mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
BUGFIX: match_function had been partially refactored to take $value as an argument rather than from the instance variable, but that hadnt been completed, causing problems with E_STRICT. This completes that refactoring.
This commit is contained in:
parent
aa14a5191e
commit
7ae9f8af84
40
thirdparty/php-peg/Compiler.php
vendored
40
thirdparty/php-peg/Compiler.php
vendored
@ -139,7 +139,7 @@ abstract class Token extends PHPWriter {
|
|||||||
// abstract protected function match_code() ;
|
// abstract protected function match_code() ;
|
||||||
|
|
||||||
function compile() {
|
function compile() {
|
||||||
$code = $this->match_code() ;
|
$code = $this->match_code($this->value) ;
|
||||||
|
|
||||||
$id = $this->varid() ;
|
$id = $this->varid() ;
|
||||||
|
|
||||||
@ -254,8 +254,8 @@ abstract class TokenExpressionable extends TokenTerminal {
|
|||||||
|
|
||||||
static $expression_rx = '/ \$(\w+) | { \$(\w+) } /x';
|
static $expression_rx = '/ \$(\w+) | { \$(\w+) } /x';
|
||||||
|
|
||||||
function contains_expression(){
|
function contains_expression( $value ){
|
||||||
return preg_match(self::$expression_rx, $this->value);
|
return preg_match(self::$expression_rx, $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
function expression_replace($matches) {
|
function expression_replace($matches) {
|
||||||
@ -275,15 +275,15 @@ class TokenLiteral extends TokenExpressionable {
|
|||||||
|
|
||||||
function match_code( $value ) {
|
function match_code( $value ) {
|
||||||
// We inline single-character matches for speed
|
// We inline single-character matches for speed
|
||||||
if ( !$this->contains_expression() && strlen( eval( 'return '. $this->value . ';' ) ) == 1 ) {
|
if ( !$this->contains_expression($value) && strlen( eval( 'return '. $value . ';' ) ) == 1 ) {
|
||||||
return $this->match_fail_conditional( 'substr($this->string,$this->pos,1) == '.$this->value,
|
return $this->match_fail_conditional( 'substr($this->string,$this->pos,1) == '.$value,
|
||||||
PHPBuilder::build()->l(
|
PHPBuilder::build()->l(
|
||||||
'$this->pos += 1;',
|
'$this->pos += 1;',
|
||||||
$this->set_text( $this->value )
|
$this->set_text($value)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return parent::match_code($this->value);
|
return parent::match_code($value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -299,7 +299,7 @@ class TokenRegex extends TokenExpressionable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function match_code( $value ) {
|
function match_code( $value ) {
|
||||||
return parent::match_code("'{$this->value}'");
|
return parent::match_code("'{$value}'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -311,7 +311,7 @@ class TokenWhitespace extends TokenTerminal {
|
|||||||
/* Call recursion indirectly */
|
/* Call recursion indirectly */
|
||||||
function match_code( $value ) {
|
function match_code( $value ) {
|
||||||
$code = parent::match_code( '' ) ;
|
$code = parent::match_code( '' ) ;
|
||||||
return $this->value ? $code->replace( array( 'FAIL' => NULL )) : $code ;
|
return $value ? $code->replace( array( 'FAIL' => NULL )) : $code ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -320,13 +320,13 @@ class TokenRecurse extends Token {
|
|||||||
parent::__construct( 'recurse', $value ) ;
|
parent::__construct( 'recurse', $value ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
function match_function() {
|
function match_function( $value ) {
|
||||||
return "'".$this->function_name($this->value)."'";
|
return "'".$this->function_name($value)."'";
|
||||||
}
|
}
|
||||||
|
|
||||||
function match_code() {
|
function match_code( $value ) {
|
||||||
$function = $this->match_function() ;
|
$function = $this->match_function($value) ;
|
||||||
$storetag = $this->function_name( $this->tag ? $this->tag : $this->match_function() ) ;
|
$storetag = $this->function_name( $this->tag ? $this->tag : $this->match_function($value) ) ;
|
||||||
|
|
||||||
if ( ParserCompiler::$debug ) {
|
if ( ParserCompiler::$debug ) {
|
||||||
$debug_header = PHPBuilder::build()
|
$debug_header = PHPBuilder::build()
|
||||||
@ -373,8 +373,8 @@ class TokenRecurse extends Token {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class TokenExpressionedRecurse extends TokenRecurse {
|
class TokenExpressionedRecurse extends TokenRecurse {
|
||||||
function match_function() {
|
function match_function( $value ) {
|
||||||
return '$this->expression($result, $stack, \''.$this->value.'\')';
|
return '$this->expression($result, $stack, \''.$value.'\')';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -383,9 +383,9 @@ class TokenSequence extends Token {
|
|||||||
parent::__construct( 'sequence', $value ) ;
|
parent::__construct( 'sequence', $value ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
function match_code() {
|
function match_code( $value ) {
|
||||||
$code = PHPBuilder::build() ;
|
$code = PHPBuilder::build() ;
|
||||||
foreach( $this->value as $token ) {
|
foreach( $value as $token ) {
|
||||||
$code->l(
|
$code->l(
|
||||||
$token->compile()->replace(array(
|
$token->compile()->replace(array(
|
||||||
'MATCH' => NULL,
|
'MATCH' => NULL,
|
||||||
@ -404,14 +404,14 @@ class TokenOption extends Token {
|
|||||||
parent::__construct( 'option', array( $opt1, $opt2 ) ) ;
|
parent::__construct( 'option', array( $opt1, $opt2 ) ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
function match_code() {
|
function match_code( $value ) {
|
||||||
$id = $this->varid() ;
|
$id = $this->varid() ;
|
||||||
$code = PHPBuilder::build()
|
$code = PHPBuilder::build()
|
||||||
->l(
|
->l(
|
||||||
$this->save($id)
|
$this->save($id)
|
||||||
) ;
|
) ;
|
||||||
|
|
||||||
foreach ( $this->value as $opt ) {
|
foreach ( $value as $opt ) {
|
||||||
$code->l(
|
$code->l(
|
||||||
$opt->compile()->replace(array(
|
$opt->compile()->replace(array(
|
||||||
'MATCH' => 'MBREAK',
|
'MATCH' => 'MBREAK',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user