Completed
Pull Request — master (#1)
by Fenz
07:21
created
libs/Parser/Node/CommentNode.php 1 patch
Spacing   +5 added lines, -6 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
      */
24 24
     protected function construct():parent
25 25
     {
26
-        $this->htmlComment = '!' !== $this->line->getChar(1);
26
+        $this->htmlComment='!'!==$this->line->getChar(1);
27 27
 
28 28
         return $this;
29 29
     }
@@ -35,9 +35,8 @@  discard block
 block discarded – undo
35 35
      */
36 36
     public function open():string
37 37
     {
38
-        return $this->htmlComment ?
39
-                                 '<!--'.str_replace('-->', '--'.chr(0xC).'>', substr($this->line->getContent(), 1)) :
40
-                                 '<?php /* '.substr($this->line->getContent(), 2);
38
+        return $this->htmlComment?
39
+                                 '<!--'.str_replace('-->', '--'.chr(0xC).'>', substr($this->line->getContent(), 1)) : '<?php /* '.substr($this->line->getContent(), 2);
41 40
     }
42 41
 
43 42
     /**
@@ -47,8 +46,8 @@  discard block
 block discarded – undo
47 46
      *
48 47
      * @return string
49 48
      */
50
-    public function close(Line $closerLine):string
49
+    public function close( Line $closerLine ):string
51 50
     {
52
-        return $this->htmlComment ? '-->' : ' */ ?>';
51
+        return $this->htmlComment? '-->' : ' */ ?>';
53 52
     }
54 53
 }
Please login to merge, or discard this patch.
libs/Parser/Node/SectionNode.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
      */
25 25
     protected function construct():parent
26 26
     {
27
-        $this->name = $this->line->pregGet('/(?<=\( ).*(?= \))/');
27
+        $this->name=$this->line->pregGet('/(?<=\( ).*(?= \))/');
28 28
 
29 29
         return $this;
30 30
     }
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
      *
49 49
      * @return string
50 50
      */
51
-    public function close(Line $closerLine):string
51
+    public function close( Line $closerLine ):string
52 52
     {
53 53
         $this->document->setSection(null);
54 54
 
Please login to merge, or discard this patch.
libs/Parser/Node/StringNode.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@
 block discarded – undo
36 36
      *
37 37
      * @return string
38 38
      */
39
-    public function close(Line $closerLine):string
39
+    public function close( Line $closerLine ):string
40 40
     {
41 41
         return '';
42 42
     }
Please login to merge, or discard this patch.
libs/Parser/Node/ControlNode.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -38,16 +38,16 @@  discard block
 block discarded – undo
38 38
      */
39 39
     protected function construct():parent
40 40
     {
41
-        $name = $this->line->pregGet('/(?<=^~)[\w-]*/');
42
-        $this->name = $name;
41
+        $name=$this->line->pregGet('/(?<=^~)[\w-]*/');
42
+        $this->name=$name;
43 43
 
44 44
         $this->loadConfig($name, $this->htsl);
45 45
 
46
-        $this->param = $this->line->pregGet('/^~[\w-]*\( (.*) \)/', 1);
46
+        $this->param=$this->line->pregGet('/^~[\w-]*\( (.*) \)/', 1);
47 47
 
48
-        $this->structureName = $this->config['name'] ?? $name;
48
+        $this->structureName=$this->config[ 'name' ] ?? $name;
49 49
 
50
-        $this->id = strtoupper(uniqid());
50
+        $this->id=strtoupper(uniqid());
51 51
 
52 52
         return $this;
53 53
     }
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
      */
60 60
     public function open():string
61 61
     {
62
-        return $this->withParam($this->config['opener']);
62
+        return $this->withParam($this->config[ 'opener' ]);
63 63
     }
64 64
 
65 65
     /**
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
      */
70 70
     public function getScope()
71 71
     {
72
-        return $this->config['scope'] ?? null;
72
+        return $this->config[ 'scope' ] ?? null;
73 73
     }
74 74
 
75 75
     /**
@@ -79,18 +79,18 @@  discard block
 block discarded – undo
79 79
      *
80 80
      * @return string
81 81
      */
82
-    public function close(Line $closerLine):string
82
+    public function close( Line $closerLine ):string
83 83
     {
84
-        if (isset($this->config['close_by']) && $closerLine->indentLevel == $this->line->indentLevel) {
85
-            foreach ($this->config['close_by'] as $key => $value) {
86
-                if ($closerLine->pregMatch($key)) {
84
+        if( isset($this->config[ 'close_by' ]) && $closerLine->indentLevel==$this->line->indentLevel ){
85
+            foreach( $this->config[ 'close_by' ] as $key => $value ){
86
+                if( $closerLine->pregMatch($key) ){
87 87
                     return $this->withParam($value);
88 88
                 }
89 89
             }
90 90
         }
91 91
 
92
-        if (isset($this->config['closer'])) {
93
-            return $this->withParam($this->config['closer']);
92
+        if( isset($this->config[ 'closer' ]) ){
93
+            return $this->withParam($this->config[ 'closer' ]);
94 94
         }
95 95
 
96 96
         return '';
@@ -103,16 +103,16 @@  discard block
 block discarded – undo
103 103
      *
104 104
      * @return string
105 105
      */
106
-    private function withParam(string $input)
106
+    private function withParam( string $input )
107 107
     {
108
-        return str_replace('$_FLAG_$', "__HTSL_CTRL_FLAG_{$this->id}__", preg_replace_callback('/(?<!%)%s((?:\\/.+?(?<!\\\\)\\/.+?(?<!\\\\)\\/)+)?/', function (array $matches) {
109
-            $param = $this->param;
108
+        return str_replace('$_FLAG_$', "__HTSL_CTRL_FLAG_{$this->id}__", preg_replace_callback('/(?<!%)%s((?:\\/.+?(?<!\\\\)\\/.+?(?<!\\\\)\\/)+)?/', function( array $matches ){
109
+            $param=$this->param;
110 110
 
111
-            if (isset($matches[1])) {
111
+            if( isset($matches[ 1 ]) ){
112 112
                 array_map(...[
113
-                    function ($replacer) use (&$param) {
114
-                        list($pattern, $replacement) = preg_split('/(?<!\\\\)\\//', $replacer);
115
-                        $param = preg_replace(...[
113
+                    function( $replacer ) use (&$param) {
114
+                        list($pattern, $replacement)=preg_split('/(?<!\\\\)\\//', $replacer);
115
+                        $param=preg_replace(...[
116 116
                             "/$pattern/",
117 117
                             preg_replace('/^\\\\_$/', '', $replacement),
118 118
                             $param,
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
                     },
121 121
                     preg_split(
122 122
                         '/(?<!\\\\)\\/\\//',
123
-                        trim($matches[1], '/')
123
+                        trim($matches[ 1 ], '/')
124 124
                     ),
125 125
                 ]);
126 126
             }
Please login to merge, or discard this patch.
libs/Parser/Section.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -22,16 +22,16 @@  discard block
 block discarded – undo
22 22
      *
23 23
      * @var string
24 24
      */
25
-    private $content = '';
25
+    private $content='';
26 26
 
27 27
     /**
28 28
      * Setting name and constructing instance of Section.
29 29
      *
30 30
      * @param string | null $name
31 31
      */
32
-    public function __construct(string $name = null)
32
+    public function __construct( string $name=null )
33 33
     {
34
-        $this->name = $name;
34
+        $this->name=$name;
35 35
     }
36 36
 
37 37
     /**
@@ -41,9 +41,9 @@  discard block
 block discarded – undo
41 41
      *
42 42
      * @return self
43 43
      */
44
-    public function append(string $content):self
44
+    public function append( string $content ):self
45 45
     {
46
-        $this->content .= $content;
46
+        $this->content.=$content;
47 47
 
48 48
         return $this;
49 49
     }
Please login to merge, or discard this patch.
libs/ReadingBuffer/FileBuffer.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -21,17 +21,17 @@  discard block
 block discarded – undo
21 21
      * @param Htsl   $htsl     Main Htsl object
22 22
      * @param string $filePath
23 23
      */
24
-    public function __construct(Htsl $htsl, string $filePath)
24
+    public function __construct( Htsl $htsl, string $filePath )
25 25
     {
26
-        substr($filePath, -5) === '.htsl' or $filePath .= '.htsl';
26
+        substr($filePath, -5)==='.htsl' or $filePath.='.htsl';
27 27
 
28
-        if (!file_exists($filePath) || !is_file($filePath)) {
28
+        if( !file_exists($filePath) || !is_file($filePath) ){
29 29
             throw new \Exception("File $filePath not exists.", 1);
30 30
         }
31 31
 
32
-        $this->filePath = $filePath;
32
+        $this->filePath=$filePath;
33 33
 
34
-        $this->handle = fopen($filePath, 'r');
34
+        $this->handle=fopen($filePath, 'r');
35 35
 
36 36
         parent::__construct($htsl);
37 37
     }
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
      */
52 52
     public function getLine():Line
53 53
     {
54
-        while ("\n" === $content = fgets($this->handle));
54
+        while( "\n"===$content=fgets($this->handle) );
55 55
 
56 56
         return new Line($content);
57 57
     }
@@ -63,9 +63,9 @@  discard block
 block discarded – undo
63 63
      *
64 64
      * @return \Htsl\ReadingBuffer\Contracts\ABuffer
65 65
      */
66
-    public function goSide($filePath):parent
66
+    public function goSide( $filePath ):parent
67 67
     {
68
-        $filePath = $this->htsl->getFilePath($filePath, dirname($this->filePath));
68
+        $filePath=$this->htsl->getFilePath($filePath, dirname($this->filePath));
69 69
 
70 70
         return new static($this->htsl, $filePath);
71 71
     }
Please login to merge, or discard this patch.
libs/ReadingBuffer/Contracts/ABuffer.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -23,11 +23,11 @@  discard block
 block discarded – undo
23 23
      *
24 24
      * @var string
25 25
      */
26
-    protected $fileName = '';
26
+    protected $fileName='';
27 27
 
28
-    public function __construct(Htsl $htsl)
28
+    public function __construct( Htsl $htsl )
29 29
     {
30
-        $this->htsl = $htsl;
30
+        $this->htsl=$htsl;
31 31
     }
32 32
 
33 33
     /**
@@ -54,5 +54,5 @@  discard block
 block discarded – undo
54 54
      *
55 55
      * @return \Htsl\ReadingBuffer\Contracts\ABuffer
56 56
      */
57
-    abstract public function goSide($fileName):self;
57
+    abstract public function goSide( $fileName ):self;
58 58
 }
Please login to merge, or discard this patch.
libs/ReadingBuffer/Line.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
      *
23 23
      * @var bool
24 24
      */
25
-    private $isLast = false;
25
+    private $isLast=false;
26 26
 
27 27
     /**
28 28
      * Constructor.
@@ -31,9 +31,9 @@  discard block
 block discarded – undo
31 31
      */
32 32
     public function __construct(/*string|bool*/$content)
33 33
     {
34
-        false === $content and $this->isLast = true;
34
+        false===$content and $this->isLast=true;
35 35
 
36
-        $this->content = rtrim($content, "\n");
36
+        $this->content=rtrim($content, "\n");
37 37
     }
38 38
 
39 39
     /**
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
      *
65 65
      * @return string
66 66
      */
67
-    public function slice(int $start = 0, int ...$lengths):string
67
+    public function slice( int $start=0, int ...$lengths ):string
68 68
     {
69 69
         return substr($this->getContent(), $start, ...array_slice($lengths, 0, 1));
70 70
     }
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
      *
77 77
      * @return string
78 78
      */
79
-    public function getChar(int $offset):string
79
+    public function getChar( int $offset ):string
80 80
     {
81 81
         return substr($this->getcontent(), $offset, 1);
82 82
     }
@@ -88,9 +88,9 @@  discard block
 block discarded – undo
88 88
      *
89 89
      * @return bool
90 90
      */
91
-    public function pregMatch(string $pattern):bool
91
+    public function pregMatch( string $pattern ):bool
92 92
     {
93
-        return (bool) preg_match($pattern, ltrim($this->content, "\t"));
93
+        return (bool)preg_match($pattern, ltrim($this->content, "\t"));
94 94
     }
95 95
 
96 96
     /**
@@ -101,11 +101,11 @@  discard block
 block discarded – undo
101 101
      *
102 102
      * @return string
103 103
      */
104
-    public function pregGet(string $pattern, /*int|string*/$match = 0):string
104
+    public function pregGet( string $pattern, /*int|string*/$match=0 ):string
105 105
     {
106 106
         preg_match($pattern, ltrim($this->content, "\t"), $matches);
107 107
 
108
-        return $matches[$match] ?? '';
108
+        return $matches[ $match ] ?? '';
109 109
     }
110 110
 
111 111
     /**
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
      *
117 117
      * @return array
118 118
      */
119
-    public function pregMap(string $pattern, callable $callback):array
119
+    public function pregMap( string $pattern, callable $callback ):array
120 120
     {
121 121
         preg_match_all($pattern, ltrim($this->content, "\t"), $matches);
122 122
 
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
     {
133 133
         // return (static function( $a ):int{$i=0;while($a{$i}==="\t")++$i;return $i;})($this->content);
134 134
 
135
-        return strlen($this->content) - strlen(ltrim($this->content, "\t"));
135
+        return strlen($this->content)-strlen(ltrim($this->content, "\t"));
136 136
     }
137 137
 
138 138
     /**
Please login to merge, or discard this patch.
libs/ReadingBuffer/StringBuffer.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -22,15 +22,15 @@  discard block
 block discarded – undo
22 22
      * @param string     $content
23 23
      * @param string     $filePath Fake file path to enable document controller.
24 24
      */
25
-    public function __construct(Htsl $htsl, string $content, string $filePath = '')
25
+    public function __construct( Htsl $htsl, string $content, string $filePath='' )
26 26
     {
27
-        if (false !== strpos($content, "\r")) {
27
+        if( false!==strpos($content, "\r") ){
28 28
             throw new \Exception('Line ending must be LF.', 1);
29 29
         }
30 30
 
31
-        $this->filePath = $filePath;
31
+        $this->filePath=$filePath;
32 32
 
33
-        $this->lines = array_filter(explode("\n", $content), 'strlen');
33
+        $this->lines=array_filter(explode("\n", $content), 'strlen');
34 34
         array_unshift($this->lines, null);
35 35
 
36 36
         parent::__construct($htsl);
@@ -53,10 +53,10 @@  discard block
 block discarded – undo
53 53
      *
54 54
      * @return \Htsl\ReadingBuffer\Contracts\ABuffer
55 55
      */
56
-    public function goSide($filePath):parent
56
+    public function goSide( $filePath ):parent
57 57
     {
58
-        $filePath = $this->htsl->getFilePath($filePath, dirname($this->filePath));
59
-        $content = $this->htsl->getFileContent($filePath);
58
+        $filePath=$this->htsl->getFilePath($filePath, dirname($this->filePath));
59
+        $content=$this->htsl->getFileContent($filePath);
60 60
 
61 61
         return new static($this->htsl, $content, $filePath);
62 62
     }
Please login to merge, or discard this patch.