X Tutup
Skip to content

[PHPStan 1.11] list() with no first variable reports Undefined offset: 2 #11004

@phil-davis

Description

@phil-davis

Bug report

php -d zend.enable_gc=0 vendor-bin/phpstan/vendor/bin/phpstan analyse --memory-limit=2G --configuration=./phpstan.neon --level=0 apps core settings lib/private lib/public ocs ocs-provider
 1497/1497 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

 ------ ----------------------------- 
  Line   lib/private/Autoloader.php   
 ------ ----------------------------- 
  79     Notice: Undefined offset: 2  
  79     Notice: Undefined offset: 2  
  79     Notice: Undefined offset: 2  
  79     Notice: Undefined offset: 2  
  79     Notice: Undefined offset: 2  
  79     Notice: Undefined offset: 2  
 ------ ----------------------------- 

Line 79 is:

			list(, $app, $rest) = \explode('\\', $class, 3);

This is code that is included by the defined bootstrapFiles lib/base.php

Changing the line to:

			list($x, $app, $rest) = \explode('\\', $class, 3);

does not help. (I thought that maybe it did not cope with the first list variable not being used)

After getting this 6-error output, phpstan passes the 2nd time.

To get the error again, I have to phpstan clear-result-cache

So it is something in the bootstrap sequence, not just an ordinary code-parsing thing. I haven't been able to reproduce it at:
https://phpstan.org/r/66c742f6-387c-4106-9778-4727602eb0cb

So it seems that I need to dig deeper to know what is happening.

I anyone else has an idea, please make a comment.

Code snippet that reproduces the problem

No response

Expected output

No errors.

Did PHPStan help you today? Did it make you happy in any way?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      X Tutup