Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReflectionClass->getFileName() returns false for core/extnsion clasess which causes fatal error #1190

Open
dotdevio opened this issue Mar 18, 2021 · 11 comments
Labels

Comments

@dotdevio
Copy link

dotdevio commented Mar 18, 2021

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:

public function loadFromClass(string $classFQN): array

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()
        );
    }
@dotdevio dotdevio added the bug label Mar 18, 2021
@vsg24
Copy link

vsg24 commented Jul 2, 2021

this needs to be fixed asap

@mikloshumli
Copy link

Please fixed this bug. Thanx

@birkaaa
Copy link

birkaaa commented Dec 13, 2021

this needs to be fixed

@sanya6456
Copy link

Fix it please! Thx!

@ay4toh5i
Copy link

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.

#1186

@mfn
Copy link
Collaborator

mfn commented May 3, 2022

Previously this problem was skipped as below.

Isn't it anymore? Because the code is still there

$this->error('Exception: ' . $e->getMessage() . "\nSkipping $facade.");

@yogesh98
Copy link

yogesh98 commented Nov 3, 2022

This is also still happening for me.

@yogesh98
Copy link

This is still an issue for me.

@anderson-xd
Copy link

anderson-xd commented Apr 19, 2023

This is still an issue for me with Swoole after update the package version

@Arkanius
Copy link

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.

@mfn
Copy link
Collaborator

mfn commented Feb 16, 2024

The swoole related issue with fixed with #1477 and is in the latest release.

Don't know about the others, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

10 participants