@@ -45,7 +45,7 @@ |
||
45 | 45 | |
46 | 46 | protected function processEnd(Context $context, Language $language, Result $result, TokenIterator $tokens) |
47 | 47 | { |
48 | - foreach(array_filter($context->stack, function ($name) { |
|
48 | + foreach (array_filter($context->stack, function($name) { |
|
49 | 49 | return in_array($name, $this->closes); |
50 | 50 | }) as $hash => $name) { |
51 | 51 | $end = new Token([$name, 'pos' => $this->pos]); |
@@ -30,7 +30,7 @@ |
||
30 | 30 | |
31 | 31 | public function find($needle) { |
32 | 32 | foreach (array_reverse($this->stack, true) as $id => $name) { |
33 | - if($name === $needle) { |
|
33 | + if ($name === $needle) { |
|
34 | 34 | return $id; |
35 | 35 | } |
36 | 36 | } |
@@ -28,7 +28,7 @@ |
||
28 | 28 | $this->_source = $source; |
29 | 29 | $this->_start = $start; |
30 | 30 | |
31 | - parent::__construct($start !== null ? [ $start->id => $start ] : [], 0, \ArrayIterator::class); |
|
31 | + parent::__construct($start !== null ? [$start->id => $start] : [], 0, \ArrayIterator::class); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | public function getSource() |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | $css = new Css(); |
34 | 34 | $js = new JavaScript(); |
35 | 35 | $this->rules->addMany([ |
36 | - 'language.'.$js->getIdentifier() => [ |
|
36 | + 'language.' . $js->getIdentifier() => [ |
|
37 | 37 | new OpenRule(new RegexMatcher('/<script.*?>()/'), [ |
38 | 38 | 'factory' => new TokenFactory(LanguageToken::class), |
39 | 39 | 'inject' => $js, |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | 'language' => $js |
46 | 46 | ]) |
47 | 47 | ], |
48 | - 'language.'.$css->getIdentifier() => [ |
|
48 | + 'language.' . $css->getIdentifier() => [ |
|
49 | 49 | new OpenRule(new RegexMatcher('/<style.*?>()/'), [ |
50 | 50 | 'factory' => new TokenFactory(LanguageToken::class), |
51 | 51 | 'inject' => $css, |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | public function __construct(array $singleLine = null, array $multiLine = null) |
32 | 32 | { |
33 | 33 | $this->singleLine = $singleLine ?: []; |
34 | - $this->multiLine = $multiLine ?: []; |
|
34 | + $this->multiLine = $multiLine ?: []; |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | $all = []; |
50 | 50 | |
51 | 51 | foreach ($this->multiLine as $name => $comment) { |
52 | - $comment = array_map(function ($e) { return preg_quote($e, '/'); }, $comment); |
|
52 | + $comment = array_map(function($e) { return preg_quote($e, '/'); }, $comment); |
|
53 | 53 | |
54 | 54 | $all[] = [$name, "/{$comment[0]}(.*?){$comment[1]}/ms"]; |
55 | 55 | } |
@@ -49,7 +49,7 @@ |
||
49 | 49 | |
50 | 50 | $callable = $this->callable; |
51 | 51 | foreach ($matches as $match) { |
52 | - foreach($callable($match, $factory) as $token) { |
|
52 | + foreach ($callable($match, $factory) as $token) { |
|
53 | 53 | yield $token; |
54 | 54 | } |
55 | 55 | } |
@@ -32,7 +32,7 @@ |
||
32 | 32 | { |
33 | 33 | public function __construct($name, $options = []) { |
34 | 34 | parent::__construct($name, $options); |
35 | - if(isset($options['inject'])) { |
|
35 | + if (isset($options['inject'])) { |
|
36 | 36 | $this->inject = $options['inject']; |
37 | 37 | } |
38 | 38 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | 'enabled' => true |
61 | 61 | ], $options); |
62 | 62 | |
63 | - if(isset($options['context'])) { |
|
63 | + if (isset($options['context'])) { |
|
64 | 64 | $this->setContext($options['context']); |
65 | 65 | } |
66 | 66 | |
@@ -71,11 +71,11 @@ discard block |
||
71 | 71 | } |
72 | 72 | |
73 | 73 | public function setContext($context) { |
74 | - if(is_array($context)) { |
|
74 | + if (is_array($context)) { |
|
75 | 75 | $this->validator = new Validator($context); |
76 | - } elseif(is_callable($context)) { |
|
76 | + } elseif (is_callable($context)) { |
|
77 | 77 | $this->validator = new DelegateValidator($context); |
78 | - }elseif($context instanceof Validator) { |
|
78 | + }elseif ($context instanceof Validator) { |
|
79 | 79 | $this->validator = $context; |
80 | 80 | } else { |
81 | 81 | throw new \InvalidArgumentException('$context must be valid Validator'); |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * |
49 | 49 | * @return false|Token|null |
50 | 50 | */ |
51 | - public function create($name, $params = [ ]) |
|
51 | + public function create($name, $params = []) |
|
52 | 52 | { |
53 | 53 | if ($name !== null) { |
54 | 54 | $name = $this->getName($name); |
@@ -72,29 +72,29 @@ discard block |
||
72 | 72 | } |
73 | 73 | |
74 | 74 | private function link($name, $params) { |
75 | - if($this->_type & Token::START) { |
|
76 | - if(!isset($params['start'])) { |
|
75 | + if ($this->_type & Token::START) { |
|
76 | + if (!isset($params['start'])) { |
|
77 | 77 | $params['start'] = new $params['class']($name, $params); |
78 | 78 | } |
79 | 79 | |
80 | - if($this->_type === Token::START) { |
|
80 | + if ($this->_type === Token::START) { |
|
81 | 81 | $params['start']->setEnd(false); |
82 | 82 | return $params['start']; |
83 | 83 | } |
84 | 84 | } |
85 | 85 | |
86 | - if($this->_type & Token::END) { |
|
86 | + if ($this->_type & Token::END) { |
|
87 | 87 | if (isset($params['length'])) { |
88 | 88 | $end = $params; |
89 | 89 | $end['pos'] += $params['length']; |
90 | 90 | |
91 | 91 | /** @var Token $end */ |
92 | 92 | $params['end'] = new $params['class']($name, $end); |
93 | - } elseif(!isset($params['end'])) { |
|
93 | + } elseif (!isset($params['end'])) { |
|
94 | 94 | $params['end'] = new $params['class']($name, $params); |
95 | 95 | } |
96 | 96 | |
97 | - if($this->_type === Token::END) { |
|
97 | + if ($this->_type === Token::END) { |
|
98 | 98 | $params['end']->setStart(false); |
99 | 99 | return $params['end']; |
100 | 100 | } |