php-integrator-symbol-viewer icon indicating copy to clipboard operation
php-integrator-symbol-viewer copied to clipboard

Not opening the correct file

Open Arcesilas opened this issue 8 years ago • 5 comments

Hi,

I use Laravel which uses a class pre-loader: the most used classes are "compiled" in a big PHP file and loaded once for all at startup.

When I toggle the panel on and click on a method or a property, it does not scroll to that one in the current file, it opens the compiled file.

Arcesilas avatar Feb 09 '16 23:02 Arcesilas

Just a small addition: it does not happen all the times... :/

Arcesilas avatar Feb 10 '16 00:02 Arcesilas

Hi Arcesilas, thanks for taking time to report the issue. :)

Personally speaking I don't have much experience with Laravel, but from what I know and remember there is much magic happening there, i.e. Facades in the service container, and I have to investigate a little. My guess is that simply some Laravel mechanisms are not supported by php-integrator-base and it would have to be fixed there.

If you'd like to help me out I would be very grateful for a sample scenario when this bug occurs in a blank Laravel project, i.e.

  1. create blank Laravel project
  2. go to class X
  3. click on property Y.

Cheers, tocjent

m-bobrowicz avatar Feb 10 '16 00:02 m-bobrowicz

Actually it's not really a Laravel problem. It does not concern Facades or anything magic.

If I have two files defining the same class with the same namespace, etc, it may open the other file whereas the method is actually defined in the current file.

Here is a simple scenario

  1. Create new Laravel Project: composer create-project laravel/laravel
  2. Run the optimizer in CLI: php artisan optimize
  3. Open any file of a class that has been optimized, for instance vendor/laravel/framework/Illuminate/Support/ServiceProvider.php
  4. Click on a method in the symbol viewer panel. It may open the compiled.php file (which is located at bootstrap/cache/compiled.php) rather jump to the method in the current file.

I wrote "may open", because, as I said, it stopped doing it. It still opens that file (compile.php) when clicking on a method defined in another file (then, i'd say it just opens the file I don't want, but it's not a bug : it has to open a file where the method is defined, it does it well, I'd just prefer it opens the "real" one... with an ignore option somewhere... ?).

So I can't reproduce the bug right now... :/ Could it be possible to have an ignore option, to list files not to index ? Is it relevant... ?

Arcesilas avatar Feb 10 '16 00:02 Arcesilas

As you can see in the screenshots below, I managed to reproduce the issue. The problem is in the second screen. As you may or may not noticed, my package is kind of simple - all the magic happens in php-integrator-base, which is responsible for parsing the PHP code for information, all I do is call service.getClassInfo(<<insertFullClassNameHere>>). The second screen is a sample output - there you can see that php-integrator service is fooled by the compiled.php file. As of now, php-integrator-base does not support ignoring files (or any per-project configuration, IIRC).

To summarize: as soon as those features are implemented in php-integrator-base, it'll work correctly. I'll leave the issue open as a reminder to check if the bug is fixed.

screenshot from 2016-02-10 01-59-01 screenshot from 2016-02-10 01-59-01 copy

m-bobrowicz avatar Feb 10 '16 01:02 m-bobrowicz

Well, I'm glad to see I'm not completely crazy (yet), not that old and that my eyes are still functionnal, even if not 100%.

Thanks!

Regards,

Arcesilas avatar Feb 10 '16 01:02 Arcesilas