@@ -37,7 +37,7 @@ |
||
| 37 | 37 | * |
| 38 | 38 | * @return string |
| 39 | 39 | */ |
| 40 | - public function close( Line$closerLine ):string |
|
| 40 | + public function close(Line$closerLine):string |
|
| 41 | 41 | { |
| 42 | 42 | return ''; |
| 43 | 43 | } |
@@ -49,11 +49,11 @@ discard block |
||
| 49 | 49 | * @param \Htsl\Parser\Document $document |
| 50 | 50 | * @param \Htsl\ReadingBuffer\Line $line |
| 51 | 51 | */ |
| 52 | - final public function __construct( Document$document, Line$line ) |
|
| 52 | + final public function __construct(Document$document, Line$line) |
|
| 53 | 53 | { |
| 54 | - $this->htsl= $document->htsl; |
|
| 55 | - $this->document= $document; |
|
| 56 | - $this->line= $line; |
|
| 54 | + $this->htsl=$document->htsl; |
|
| 55 | + $this->document=$document; |
|
| 56 | + $this->line=$line; |
|
| 57 | 57 | |
| 58 | 58 | $this->construct(); |
| 59 | 59 | } |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | * |
| 80 | 80 | * @return string |
| 81 | 81 | */ |
| 82 | - abstract public function close( Line$closerLine ):string; |
|
| 82 | + abstract public function close(Line$closerLine):string; |
|
| 83 | 83 | |
| 84 | 84 | /** |
| 85 | 85 | * Getting whether this node contains a scope and scope name. |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | public function getNodeType() |
| 100 | 100 | { |
| 101 | 101 | static $nodeType; |
| 102 | - return $nodeType??$nodeType= $this->nodeType??(static function($className){return strtolower(preg_replace('/(?<=\\w)([A-Z])/','_$1',preg_replace('/^(?:\\w+\\\\)*(\\w+)Node$/','$1',$className)));})(get_class($this)); |
|
| 102 | + return $nodeType??$nodeType=$this->nodeType??(static function($className) {return strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_$1', preg_replace('/^(?:\\w+\\\\)*(\\w+)Node$/', '$1', $className))); })(get_class($this)); |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | /** |
@@ -110,41 +110,41 @@ discard block |
||
| 110 | 110 | * |
| 111 | 111 | * @return \Htsl\Parser\Node\Contracts\ANode |
| 112 | 112 | */ |
| 113 | - protected function loadConfig( string$name, IConfigProvider$configProvider ) |
|
| 113 | + protected function loadConfig(string$name, IConfigProvider$configProvider) |
|
| 114 | 114 | { |
| 115 | - $config= $configProvider->getConfig($this->nodeType.'_nodes',$name) ?: $configProvider->getConfig($this->nodeType.'_nodes','*'); |
|
| 115 | + $config=$configProvider->getConfig($this->nodeType.'_nodes', $name) ?: $configProvider->getConfig($this->nodeType.'_nodes', '*'); |
|
| 116 | 116 | |
| 117 | - if( isset($config['multiple']) ){ |
|
| 118 | - foreach( $config['multiple'] as $value ){ |
|
| 119 | - if( $this->line->pregGet($value['pattern']) ){ |
|
| 120 | - $config= $value; |
|
| 117 | + if (isset($config['multiple'])) { |
|
| 118 | + foreach ($config['multiple'] as $value) { |
|
| 119 | + if ($this->line->pregGet($value['pattern'])) { |
|
| 120 | + $config=$value; |
|
| 121 | 121 | break; |
| 122 | 122 | } |
| 123 | 123 | } |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | - if( isset($config['in']) ){ |
|
| 127 | - $config=(function( array$config )use($name){ |
|
| 128 | - foreach( $config['in'] as $key=>$value ){ |
|
| 129 | - if( $this->document->scope && $this->document->scope->scope===$key ){ |
|
| 130 | - $value['in_scope']= $key; |
|
| 126 | + if (isset($config['in'])) { |
|
| 127 | + $config=(function(array$config)use($name){ |
|
| 128 | + foreach ($config['in'] as $key=>$value) { |
|
| 129 | + if ($this->document->scope && $this->document->scope->scope===$key) { |
|
| 130 | + $value['in_scope']=$key; |
|
| 131 | 131 | return $value; |
| 132 | 132 | } |
| 133 | 133 | } |
| 134 | - if( !isset($config['out']) ){ |
|
| 135 | - $this->document->throw("The $this->nodeType node $name only use in scope ".implode(',',array_keys($config['in']))); |
|
| 134 | + if (!isset($config['out'])) { |
|
| 135 | + $this->document->throw("The $this->nodeType node $name only use in scope ".implode(',', array_keys($config['in']))); |
|
| 136 | 136 | } |
| 137 | 137 | return $config['out']; |
| 138 | 138 | })($config); |
| 139 | - }elseif( isset($config['only_in']) && (!$this->document->scope || !in_array($this->document->scope->scope,$config['only_in'])) ){ |
|
| 140 | - $this->document->throw("The $this->nodeType node $name only use in scope ".implode(',',$config['only_in'])); |
|
| 141 | - }elseif( isset($config['not_in']) && (!$this->document->scope || !in_array($this->document->scope->scope,$config['not_in'])) ){ |
|
| 142 | - $this->document->throw("The $this->nodeType node $name not use in scope ".implode(',',$config['not_in'])); |
|
| 139 | + }elseif (isset($config['only_in']) && (!$this->document->scope || !in_array($this->document->scope->scope, $config['only_in']))) { |
|
| 140 | + $this->document->throw("The $this->nodeType node $name only use in scope ".implode(',', $config['only_in'])); |
|
| 141 | + }elseif (isset($config['not_in']) && (!$this->document->scope || !in_array($this->document->scope->scope, $config['not_in']))) { |
|
| 142 | + $this->document->throw("The $this->nodeType node $name not use in scope ".implode(',', $config['not_in'])); |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - if( !is_array($config) ){$this->document->throw("The $this->nodeType node $name is not supported.");} |
|
| 145 | + if (!is_array($config)) {$this->document->throw("The $this->nodeType node $name is not supported."); } |
|
| 146 | 146 | |
| 147 | - $this->config= $config; |
|
| 147 | + $this->config=$config; |
|
| 148 | 148 | |
| 149 | 149 | return $this; |
| 150 | 150 | } |
@@ -136,9 +136,9 @@ |
||
| 136 | 136 | } |
| 137 | 137 | return $config['out']; |
| 138 | 138 | })($config); |
| 139 | - }elseif( isset($config['only_in']) && (!$this->document->scope || !in_array($this->document->scope->scope,$config['only_in'])) ){ |
|
| 139 | + } elseif( isset($config['only_in']) && (!$this->document->scope || !in_array($this->document->scope->scope,$config['only_in'])) ){ |
|
| 140 | 140 | $this->document->throw("The $this->nodeType node $name only use in scope ".implode(',',$config['only_in'])); |
| 141 | - }elseif( isset($config['not_in']) && (!$this->document->scope || !in_array($this->document->scope->scope,$config['not_in'])) ){ |
|
| 141 | + } elseif( isset($config['not_in']) && (!$this->document->scope || !in_array($this->document->scope->scope,$config['not_in'])) ){ |
|
| 142 | 142 | $this->document->throw("The $this->nodeType node $name not use in scope ".implode(',',$config['not_in'])); |
| 143 | 143 | } |
| 144 | 144 | |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | */ |
| 26 | 26 | protected function construct():parent |
| 27 | 27 | { |
| 28 | - $this->name= null; |
|
| 28 | + $this->name=null; |
|
| 29 | 29 | |
| 30 | 30 | return $this; |
| 31 | 31 | } |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | * |
| 50 | 50 | * @return string |
| 51 | 51 | */ |
| 52 | - public function close( Line$closerLine ):string |
|
| 52 | + public function close(Line$closerLine):string |
|
| 53 | 53 | { |
| 54 | 54 | $this->document->setSection(null); |
| 55 | 55 | |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | */ |
| 26 | 26 | protected function construct():parent |
| 27 | 27 | { |
| 28 | - $this->name= $this->line->pregGet('/(?<=\( ).*(?= \))/'); |
|
| 28 | + $this->name=$this->line->pregGet('/(?<=\( ).*(?= \))/'); |
|
| 29 | 29 | |
| 30 | 30 | return $this; |
| 31 | 31 | } |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | * |
| 50 | 50 | * @return string |
| 51 | 51 | */ |
| 52 | - public function close( Line$closerLine ):string |
|
| 52 | + public function close(Line$closerLine):string |
|
| 53 | 53 | { |
| 54 | 54 | $this->document->setSection(null); |
| 55 | 55 | |