laravel-ide-helper
laravel-ide-helper copied to clipboard
ReflectionClass->getFileName() returns false for core/extnsion clasess which causes fatal error
Versions:
- ide-helper Version: 2.9.1
- PHP Version: Tested on 8.0 but i think may relate to others as well.
Description:
This method: https://github.com/barryvdh/laravel-ide-helper/blob/244e936b740b18ab56180af2e1172436544764f2/src/UsesResolver.php#L26 fails when $classFQN will be php core/extension class as per php docs: https://www.php.net/manual/ru/reflectionclass.getfilename.php, for example this bug occurs when i install swoole/ide-helper.
php artisan ide-helper:generate
ValueError
Path cannot be empty
at vendor/barryvdh/laravel-ide-helper/src/UsesResolver.php:44
40| {
41| return $this->loadFromCode(
42| $classFQN,
43| file_get_contents(
> 44| $filename
45| )
46| );
47| }
48|
+20 vendor frames
21 artisan:36
Illuminate\Foundation\Console\Kernel::handle()
Steps To Reproduce:
for example u may install swoole/ide-helper.
Possible solution
/**
* @param string $classFQN
* @return array
*/
public function loadFromClass(string $classFQN): array
{
$ref = (new \ReflectionClass($classFQN));
if (false === $ref->getFileName()) {
return [];
}
return $this->loadFromFile(
$classFQN,
$ref->getFileName()
);
}
this needs to be fixed asap
Please fixed this bug. Thanx
this needs to be fixed
Fix it please! Thx!
I'm facing this problem too.
It is seems ReflectionClass->getFileName()
fails using this helper with swoole, because classes related swoole extention can not be resolved.
Previously this problem was skipped as below.
Exception: Target class [swoole.room] does not exist.
Skipping \SwooleTW\Http\Websocket\Facades\Room.
Exception: Target class [swoole.websocket] does not exist.
Skipping \SwooleTW\Http\Websocket\Facades\Websocket.
Exception: Target class [swoole.room] does not exist.
Skipping \SwooleTW\Http\Websocket\Facades\Room.
Exception: Target class [swoole.websocket] does not exist.
Skipping \SwooleTW\Http\Websocket\Facades\Websocket.
https://github.com/barryvdh/laravel-ide-helper/issues/1186
Previously this problem was skipped as below.
Isn't it anymore? Because the code is still there https://github.com/barryvdh/laravel-ide-helper/blob/c5e18beff1a2933913f86d56281581566e5c8705/src/Alias.php#L305
This is also still happening for me.
This is still an issue for me.
This is still an issue for me with Swoole after update the package version
I got this error as well. Since @dotdevpro suggested a fix, is there any way to merge it?
If there's any problem related to SwooleTW package I can help to address the solution btw.
The swoole related issue with fixed with https://github.com/barryvdh/laravel-ide-helper/pull/1477 and is in the latest release.
Don't know about the others, though.