This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Htsl\Parser\Node; |
||
4 | |||
5 | use Htsl\Htsl; |
||
6 | use Htsl\ReadingBuffer\Line; |
||
7 | use Htsl\Parser\Node\Contracts\ANode; |
||
8 | |||
9 | //////////////////////////////////////////////////////////////// |
||
10 | |||
11 | class ControlNode extends ANode |
||
12 | { |
||
13 | /** |
||
14 | * The name of the Htsl.php control structure. |
||
15 | * |
||
16 | * @access private |
||
17 | * |
||
18 | * @var string |
||
19 | */ |
||
20 | private $name; |
||
21 | |||
22 | /** |
||
23 | * The name of the complied(PHP) control structure. |
||
24 | * |
||
25 | * @access private |
||
26 | * |
||
27 | * @var string |
||
28 | */ |
||
29 | private $structureName; |
||
30 | |||
31 | /** |
||
32 | * Parameters. |
||
33 | * |
||
34 | * @access private |
||
35 | * |
||
36 | * @var string |
||
37 | */ |
||
38 | private $param; |
||
39 | |||
40 | /** |
||
41 | * Unique id for check whether loop executed. |
||
42 | * |
||
43 | * @access private |
||
44 | * |
||
45 | * @var string |
||
46 | */ |
||
47 | private $id; |
||
48 | |||
49 | /** |
||
50 | * Real constructor. |
||
51 | * |
||
52 | * @access protected |
||
53 | * |
||
54 | * @return \Htsl\Parser\Node\Contracts\ANode |
||
0 ignored issues
–
show
|
|||
55 | */ |
||
56 | protected function construct():parent |
||
57 | { |
||
58 | $name= $this->line->pregGet('/(?<=^~)[\w-]*/'); |
||
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 7 spaces but found 0 spaces
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line. To visualize $a = "a";
$ab = "ab";
$abc = "abc";
will produce issues in the first and second line, while this second example $a = "a";
$ab = "ab";
$abc = "abc";
will produce no issues. ![]() |
|||
59 | $this->name=$name; |
||
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 1 space but found 0 spaces
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line. To visualize $a = "a";
$ab = "ab";
$abc = "abc";
will produce issues in the first and second line, while this second example $a = "a";
$ab = "ab";
$abc = "abc";
will produce no issues. ![]() |
|||
60 | |||
61 | $this->loadConfig($name,$this->htsl); |
||
62 | |||
63 | $this->param= $this->line->pregGet('/^~[\w-]*\( (.*) \)/',1); |
||
0 ignored issues
–
show
Equals sign not aligned correctly; expected 1 space but found 0 spaces
This check looks for improperly formatted assignments. Every assignment must have exactly one space before and one space after the equals operator. To illustrate: $a = "a";
$ab = "ab";
$abc = "abc";
will have no issues, while $a = "a";
$ab = "ab";
$abc = "abc";
will report issues in lines 1 and 2. ![]() |
|||
64 | |||
65 | $this->structureName=$this->config['name']??$name; |
||
0 ignored issues
–
show
Equals sign not aligned correctly; expected 1 space but found 0 spaces
This check looks for improperly formatted assignments. Every assignment must have exactly one space before and one space after the equals operator. To illustrate: $a = "a";
$ab = "ab";
$abc = "abc";
will have no issues, while $a = "a";
$ab = "ab";
$abc = "abc";
will report issues in lines 1 and 2. ![]() |
|||
66 | |||
67 | $this->id=strtoupper(uniqid()); |
||
0 ignored issues
–
show
Equals sign not aligned correctly; expected 1 space but found 0 spaces
This check looks for improperly formatted assignments. Every assignment must have exactly one space before and one space after the equals operator. To illustrate: $a = "a";
$ab = "ab";
$abc = "abc";
will have no issues, while $a = "a";
$ab = "ab";
$abc = "abc";
will report issues in lines 1 and 2. ![]() |
|||
68 | |||
69 | return $this; |
||
70 | } |
||
71 | |||
72 | /** |
||
73 | * Opening this control node, and returning node opener. |
||
74 | * |
||
75 | * @access public |
||
76 | * |
||
77 | * @return string |
||
78 | */ |
||
79 | public function open():string |
||
80 | { |
||
81 | return $this->withParam($this->config['opener']); |
||
82 | } |
||
83 | |||
84 | /** |
||
85 | * Getting whether this node contains a scope and scope name. |
||
86 | * |
||
87 | * @access public |
||
88 | * |
||
89 | * @return string | null |
||
90 | */ |
||
91 | public function getScope() |
||
92 | { |
||
93 | return $this->config['scope']??null; |
||
94 | } |
||
95 | |||
96 | |||
97 | /** |
||
98 | * Close this control node, and returning node closer. |
||
99 | * |
||
100 | * @access public |
||
101 | * |
||
102 | * @param \Htsl\ReadingBuffer\Line $closerLine The line when node closed. |
||
103 | * |
||
104 | * @return string |
||
105 | */ |
||
106 | public function close( Line$closerLine ):string |
||
107 | { |
||
108 | if( isset($this->config['close_by']) && $closerLine->indentLevel==$this->line->indentLevel ){ |
||
109 | foreach( $this->config['close_by'] as $key=>$value ){ |
||
110 | if( $closerLine->pregMatch($key) ){ |
||
111 | return $this->withParam($value); |
||
112 | } |
||
113 | } |
||
114 | } |
||
115 | |||
116 | if( isset($this->config['closer']) ) |
||
117 | { return $this->withParam($this->config['closer']); } |
||
118 | |||
119 | return ''; |
||
120 | } |
||
121 | |||
122 | /** |
||
123 | * Parse opener or closer with parameters. |
||
124 | * |
||
125 | * @access private |
||
126 | * |
||
127 | * @param string $input Opener or Closer |
||
128 | * |
||
129 | * @return string |
||
130 | */ |
||
131 | private function withParam( string$input ) |
||
132 | { |
||
133 | return str_replace('$_FLAG_$',"__HTSL_CTRL_FLAG_{$this->id}__",preg_replace_callback('/(?<!%)%s((?:\\/.+?(?<!\\\\)\\/.+?(?<!\\\\)\\/)+)?/',function( array$matches ){ |
||
0 ignored issues
–
show
As per coding-style, please use concatenation or
sprintf for the variable $this instead of interpolation.
It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings. // Instead of
$x = "foo $bar $baz";
// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
![]() |
|||
134 | $param= $this->param; |
||
0 ignored issues
–
show
Equals sign not aligned correctly; expected 1 space but found 0 spaces
This check looks for improperly formatted assignments. Every assignment must have exactly one space before and one space after the equals operator. To illustrate: $a = "a";
$ab = "ab";
$abc = "abc";
will have no issues, while $a = "a";
$ab = "ab";
$abc = "abc";
will report issues in lines 1 and 2. ![]() |
|||
135 | |||
136 | if( isset($matches[1]) ){ |
||
137 | array_map(...[ |
||
138 | function($replacer)use(&$param){ |
||
139 | list($pattern,$replacement,)= preg_split('/(?<!\\\\)\\//',$replacer); |
||
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 1 space but found 0 spaces
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line. To visualize $a = "a";
$ab = "ab";
$abc = "abc";
will produce issues in the first and second line, while this second example $a = "a";
$ab = "ab";
$abc = "abc";
will produce no issues. ![]() |
|||
140 | $param= preg_replace(...[ |
||
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 23 spaces but found 0 spaces
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line. To visualize $a = "a";
$ab = "ab";
$abc = "abc";
will produce issues in the first and second line, while this second example $a = "a";
$ab = "ab";
$abc = "abc";
will produce no issues. ![]() |
|||
141 | "/$pattern/", |
||
0 ignored issues
–
show
As per coding-style, please use concatenation or
sprintf for the variable $pattern instead of interpolation.
It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings. // Instead of
$x = "foo $bar $baz";
// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
![]() |
|||
142 | preg_replace('/^\\\\_$/','',$replacement), |
||
143 | $param, |
||
144 | ]); |
||
145 | }, |
||
146 | preg_split( |
||
147 | '/(?<!\\\\)\\/\\//' |
||
148 | , |
||
149 | trim($matches[1],'/') |
||
150 | ), |
||
151 | ]); |
||
152 | } |
||
153 | return $param; |
||
154 | },$input)); |
||
155 | } |
||
156 | } |
||
0 ignored issues
–
show
|
|||
157 |
This check looks for the generic type
array
as a return type and suggests a more specific type. This type is inferred from the actual code.