Skip to content

Commit efaa267

Browse files
committed
[+]: "PhpCodeParser" -> use the autoloader
1 parent b9441a4 commit efaa267

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# Changelog
22

3-
### master
3+
### 0.12.0 (2020-07-05)
44

55
- "PhpCodeParser" -> fix cache key
6+
- "PhpCodeChecker" -> fix the autoloader parameter
67

78
### 0.11.0 (2020-06-18)
89

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ $phpCodeErrors = \voku\SimplePhpParser\Parsers\PhpCodeChecker::checkFromString($
9090
var_dump($phpCodeErrors); // ['missing property type for voku\tests\SimpleClass->$foo']
9191
```
9292

93+
### "phar" build
94+
95+
```php ~/Downloads/box.phar compile --debug```
96+
9397
### Support
9498

9599
For support and donations please visit [Github](https://github.com/voku/simple_html_dom/) | [Issues](https://github.com/voku/simple_html_dom/issues) | [PayPal](https://paypal.me/moelleken) | [Patreon](https://www.patreon.com/voku).

src/voku/SimplePhpParser/Parsers/PhpCodeParser.php

+15
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,20 @@ public static function getPhpFiles(
5454
array $autoloaderProjectPaths = [],
5555
array $pathExcludeRegex = []
5656
): ParserContainer {
57+
foreach ($autoloaderProjectPaths as $projectPath) {
58+
if (\file_exists($projectPath . '/vendor/autoload.php')) {
59+
/** @noinspection PhpIncludeInspection */
60+
require_once $projectPath . '/vendor/autoload.php';
61+
} elseif (\file_exists($projectPath . '/../vendor/autoload.php')) {
62+
/** @noinspection PhpIncludeInspection */
63+
require_once $projectPath . '/../vendor/autoload.php';
64+
} elseif (\file_exists($projectPath) && \is_file($projectPath)) {
65+
/** @noinspection PhpIncludeInspection */
66+
require_once $projectPath;
67+
}
68+
}
69+
restore_error_handler();
70+
5771
$phpCodes = self::getCode(
5872
$pathOrCode,
5973
$pathExcludeRegex
@@ -183,6 +197,7 @@ public static function process(
183197
require_once $projectPath;
184198
}
185199
}
200+
restore_error_handler();
186201

187202
new \voku\SimplePhpParser\Parsers\Helper\Psalm\FakeFileProvider();
188203
$providers = new \Psalm\Internal\Provider\Providers(

0 commit comments

Comments
 (0)