1 | #!/usr/bin/env php |
||||
2 | <?php |
||||
3 | |||||
4 | function findPolyfill(string $directory): int |
||||
5 | { |
||||
6 | // See issue #4215 - code which should have erred in unit test |
||||
7 | // succeeded because a dev package required polyfills. |
||||
8 | $retCode = 0; |
||||
9 | $polyfill81 = 'MYSQLI_REFRESH_REPLICA\\b' |
||||
10 | . '|fdiv[(]' |
||||
11 | . '|array_is_list[(]' |
||||
12 | . '|enum_exists[(]'; |
||||
13 | $polyfill = '/\\b(?:' |
||||
14 | . $polyfill81 |
||||
15 | . '})/'; |
||||
16 | |||||
17 | $it = new RecursiveIteratorIterator( |
||||
18 | new RecursiveDirectoryIterator($directory, FilesystemIterator::UNIX_PATHS) |
||||
19 | ); |
||||
20 | |||||
21 | foreach ($it as $file) { |
||||
22 | if ($file->getExtension() === 'php') { |
||||
23 | $fullname = $it->getPath() . '/' . $it->getBaseName(); |
||||
2 ignored issues
–
show
The method
getBaseName() does not exist on RecursiveIteratorIterator .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. ![]() |
|||||
24 | $contents = file_get_contents($fullname); |
||||
25 | if ($contents === false) { |
||||
26 | echo "failed to read $fullname\n"; |
||||
27 | ++$retCode; |
||||
28 | } elseif (preg_match_all($polyfill, $contents, $matches)) { |
||||
29 | var_dump($fullname, $matches); |
||||
1 ignored issue
–
show
|
|||||
30 | ++$retCode; |
||||
31 | } |
||||
32 | } |
||||
33 | } |
||||
34 | |||||
35 | return $retCode; |
||||
36 | } |
||||
37 | |||||
38 | // Don't care if tests use polyfill |
||||
39 | $errors = findPolyfill(__DIR__ . '/../src') + findPolyfill(__DIR__ . '/../samples'); |
||||
40 | if ($errors !== 0) { |
||||
41 | echo "Found $errors files that might require polyfills\n"; |
||||
42 | exit(1); |
||||
43 | } |
||||
44 | echo "No polyfills needed\n"; |
||||
45 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.