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

DateInterval marked as PHP 5.6? #223

Closed mikerockett closed 8 years ago

mikerockett commented 8 years ago

I'm busy trying to ensure that a CMS module I'm writing is compatible with PHP 5.4. When validating nesbot/Carbon, specifically CarbonInterval, php-compat-info reports a minimum version of PHP 5.6 for DateInterval, which actually has a minimum version of 5.3.

Classes Analysis

    Class                                     Matches REF  EXT min/Max PHP min/Max PHP all
    Carbon\CarbonInterval                             user             5.6.0
    DateInterval                              4       date             5.6.0
llaville commented 8 years ago

Just back from hollidays. I'll have a look tomorrow !

llaville commented 8 years ago

Just downloaded https://github.com/briannesbitt/Carbon/releases/tag/1.21.0 and scanned src directory.

With PHP 5.6 (on windows) with CompatInfo clone branch master

phpCompatInfo version 5.0-dev DB built Jul 23 2016 18:13:46 CEST

I cannot reproduce this issue

My class Analysis report gave me

Classes Analysis

    Class                                             Matches REF  EXT min/Max PHP min/Max PHP all
    Carbon\Carbon                                     34      user             5.3.0
    Carbon\CarbonInterval                             3       user             5.6.0
    Closure                                           3       Core 5.3.0       5.3.0
    DateInterval                                      4       date 5.3.0       5.3.0
    DatePeriod                                        1       date 5.3.0       5.3.0
    DateTime                                          3       date 5.2.0       5.2.0
    DateTimeZone                                      1       date 5.2.0       5.2.0
    InvalidArgumentException                          6       spl  5.1.0       5.1.0
  U Symfony\Component\Translation\Loader\ArrayLoader  2       user             5.3.0
  U Symfony\Component\Translation\Translator          2       user             5.3.0
  U Symfony\Component\Translation\TranslatorInterface 2       user             5.3.0
    parent                                            6       Core 5.0.0       5.0.0
    static                                            69      Core 5.0.0       5.0.0
    Total [13]                                                                 5.6.0

Can you tell me what version of CompatInfo distribution you used please ?

Platform (Windows / Linux), PHP version, compat info (phar or not) version : use command phpcompatinfo --version

mikerockett commented 8 years ago

Hmm, I've just re-downloaded compat info, and I'm getting the same results as you're getting... I landed up going a different road (PHPCS), and so I deleted the phar that was used. Now, running 5.0.0 and Carbon ~1.0 (I assume that means latest on 1.x branch?), I get the following:

compatinfo.phar analyser:run ./vendor/nesbot

...

Namespaces Analysis

    Namespace Matches REF  EXT min/Max PHP min/Max PHP all
    +global           Core             4.0.0
    Carbon            user             5.3.0
    Total [2]                          5.3.0

...

Classes Analysis

    Class                                             Matches REF  EXT min/Max PHP min/Max PHP all
    Carbon\Carbon                                     34      user             5.3.0
    Carbon\CarbonInterval                             3       user             5.3.0
    Closure                                           3       Core 5.3.0       5.3.0
    DateInterval                                      4       date 5.3.0       5.3.0
    DatePeriod                                        1       date 5.3.0       5.3.0
    DateTime                                          3       date 5.2.0       5.2.0       5.3.0
    DateTimeZone                                      1       date 5.2.0       5.2.0
    InvalidArgumentException                          6       spl  5.1.0       5.1.0
  U Symfony\Component\Translation\Loader\ArrayLoader  2       user             5.3.0
  U Symfony\Component\Translation\Translator          2       user             5.3.0
  U Symfony\Component\Translation\TranslatorInterface 2       user             5.3.0
    parent                                            6       Core 5.0.0       5.0.0
    static                                            69      Core 5.0.0       5.0.0
    Total [13]                                                                 5.3.0

Actually, it appears to be a little different to yours as my CarbonInterval says 5.3, and yours says 5.6. I used PHP 7.0.9 for the scan.

llaville commented 8 years ago

Fixed with issue #222 because Carbon 1.21.0 have unary minus class constant. See https://github.com/briannesbitt/Carbon/blob/master/src/Carbon/CarbonInterval.php#L91

llaville commented 8 years ago

Code is already available on branch 5.0 of CompatInfo