@@ -27,14 +27,14 @@ discard block |
||
27 | 27 | $this->subject = $subject; |
28 | 28 | } |
29 | 29 | |
30 | - public function setRemoveDuplicates(bool $remove=true, bool $caseInsensitive=false) : self |
|
30 | + public function setRemoveDuplicates(bool $remove = true, bool $caseInsensitive = false) : self |
|
31 | 31 | { |
32 | 32 | $this->removeDuplicates = $remove; |
33 | 33 | $this->duplicatesCaseInsensitive = $caseInsensitive; |
34 | 34 | return $this; |
35 | 35 | } |
36 | 36 | |
37 | - public function setSorting(bool $sorting=true) : self |
|
37 | + public function setSorting(bool $sorting = true) : self |
|
38 | 38 | { |
39 | 39 | $this->sorting = $sorting; |
40 | 40 | return $this; |
@@ -52,11 +52,11 @@ discard block |
||
52 | 52 | |
53 | 53 | $words = $this->filterEmpty($words); |
54 | 54 | |
55 | - if($this->removeDuplicates) { |
|
55 | + if ($this->removeDuplicates) { |
|
56 | 56 | $words = $this->filterDuplicates($words); |
57 | 57 | } |
58 | 58 | |
59 | - if($this->sorting) { |
|
59 | + if ($this->sorting) { |
|
60 | 60 | usort($words, 'strnatcasecmp'); |
61 | 61 | } |
62 | 62 | |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | |
66 | 66 | private function filterDuplicates(array $words) : array |
67 | 67 | { |
68 | - if($this->duplicatesCaseInsensitive) { |
|
68 | + if ($this->duplicatesCaseInsensitive) { |
|
69 | 69 | return $this->filterDuplicatesCaseInsensitive($words); |
70 | 70 | } |
71 | 71 | |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | { |
77 | 77 | return array_intersect_key( |
78 | 78 | $array, |
79 | - array_unique( array_map( "strtolower", $array ) ) |
|
79 | + array_unique(array_map("strtolower", $array)) |
|
80 | 80 | ); |
81 | 81 | } |
82 | 82 | |
@@ -88,13 +88,13 @@ discard block |
||
88 | 88 | { |
89 | 89 | $keep = array(); |
90 | 90 | |
91 | - foreach($words as $word) |
|
91 | + foreach ($words as $word) |
|
92 | 92 | { |
93 | - if(empty($word)) { |
|
93 | + if (empty($word)) { |
|
94 | 94 | continue; |
95 | 95 | } |
96 | 96 | |
97 | - if(mb_strlen($word) < $this->minWordLength) { |
|
97 | + if (mb_strlen($word) < $this->minWordLength) { |
|
98 | 98 | continue; |
99 | 99 | } |
100 | 100 |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | public function setMinWords(int $min) : self |
123 | 123 | { |
124 | 124 | // Avoid a reset if the value is the same |
125 | - if($this->minWords === $min) |
|
125 | + if ($this->minWords === $min) |
|
126 | 126 | { |
127 | 127 | return $this; |
128 | 128 | } |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | |
143 | 143 | private function detect() : void |
144 | 144 | { |
145 | - if($this->detected) { |
|
145 | + if ($this->detected) { |
|
146 | 146 | return; |
147 | 147 | } |
148 | 148 | |
@@ -150,15 +150,15 @@ discard block |
||
150 | 150 | $this->found = array(); |
151 | 151 | $this->count = 0; |
152 | 152 | |
153 | - foreach(self::$words as $word) |
|
153 | + foreach (self::$words as $word) |
|
154 | 154 | { |
155 | - if(stripos($this->subject, $word) !== false) |
|
155 | + if (stripos($this->subject, $word) !== false) |
|
156 | 156 | { |
157 | 157 | $this->count++; |
158 | 158 | $this->found[] = $word; |
159 | 159 | } |
160 | 160 | |
161 | - if($this->count >= $this->minWords) { |
|
161 | + if ($this->count >= $this->minWords) { |
|
162 | 162 | break; |
163 | 163 | } |
164 | 164 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | /** |
34 | 34 | * @param array<string,string|number|NumberInfo|Interface_Stringable|NULL> $styles |
35 | 35 | */ |
36 | - public function __construct(array $styles=array()) |
|
36 | + public function __construct(array $styles = array()) |
|
37 | 37 | { |
38 | 38 | $this->options = new StyleOptions(); |
39 | 39 | |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * @param array<string,string|number|NumberInfo|Interface_Stringable|NULL> $styles |
45 | 45 | * @return StyleCollection |
46 | 46 | */ |
47 | - public static function create(array $styles=array()) : StyleCollection |
|
47 | + public static function create(array $styles = array()) : StyleCollection |
|
48 | 48 | { |
49 | 49 | return new StyleCollection($styles); |
50 | 50 | } |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | { |
69 | 69 | $lines = explode(';', $string); |
70 | 70 | |
71 | - foreach($lines as $line) |
|
71 | + foreach ($lines as $line) |
|
72 | 72 | { |
73 | 73 | $parts = explode(':', $line); |
74 | 74 | |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | */ |
90 | 90 | public function setStyles(array $styles) : StyleCollection |
91 | 91 | { |
92 | - foreach($styles as $name => $value) |
|
92 | + foreach ($styles as $name => $value) |
|
93 | 93 | { |
94 | 94 | $this->styleAuto($name, $value); |
95 | 95 | } |
@@ -105,14 +105,14 @@ discard block |
||
105 | 105 | * @param bool $important |
106 | 106 | * @return $this |
107 | 107 | */ |
108 | - public function style(string $name, string $value, bool $important=false) : StyleCollection |
|
108 | + public function style(string $name, string $value, bool $important = false) : StyleCollection |
|
109 | 109 | { |
110 | - if($value === '') |
|
110 | + if ($value === '') |
|
111 | 111 | { |
112 | 112 | return $this; |
113 | 113 | } |
114 | 114 | |
115 | - if($important && stripos($value, '!important') === false) |
|
115 | + if ($important && stripos($value, '!important') === false) |
|
116 | 116 | { |
117 | 117 | $value .= ' !important'; |
118 | 118 | } |
@@ -130,9 +130,9 @@ discard block |
||
130 | 130 | * @param bool $important |
131 | 131 | * @return $this |
132 | 132 | */ |
133 | - public function styleAuto(string $name, $value, bool $important=false) : StyleCollection |
|
133 | + public function styleAuto(string $name, $value, bool $important = false) : StyleCollection |
|
134 | 134 | { |
135 | - if($value instanceof NumberInfo) |
|
135 | + if ($value instanceof NumberInfo) |
|
136 | 136 | { |
137 | 137 | return $this->style($name, $value->toCSS(), $important); |
138 | 138 | } |
@@ -140,22 +140,22 @@ discard block |
||
140 | 140 | return $this->style($name, (string)$value, $important); |
141 | 141 | } |
142 | 142 | |
143 | - public function stylePX(string $name, int $px, bool $important=false) : StyleCollection |
|
143 | + public function stylePX(string $name, int $px, bool $important = false) : StyleCollection |
|
144 | 144 | { |
145 | 145 | return $this->style($name, $px.'px', $important); |
146 | 146 | } |
147 | 147 | |
148 | - public function stylePercent(string $name, float $percent, bool $important=false) : StyleCollection |
|
148 | + public function stylePercent(string $name, float $percent, bool $important = false) : StyleCollection |
|
149 | 149 | { |
150 | 150 | return $this->style($name, $percent.'%', $important); |
151 | 151 | } |
152 | 152 | |
153 | - public function styleEM(string $name, float $em, bool $important=false) : StyleCollection |
|
153 | + public function styleEM(string $name, float $em, bool $important = false) : StyleCollection |
|
154 | 154 | { |
155 | 155 | return $this->style($name, $em.'em', $important); |
156 | 156 | } |
157 | 157 | |
158 | - public function styleREM(string $name, float $em, bool $important=false) : StyleCollection |
|
158 | + public function styleREM(string $name, float $em, bool $important = false) : StyleCollection |
|
159 | 159 | { |
160 | 160 | return $this->style($name, $em.'rem', $important); |
161 | 161 | } |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | * @param bool $important |
170 | 170 | * @return $this |
171 | 171 | */ |
172 | - public function styleParseNumber(string $name, $value, bool $important=false) : StyleCollection |
|
172 | + public function styleParseNumber(string $name, $value, bool $important = false) : StyleCollection |
|
173 | 173 | { |
174 | 174 | return $this->styleNumber($name, parseNumber($value), $important); |
175 | 175 | } |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | * @param bool $important |
183 | 183 | * @return $this |
184 | 184 | */ |
185 | - public function styleNumber(string $name, NumberInfo $info, bool $important=false) : StyleCollection |
|
185 | + public function styleNumber(string $name, NumberInfo $info, bool $important = false) : StyleCollection |
|
186 | 186 | { |
187 | 187 | $this->style($name, $info->toCSS(), $important); |
188 | 188 | return $this; |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | |
191 | 191 | public function remove(string $name) : StyleCollection |
192 | 192 | { |
193 | - if(isset($this->styles[$name])) |
|
193 | + if (isset($this->styles[$name])) |
|
194 | 194 | { |
195 | 195 | unset($this->styles[$name]); |
196 | 196 | } |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | { |
227 | 227 | $all = self::create(); |
228 | 228 | |
229 | - foreach($collections as $collection) |
|
229 | + foreach ($collections as $collection) |
|
230 | 230 | { |
231 | 231 | $all->mergeWith($collection); |
232 | 232 | } |
@@ -22,7 +22,7 @@ |
||
22 | 22 | |
23 | 23 | public function __construct(string $class, ?int $code = null, ?Throwable $previous = null) |
24 | 24 | { |
25 | - if($code === null || $code === 0) { |
|
25 | + if ($code === null || $code === 0) { |
|
26 | 26 | $code = self::ERROR_CODE; |
27 | 27 | } |
28 | 28 |
@@ -48,11 +48,11 @@ discard block |
||
48 | 48 | self::TYPE_TRAIT |
49 | 49 | ); |
50 | 50 | |
51 | - /** |
|
52 | - * @param PHPFile $path The path to the PHP file to parse. |
|
53 | - * @throws FileHelper_Exception |
|
54 | - * @see FileHelper::findPHPClasses() |
|
55 | - */ |
|
51 | + /** |
|
52 | + * @param PHPFile $path The path to the PHP file to parse. |
|
53 | + * @throws FileHelper_Exception |
|
54 | + * @see FileHelper::findPHPClasses() |
|
55 | + */ |
|
56 | 56 | public function __construct(PHPFile $path) |
57 | 57 | { |
58 | 58 | $this->file = $path |
@@ -62,58 +62,58 @@ discard block |
||
62 | 62 | $this->parseFile(); |
63 | 63 | } |
64 | 64 | |
65 | - /** |
|
66 | - * The name of the namespace of the classes in the file, if any. |
|
67 | - * @return string |
|
68 | - */ |
|
65 | + /** |
|
66 | + * The name of the namespace of the classes in the file, if any. |
|
67 | + * @return string |
|
68 | + */ |
|
69 | 69 | public function getNamespace() : string |
70 | 70 | { |
71 | 71 | return $this->namespace; |
72 | 72 | } |
73 | 73 | |
74 | - /** |
|
75 | - * Whether the file contains a namespace. |
|
76 | - * @return bool |
|
77 | - */ |
|
74 | + /** |
|
75 | + * Whether the file contains a namespace. |
|
76 | + * @return bool |
|
77 | + */ |
|
78 | 78 | public function hasNamespace() : bool |
79 | 79 | { |
80 | 80 | return !empty($this->namespace); |
81 | 81 | } |
82 | 82 | |
83 | - /** |
|
84 | - * The absolute path to the file. |
|
85 | - * @return string |
|
86 | - */ |
|
83 | + /** |
|
84 | + * The absolute path to the file. |
|
85 | + * @return string |
|
86 | + */ |
|
87 | 87 | public function getPath() : string |
88 | 88 | { |
89 | 89 | return $this->file->getPath(); |
90 | 90 | } |
91 | 91 | |
92 | - /** |
|
93 | - * Whether any classes were found in the file. |
|
94 | - * @return bool |
|
95 | - */ |
|
92 | + /** |
|
93 | + * Whether any classes were found in the file. |
|
94 | + * @return bool |
|
95 | + */ |
|
96 | 96 | public function hasClasses() : bool |
97 | 97 | { |
98 | 98 | return !empty($this->classes); |
99 | 99 | } |
100 | 100 | |
101 | - /** |
|
102 | - * The names of the classes that were found in the file (with namespace if any). |
|
103 | - * @return string[] |
|
104 | - */ |
|
101 | + /** |
|
102 | + * The names of the classes that were found in the file (with namespace if any). |
|
103 | + * @return string[] |
|
104 | + */ |
|
105 | 105 | public function getClassNames() : array |
106 | 106 | { |
107 | 107 | return array_keys($this->classes); |
108 | 108 | } |
109 | 109 | |
110 | - /** |
|
111 | - * Retrieves all classes that were detected in the file, |
|
112 | - * which can be used to retrieve more information about |
|
113 | - * them. |
|
114 | - * |
|
115 | - * @return FileHelper_PHPClassInfo_Class[] |
|
116 | - */ |
|
110 | + /** |
|
111 | + * Retrieves all classes that were detected in the file, |
|
112 | + * which can be used to retrieve more information about |
|
113 | + * them. |
|
114 | + * |
|
115 | + * @return FileHelper_PHPClassInfo_Class[] |
|
116 | + */ |
|
117 | 117 | public function getClasses() : array |
118 | 118 | { |
119 | 119 | return array_values($this->classes); |
@@ -185,13 +185,13 @@ discard block |
||
185 | 185 | $this->classes[$class->getNameNS()] = $class; |
186 | 186 | } |
187 | 187 | |
188 | - /** |
|
189 | - * Strips all whitespace from the string, replacing it with |
|
190 | - * regular spaces (newlines, tabs, etc.). |
|
191 | - * |
|
192 | - * @param string $string |
|
193 | - * @return string |
|
194 | - */ |
|
188 | + /** |
|
189 | + * Strips all whitespace from the string, replacing it with |
|
190 | + * regular spaces (newlines, tabs, etc.). |
|
191 | + * |
|
192 | + * @param string $string |
|
193 | + * @return string |
|
194 | + */ |
|
195 | 195 | protected function stripWhitespace(string $string) : string |
196 | 196 | { |
197 | 197 | return preg_replace('/\s/', ' ', $string); |
@@ -126,13 +126,13 @@ discard block |
||
126 | 126 | $this->detectNamespace($code); |
127 | 127 | $result = $this->detectMatches($code); |
128 | 128 | |
129 | - if($result === null) { |
|
129 | + if ($result === null) { |
|
130 | 130 | return; |
131 | 131 | } |
132 | 132 | |
133 | 133 | $indexes = array_keys($result[0]); |
134 | 134 | |
135 | - foreach($indexes as $idx) |
|
135 | + foreach ($indexes as $idx) |
|
136 | 136 | { |
137 | 137 | $this->parseResult( |
138 | 138 | $result[1][$idx], |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | |
152 | 152 | preg_match_all('/(abstract|final)\s+('.$types.')\s+([\sa-z\d\\\\_,]+){|('.$types.')\s+([\sa-z\d\\\\_,]+){/ix', $code, $result, PREG_PATTERN_ORDER); |
153 | 153 | |
154 | - if(isset($result[0][0])) { |
|
154 | + if (isset($result[0][0])) { |
|
155 | 155 | return $result; |
156 | 156 | } |
157 | 157 | |
@@ -163,14 +163,14 @@ discard block |
||
163 | 163 | $result = array(); |
164 | 164 | preg_match_all('/namespace\s+([^;]+);/ix', $code, $result, PREG_PATTERN_ORDER); |
165 | 165 | |
166 | - if(isset($result[0][0])) { |
|
166 | + if (isset($result[0][0])) { |
|
167 | 167 | $this->namespace = trim($result[1][0]); |
168 | 168 | } |
169 | 169 | } |
170 | 170 | |
171 | 171 | private function parseResult(string $keyword, string $declaration, string $type, string $simpleType, string $simpleDeclaration) : void |
172 | 172 | { |
173 | - if(empty($keyword)) { |
|
173 | + if (empty($keyword)) { |
|
174 | 174 | $type = $simpleType; |
175 | 175 | $declaration = $simpleDeclaration; |
176 | 176 | } |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | * the vendor name, for example (Vendor\PackageName\Folder\Class). |
41 | 41 | * @return string|null The detected class name, or NULL otherwise. |
42 | 42 | */ |
43 | - public static function resolveClassName(string $legacyName, string $nsPrefix='') : ?string |
|
43 | + public static function resolveClassName(string $legacyName, string $nsPrefix = '') : ?string |
|
44 | 44 | { |
45 | 45 | $names = array( |
46 | 46 | str_replace('\\', '_', $legacyName), |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | $nsPrefix.'\\'.str_replace('_', '\\', $legacyName) |
49 | 49 | ); |
50 | 50 | |
51 | - foreach($names as $name) { |
|
51 | + foreach ($names as $name) { |
|
52 | 52 | if (class_exists($name)) { |
53 | 53 | return ltrim($name, '\\'); |
54 | 54 | } |
@@ -67,11 +67,11 @@ discard block |
||
67 | 67 | * @return string |
68 | 68 | * @throws ClassNotExistsException |
69 | 69 | */ |
70 | - public static function requireResolvedClass(string $legacyName, string $nsPrefix='') : string |
|
70 | + public static function requireResolvedClass(string $legacyName, string $nsPrefix = '') : string |
|
71 | 71 | { |
72 | 72 | $class = self::resolveClassName($legacyName, $nsPrefix); |
73 | 73 | |
74 | - if($class !== null) |
|
74 | + if ($class !== null) |
|
75 | 75 | { |
76 | 76 | return $class; |
77 | 77 | } |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | */ |
92 | 92 | public static function requireClassExists(string $className) : void |
93 | 93 | { |
94 | - if(class_exists($className)) |
|
94 | + if (class_exists($className)) |
|
95 | 95 | { |
96 | 96 | return; |
97 | 97 | } |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | self::requireClassExists($targetClass); |
117 | 117 | self::requireClassExists($extendsClass); |
118 | 118 | |
119 | - if(is_a($targetClass, $extendsClass, true)) |
|
119 | + if (is_a($targetClass, $extendsClass, true)) |
|
120 | 120 | { |
121 | 121 | return; |
122 | 122 | } |
@@ -142,19 +142,19 @@ discard block |
||
142 | 142 | * @throws ClassNotImplementsException |
143 | 143 | * @throws Throwable |
144 | 144 | */ |
145 | - public static function requireObjectInstanceOf(string $class, object $object, int $errorCode=0) |
|
145 | + public static function requireObjectInstanceOf(string $class, object $object, int $errorCode = 0) |
|
146 | 146 | { |
147 | - if($object instanceof Throwable) |
|
147 | + if ($object instanceof Throwable) |
|
148 | 148 | { |
149 | 149 | throw $object; |
150 | 150 | } |
151 | 151 | |
152 | - if(!class_exists($class) && !interface_exists($class) && !trait_exists($class)) |
|
152 | + if (!class_exists($class) && !interface_exists($class) && !trait_exists($class)) |
|
153 | 153 | { |
154 | 154 | throw new ClassNotExistsException($class, $errorCode); |
155 | 155 | } |
156 | 156 | |
157 | - if(is_a($object, $class, true)) |
|
157 | + if (is_a($object, $class, true)) |
|
158 | 158 | { |
159 | 159 | return $object; |
160 | 160 | } |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | */ |
176 | 176 | public static function getClassLoader() : ClassLoader |
177 | 177 | { |
178 | - if(isset(self::$classLoader)) { |
|
178 | + if (isset(self::$classLoader)) { |
|
179 | 179 | return self::$classLoader; |
180 | 180 | } |
181 | 181 | |
@@ -189,14 +189,14 @@ discard block |
||
189 | 189 | |
190 | 190 | $autoloadFile = null; |
191 | 191 | |
192 | - foreach($paths as $path) |
|
192 | + foreach ($paths as $path) |
|
193 | 193 | { |
194 | - if(file_exists($path)) { |
|
194 | + if (file_exists($path)) { |
|
195 | 195 | $autoloadFile = $path; |
196 | 196 | } |
197 | 197 | } |
198 | 198 | |
199 | - if($autoloadFile === null) { |
|
199 | + if ($autoloadFile === null) { |
|
200 | 200 | throw new ClassLoaderNotFoundException($paths); |
201 | 201 | } |
202 | 202 | |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | */ |
248 | 248 | private static function splitClass($subject) : array |
249 | 249 | { |
250 | - if(is_object($subject)) { |
|
250 | + if (is_object($subject)) { |
|
251 | 251 | $class = get_class($subject); |
252 | 252 | } else { |
253 | 253 | $class = $subject; |