llaville / php-compatinfo

Library that find out the minimum version and the extensions required for a piece of code to run
https://llaville.github.io/php-compatinfo/7.1/
Other
371 stars 21 forks source link

Missing extension when class name FQN is resolved under user namespace #275

Closed llaville closed 3 years ago

llaville commented 3 years ago

With issue #210 running on new version 5.4, I've noticed (and it's normal because it's PHP native behaviour), that class called with new constructor that are not properly defined with namespace import are detected under user namespace.

Here is a concrete example pick from vfsStream v1.6.0 => https://github.com/bovigo/vfsStream/blob/v1.6.0/src/test/php/org/bovigo/vfs/vfsStreamZipTestCase.php#L39 ZipArchive is resolved by nikic/php-parser NameResolver as org\bovigo\vfs\ZipArchive (and it's not a bug)

So in CompatInfo 5.4.0 I'll consider this situtation (conditional code only) as resolving extension with :

llaville commented 3 years ago

Run example with v5.4 when analysing this file https://github.com/bovigo/vfsStream/blob/v1.6.0/src/test/php/org/bovigo/vfs/vfsStreamZipTestCase.php

Data Source Analysed

Directories                                          1
Files                                                1
Errors                                               0

Extensions Analysis

    Extension REF      EXT min/Max PHP min/Max
    Core      Core     4.0.0       4.0.0
    standard  standard 4.0.0       4.0.0
    zip       zip      0.1.0       5.3.0
    Total [3]                      5.3.0

Namespaces Analysis

    Namespace      REF  EXT min/Max PHP min/Max
    org\bovigo\vfs user             5.3.0
    Total [1]                       5.3.0

No interface found

No trait found

Classes Analysis

    Class                               REF  EXT min/Max PHP min/Max
  U org\bovigo\vfs\ZipArchive           user             5.3.0
    org\bovigo\vfs\vfsStreamZipTestCase user             5.3.0
    Total [2]                                            5.3.0

No generator found

Functions Analysis

    Function         REF      EXT min/Max PHP min/Max
    extension_loaded Core     4.0.0       4.0.0
    file_exists      standard 4.0.0       4.0.0
    var_dump         standard 4.0.0       4.0.0
    Total [3]                             4.0.0

Constants Analysis

    Constant  REF  EXT min/Max PHP min/Max
    false     Core 4.0.0       4.0.0
    Total [1]                  4.0.0

Conditions Analysis

    Condition             REF EXT min/Max PHP min/Max
    extension_loaded(zip) zip 0.1.0       5.3.0
    Total [1]                             5.3.0

Requires PHP 5.3.0 (min)
llaville commented 3 years ago

Change with commits 83492c2 and c5254b0 allows to solve situation in such context https://github.com/sebastianbergmann/phpunit/blob/7.5.20/src/Util/Configuration.php#L549 And php.min was changed to 4.0.0 with commit 7ed2d57