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
373 stars 20 forks source link

PHP 7 requirement not detected for return type hint #233

Closed CybotTM closed 4 years ago

CybotTM commented 7 years ago

PHP CompatInfo does not detect PHP 7 minimum requirement for return type hint.

With following source code file:

<?php

function fooBar(integer $i) : string
{
    return (string) $i;
}

i would expect PHP CompatInfo returns PHP 7 as minimum, but it does report PHP 5.0.0 as minimum:

$ phpcompatinfo analyser:run php7.php

Data Source Analysed

Directories                                          1
Files                                                1

Extensions Analysis

    Extension Matches REF  EXT min/Max PHP min/Max PHP all
    Core              Core             4.0.0
    Total [1]                          4.0.0

Namespaces Analysis

    Namespace Matches REF  EXT min/Max PHP min/Max PHP all
    +global           Core             5.0.0
    Total [1]                          5.0.0

No interface found

No trait found

Classes Analysis

    Class     Matches REF  EXT min/Max PHP min/Max PHP all
  U integer   1       user             4.0.0
    Total [1]                          4.0.0

Functions Analysis

    Function  Matches REF  EXT min/Max PHP min/Max
    fooBar            user             5.0.0
    Total [1]                          5.0.0

No constant found

No condition found

Requires PHP 5.0.0 (min), PHP 5.0.0 (all)
llaville commented 7 years ago

Hello Thanks for reporting this issue. BTW, be aware that I've beginning to write a new Major version 6.0 that will be independant of php-reflect and will support PHP 7.0, 7.1, and future 7.2

Branch 5.0 is features closed. I'll drop branch 5.1, that was an attempt to include a new architecture based on sniffs. Branch 6.0 will be soon available with an alpha version and a rewrites of monolithic CompatibilityAnalyser.

I'll keep you in touch ASAP.

MatthiasKuehneEllerhold commented 6 years ago

Just for completeness: Detection of nullable types are also missing (as an indicator for 7.1), but I'm sure you had that on your radar already. :)

llaville commented 4 years ago

Removes MS 6.0 because it will be included for upcoming release 5.4 (that is a compromise before full rewrites of v6), using the sniff architecture.

llaville commented 4 years ago

Sorry to be very so long to gave us a fix, but the world health situation give me a chance of free time ;-)

llaville commented 4 years ago

@MatthiasKuehneEllerhold I bit late to reply, but you're right it's effectivly on scope and issue #273 referenced it now !

It will be solved and with beta code of version 5.4 that will be available very soon now on repository.

Feedback of incoming v5.4 that will improve PHP 7 detection are of course welcome !