| @@ -2,8 +2,8 @@ | ||
| 2 | 2 | |
| 3 | 3 |  spl_autoload_register(function ($class) { | 
| 4 | 4 | $file = __DIR__ . DIRECTORY_SEPARATOR . $class . '.php'; | 
| 5 | -	if (!class_exists($class) && is_file($file)) { | |
| 5 | +    if (!class_exists($class) && is_file($file)) { | |
| 6 | 6 | /** @noinspection PhpIncludeInspection */ | 
| 7 | 7 | require_once $file; | 
| 8 | - } | |
| 8 | + } | |
| 9 | 9 | }); | 
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | <?php | 
| 2 | 2 | |
| 3 | -spl_autoload_register(function ($class) { | |
| 3 | +spl_autoload_register(function($class) { | |
| 4 | 4 | $file = __DIR__ . DIRECTORY_SEPARATOR . $class . '.php'; | 
| 5 | 5 |  	if (!class_exists($class) && is_file($file)) { | 
| 6 | 6 | /** @noinspection PhpIncludeInspection */ | 
| @@ -13,41 +13,41 @@ | ||
| 13 | 13 | */ | 
| 14 | 14 |  class CaseSensitive extends Parser { | 
| 15 | 15 | |
| 16 | - use ArgumentsTrait; | |
| 17 | - | |
| 18 | - /** | |
| 19 | - * @var Parser | |
| 20 | - */ | |
| 21 | - private $parser = null; | |
| 22 | - | |
| 23 | - /** | |
| 24 | - * @var bool | |
| 25 | - */ | |
| 26 | - private $sensitivity = null; | |
| 27 | - | |
| 28 | - /** | |
| 29 | - * | |
| 30 | - * @param Parser|string|integer $parser | |
| 31 | - * @param bool $sensitivity | |
| 32 | - */ | |
| 33 | - public function __construct($sensitivity, $parser) | |
| 34 | -	{ | |
| 35 | - $this->parser = self::getArgument($parser); | |
| 36 | - $this->sensitivity = (bool) $sensitivity; | |
| 37 | - } | |
| 38 | - | |
| 39 | - protected function parse(&$input, $offset, Context $context) | |
| 40 | -	{ | |
| 41 | - $context->pushCaseSensitivity($this->sensitivity); | |
| 42 | - $match = $this->parser->parse($input, $offset, $context); | |
| 43 | - $context->popCaseSensitivity(); | |
| 44 | - | |
| 45 | - return $match; | |
| 46 | - } | |
| 47 | - | |
| 48 | - public function __toString() | |
| 49 | -	{ | |
| 50 | - return ($this->sensitivity ? 'case' : 'no-case') . '( ' . $this->parser . ' )'; | |
| 51 | - } | |
| 16 | + use ArgumentsTrait; | |
| 17 | + | |
| 18 | + /** | |
| 19 | + * @var Parser | |
| 20 | + */ | |
| 21 | + private $parser = null; | |
| 22 | + | |
| 23 | + /** | |
| 24 | + * @var bool | |
| 25 | + */ | |
| 26 | + private $sensitivity = null; | |
| 27 | + | |
| 28 | + /** | |
| 29 | + * | |
| 30 | + * @param Parser|string|integer $parser | |
| 31 | + * @param bool $sensitivity | |
| 32 | + */ | |
| 33 | + public function __construct($sensitivity, $parser) | |
| 34 | +    { | |
| 35 | + $this->parser = self::getArgument($parser); | |
| 36 | + $this->sensitivity = (bool) $sensitivity; | |
| 37 | + } | |
| 38 | + | |
| 39 | + protected function parse(&$input, $offset, Context $context) | |
| 40 | +    { | |
| 41 | + $context->pushCaseSensitivity($this->sensitivity); | |
| 42 | + $match = $this->parser->parse($input, $offset, $context); | |
| 43 | + $context->popCaseSensitivity(); | |
| 44 | + | |
| 45 | + return $match; | |
| 46 | + } | |
| 47 | + | |
| 48 | + public function __toString() | |
| 49 | +    { | |
| 50 | + return ($this->sensitivity ? 'case' : 'no-case') . '( ' . $this->parser . ' )'; | |
| 51 | + } | |
| 52 | 52 | |
| 53 | 53 | } | 
| @@ -13,42 +13,42 @@ | ||
| 13 | 13 | */ | 
| 14 | 14 |  class Space extends Parser { | 
| 15 | 15 | |
| 16 | - use ArgumentsTrait; | |
| 16 | + use ArgumentsTrait; | |
| 17 | 17 | |
| 18 | 18 | /** | 
| 19 | 19 | * @var null|Parser | 
| 20 | 20 | */ | 
| 21 | - private $spacer = null; | |
| 22 | - | |
| 23 | - /** | |
| 24 | - * @var null|Parser | |
| 25 | - */ | |
| 26 | - private $parser = null; | |
| 27 | - | |
| 28 | - /** | |
| 29 | - * Set (or disable) a spacer for the parser | |
| 30 | - * | |
| 31 | - * @param Parser|string|int|bool|null $spacer | |
| 32 | - * @param Parser|string|int $parser | |
| 33 | - */ | |
| 34 | - public function __construct($spacer, $parser) | |
| 35 | -	{ | |
| 36 | - $this->spacer = $spacer === null ? null : self::getArgument($spacer); | |
| 37 | - $this->parser = self::getArgument($parser); | |
| 38 | - } | |
| 39 | - | |
| 40 | - protected function parse(&$input, $offset, Context $context) | |
| 41 | -	{ | |
| 42 | - $context->pushSpacer($this->spacer); | |
| 43 | - $match = $this->parser->parse($input, $offset, $context); | |
| 44 | - $context->popSpacer(); | |
| 45 | - | |
| 46 | - return $match; | |
| 47 | - } | |
| 21 | + private $spacer = null; | |
| 22 | + | |
| 23 | + /** | |
| 24 | + * @var null|Parser | |
| 25 | + */ | |
| 26 | + private $parser = null; | |
| 27 | + | |
| 28 | + /** | |
| 29 | + * Set (or disable) a spacer for the parser | |
| 30 | + * | |
| 31 | + * @param Parser|string|int|bool|null $spacer | |
| 32 | + * @param Parser|string|int $parser | |
| 33 | + */ | |
| 34 | + public function __construct($spacer, $parser) | |
| 35 | +    { | |
| 36 | + $this->spacer = $spacer === null ? null : self::getArgument($spacer); | |
| 37 | + $this->parser = self::getArgument($parser); | |
| 38 | + } | |
| 39 | + | |
| 40 | + protected function parse(&$input, $offset, Context $context) | |
| 41 | +    { | |
| 42 | + $context->pushSpacer($this->spacer); | |
| 43 | + $match = $this->parser->parse($input, $offset, $context); | |
| 44 | + $context->popSpacer(); | |
| 45 | + | |
| 46 | + return $match; | |
| 47 | + } | |
| 48 | 48 | |
| 49 | - public function __toString() | |
| 50 | -	{ | |
| 51 | - return (string) $this->parser; | |
| 52 | - } | |
| 49 | + public function __toString() | |
| 50 | +    { | |
| 51 | + return (string) $this->parser; | |
| 52 | + } | |
| 53 | 53 | |
| 54 | 54 | } | 
| @@ -100,12 +100,12 @@ | ||
| 100 | 100 | [repeat(6, 6, [$this->h16, ':']), $this->ls32], | 
| 101 | 101 | ['::', repeat(5, 5, [$this->h16, ':']), $this->ls32], | 
| 102 | 102 | [opt($this->h16), '::', repeat(4, 4, [$this->h16, ':']), $this->ls32], | 
| 103 | - [opt([repeat(0, 1, [$this->h16, ':',]), $this->h16]), '::', repeat(3, 3, [$this->h16, ':']), $this->ls32], | |
| 104 | - [opt([repeat(0, 2, [$this->h16, ':',]), $this->h16]), '::', repeat(2, 2, [$this->h16, ':']), $this->ls32], | |
| 105 | - [opt([repeat(0, 3, [$this->h16, ':',]), $this->h16]), '::', $this->h16, ':', $this->ls32], | |
| 106 | - [opt([repeat(0, 4, [$this->h16, ':',]), $this->h16]), '::', $this->ls32], | |
| 107 | - [opt([repeat(0, 5, [$this->h16, ':',]), $this->h16]), '::', $this->h16], | |
| 108 | - [opt([repeat(0, 6, [$this->h16, ':',]), $this->h16]), '::'] | |
| 103 | + [opt([repeat(0, 1, [$this->h16, ':', ]), $this->h16]), '::', repeat(3, 3, [$this->h16, ':']), $this->ls32], | |
| 104 | + [opt([repeat(0, 2, [$this->h16, ':', ]), $this->h16]), '::', repeat(2, 2, [$this->h16, ':']), $this->ls32], | |
| 105 | + [opt([repeat(0, 3, [$this->h16, ':', ]), $this->h16]), '::', $this->h16, ':', $this->ls32], | |
| 106 | + [opt([repeat(0, 4, [$this->h16, ':', ]), $this->h16]), '::', $this->ls32], | |
| 107 | + [opt([repeat(0, 5, [$this->h16, ':', ]), $this->h16]), '::', $this->h16], | |
| 108 | + [opt([repeat(0, 6, [$this->h16, ':', ]), $this->h16]), '::'] | |
| 109 | 109 | ), | 
| 110 | 110 | 'dec_octet' => c( | 
| 111 | 111 |                  ['25', range('0', '5')], // 250-255
 | 
| @@ -9,14 +9,14 @@ | ||
| 9 | 9 | */ | 
| 10 | 10 |  class Failure extends Match { | 
| 11 | 11 | |
| 12 | - public function __get($name) | |
| 13 | -	{ | |
| 14 | - return $name === 'match' ? false : parent::__get($name); | |
| 15 | - } | |
| 12 | + public function __get($name) | |
| 13 | +    { | |
| 14 | + return $name === 'match' ? false : parent::__get($name); | |
| 15 | + } | |
| 16 | 16 | |
| 17 | - public function __toString() | |
| 18 | -	{ | |
| 19 | - return 'Failed match at ' . $this->length . ' characters'; | |
| 20 | - } | |
| 17 | + public function __toString() | |
| 18 | +    { | |
| 19 | + return 'Failed match at ' . $this->length . ' characters'; | |
| 20 | + } | |
| 21 | 21 | |
| 22 | 22 | } | 
| @@ -8,7 +8,7 @@ | ||
| 8 | 8 | |
| 9 | 9 | public function pushCaseSensitivity($case_sensitive = TRUE) | 
| 10 | 10 |      {
 | 
| 11 | - array_push($this->case_sensitivity, (bool)$case_sensitive); | |
| 11 | + array_push($this->case_sensitivity, (bool) $case_sensitive); | |
| 12 | 12 | } | 
| 13 | 13 | |
| 14 | 14 | public function popCaseSensitivity() | 
| @@ -53,7 +53,7 @@ | ||
| 53 | 53 | |
| 54 | 54 | protected static function getArguments($arguments, $arrayToSequence = true) | 
| 55 | 55 |      { | 
| 56 | -        return array_map(function ($argument) use ($arrayToSequence) { | |
| 56 | +        return array_map(function($argument) use ($arrayToSequence) { | |
| 57 | 57 | return self::getArgument($argument, $arrayToSequence); | 
| 58 | 58 | }, $arguments); | 
| 59 | 59 | } | 
| @@ -98,7 +98,7 @@ discard block | ||
| 98 | 98 | $success = new Success($length, $successes); | 
| 99 | 99 | |
| 100 | 100 | // ResultTrait | 
| 101 | -        $success->addResultCallback(function (&$results) use ($input, $offset, $length) {
 | |
| 101 | +        $success->addResultCallback(function(&$results) use ($input, $offset, $length) {
 | |
| 102 | 102 | $text = substr($input, $offset, $length); | 
| 103 | 103 | |
| 104 | 104 | $this->resolveResultCallbacks($results, $text); | 
| @@ -106,7 +106,7 @@ discard block | ||
| 106 | 106 | |
| 107 | 107 | // AssignTrait | 
| 108 | 108 | $callbacks = $this->callbacks; | 
| 109 | -        $success->addCustomCallback(function () use ($input, $offset, $length, $callbacks) {
 | |
| 109 | +        $success->addCustomCallback(function() use ($input, $offset, $length, $callbacks) {
 | |
| 110 | 110 | $text = substr($input, $offset, $length); | 
| 111 | 111 | |
| 112 | 112 | $this->resolveAssignCallbacks($text); | 
| @@ -117,7 +117,7 @@ discard block | ||
| 117 | 117 | }); | 
| 118 | 118 | |
| 119 | 119 | // TokenTrait | 
| 120 | -        $success->setTokenCallback(function (&$children) use ($input, $offset, $length) {
 | |
| 120 | +        $success->setTokenCallback(function(&$children) use ($input, $offset, $length) {
 | |
| 121 | 121 | return $this->resolveToken($input, $offset, $length, $children, get_class($this)); | 
| 122 | 122 | }); | 
| 123 | 123 | |
| @@ -14,48 +14,48 @@ | ||
| 14 | 14 | */ | 
| 15 | 15 |  class Stub extends Parser { | 
| 16 | 16 | |
| 17 | - use ArgumentsTrait; | |
| 18 | - | |
| 19 | - /** | |
| 20 | - * @var Parser|null | |
| 21 | - */ | |
| 22 | - private $parser = null; | |
| 23 | - | |
| 24 | - public function __set($name, $parser) | |
| 25 | -	{ | |
| 26 | -		if ($name == 'parser') { | |
| 27 | - return $this->parser = self::getArgument($parser); | |
| 28 | - } | |
| 17 | + use ArgumentsTrait; | |
| 18 | + | |
| 19 | + /** | |
| 20 | + * @var Parser|null | |
| 21 | + */ | |
| 22 | + private $parser = null; | |
| 23 | + | |
| 24 | + public function __set($name, $parser) | |
| 25 | +    { | |
| 26 | +        if ($name == 'parser') { | |
| 27 | + return $this->parser = self::getArgument($parser); | |
| 28 | + } | |
| 29 | 29 | |
| 30 | -		throw new \InvalidArgumentException("Property `{$name}` does not exist"); | |
| 31 | - } | |
| 32 | - | |
| 33 | - public function __get($name) | |
| 34 | -	{ | |
| 35 | -		if ($name == 'parser') { | |
| 36 | - return $this->parser; | |
| 37 | - } | |
| 30 | +        throw new \InvalidArgumentException("Property `{$name}` does not exist"); | |
| 31 | + } | |
| 32 | + | |
| 33 | + public function __get($name) | |
| 34 | +    { | |
| 35 | +        if ($name == 'parser') { | |
| 36 | + return $this->parser; | |
| 37 | + } | |
| 38 | 38 | |
| 39 | -		throw new \InvalidArgumentException("Property `{$name}` does not exist"); | |
| 40 | - } | |
| 41 | - | |
| 42 | - protected function parse(&$input, $offset, Context $context) | |
| 43 | -	{ | |
| 44 | -		if ($this->parser === null) { | |
| 45 | -			throw new \UnexpectedValueException('Missing parser'); | |
| 46 | - } | |
| 47 | - | |
| 48 | - $match = $this->parser->parse($input, $offset, $context); | |
| 49 | -		if ($match->match) { | |
| 50 | - return $this->success($input, $offset, $match->length, $match); | |
| 51 | - } | |
| 52 | - | |
| 53 | - return $this->failure($input, $offset, $match->length); | |
| 54 | - } | |
| 55 | - | |
| 56 | - public function __toString() | |
| 57 | -	{ | |
| 58 | - return $this->parser ? (string) $this->parser : '<undefined>'; | |
| 59 | - } | |
| 39 | +        throw new \InvalidArgumentException("Property `{$name}` does not exist"); | |
| 40 | + } | |
| 41 | + | |
| 42 | + protected function parse(&$input, $offset, Context $context) | |
| 43 | +    { | |
| 44 | +        if ($this->parser === null) { | |
| 45 | +            throw new \UnexpectedValueException('Missing parser'); | |
| 46 | + } | |
| 47 | + | |
| 48 | + $match = $this->parser->parse($input, $offset, $context); | |
| 49 | +        if ($match->match) { | |
| 50 | + return $this->success($input, $offset, $match->length, $match); | |
| 51 | + } | |
| 52 | + | |
| 53 | + return $this->failure($input, $offset, $match->length); | |
| 54 | + } | |
| 55 | + | |
| 56 | + public function __toString() | |
| 57 | +    { | |
| 58 | + return $this->parser ? (string) $this->parser : '<undefined>'; | |
| 59 | + } | |
| 60 | 60 | |
| 61 | 61 | } |