Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conditionally used class is reported as required #159

Closed
cmb69 opened this issue Jan 10, 2015 · 4 comments
Closed

Conditionally used class is reported as required #159

cmb69 opened this issue Jan 10, 2015 · 4 comments
Assignees
Labels
Milestone

Comments

@cmb69
Copy link
Contributor

cmb69 commented Jan 10, 2015

There seems to be a regression in 3.7.2 (works fine with 3.7.1), where conditionally used classes are reported as being required.

Test script:

<?php

mb_strtolower($text);

if (method_exists('Normalizer', 'normalize')) {
    $text = Normalizer::normalize($text);
}

Output:

Data Source Analysed

Directories                                          1
Files                                                1

Global Analysis

                    Count Cond PHP min Elements highlight
 Extensions         3     1    4.3.0   mbstring
 Namespaces         1     0    4.3.0   +global
 Interfaces         0     0
 Traits             0     0
 Classes            1     0    5.2.0   Normalizer
 User Functions     0     0
 Internal Functions 3     1    4.3.0   mb_strtolower
 Constants          0     0
 Total                         4.3.0

Note that without the mb_strtolower() the results are okay, but it doesn't seem to matter which function is used. Further note, that the Totals do not include the Classes' requirement, but that might be related to #158.

@llaville
Copy link
Owner

As I've declared in #155 (comment), the conditional code is a big challenge that is not possible to solve without breaking other features in current API 3.7

This is the reason, why I won't resolved this issue in branch 3, but only with new API 4.0

@llaville llaville added this to the 4.0.0 milestone Jan 13, 2015
@llaville llaville self-assigned this Jan 13, 2015
@llaville llaville added the bug label Jan 13, 2015
This was referenced Jan 14, 2015
@llaville
Copy link
Owner

@cmb69 method_exists was partially implement in 3.7.1 and gave wrong results.

Try analyser:run command with --php option to see something like

   Function      REF      EXT min/Max PHP min/Max
 C Normalizer    intl     1.0.0beta   5.2.0
   mb_strtolower mbstring 4.3.0       4.3.0
   method_exists Core     4.0.0       4.0.0
   Total [3/3]                        4.3.0

   Condition                 REF  EXT min/Max PHP min/Max
   method_exists(Normalizer) intl 1.0.0beta   5.2.0
   Total [1/1]                                5.2.0

While API 4 now solved the situtation. Compares with

Functions Analysis

   Function      Matches REF      EXT min/Max PHP min/Max
   mb_strtolower 1       mbstring 4.3.0       4.3.0
   method_exists 1       Core     4.0.0       4.0.0
   Total [2]                                  4.3.0

No constant found

Conditions Analysis

   Condition                            Matches REF  EXT min/Max PHP min/Max
   method_exists(Normalizer::normalize) 1       user             4.0.0
   Total [1]                                                     4.0.0

Requires PHP 4.3.0 (min)

Of course, all is not yet perfect. But it'll be when I'll published the latest alpha version (4.0) tomorrow

@llaville
Copy link
Owner

Results is better now

Classes Analysis

   Class      Matches REF  EXT min/Max PHP min/Max
 C Normalizer         intl 1.0.0beta   5.3.0alpha1
   Total [1]                           4.0.0

Functions Analysis

   Function      Matches REF      EXT min/Max PHP min/Max
   mb_strtolower 1       mbstring 4.3.0       4.3.0
   method_exists 1       Core     4.0.0       4.0.0
   Total [2]                                  4.3.0

No constant found

Conditions Analysis

   Condition                            Matches REF  EXT min/Max PHP min/Max
   method_exists(Normalizer::normalize) 1       intl 1.0.0beta   5.3.0alpha1
   Total [1]                                                     5.3.0alpha1

Requires PHP 4.3.0 (min)

But I need to fix the match counter of Normalizer class. Reason is compatibility analyser does not catch yet Node\Expr\StaticCall.

Fix will follow ...

@llaville
Copy link
Owner

That's concluded bug fixe for API 4.0 only. No backport will be provided in API 3.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants