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

Alert on wrong version #121

Closed
Mte90 opened this issue Aug 14, 2014 · 22 comments
Closed

Alert on wrong version #121

Mte90 opened this issue Aug 14, 2014 · 22 comments
Assignees
Milestone

Comments

@Mte90
Copy link

Mte90 commented Aug 14, 2014

I develop plugins for wordpress but the minimum requirement is PHP 5.2.4.
I check weekly the minimum version but is possible get an alert that report the wrong line for the minimum requirement?
Now i scan manually in search of anonymous function and other things.

@llaville
Copy link
Owner

Each analyser will details you each element (class, interface, function, constant ) and theirs versions (PHP min/max). Of course it cannot tell you exactly where these elements are located/used but it's an helper to find in your source code.

Did I answered to your question ?

@Mte90
Copy link
Author

Mte90 commented Aug 14, 2014

Maybe a settings for the minimum version and an alert with the lines with the problematic code will be very useful.

Uhm myabe i use the wrong command? phpcompatinfo analyser:run . that print a list with number of element (class, interface, function, constant)

@llaville
Copy link
Owner

Hum, I think I should improve again the documentation !

Did you see that there are other analysers available ? phpcompatinfo analyser:list

So try it when you run your parse, E.g : phpcompatinfo analyser:run . function or combined with each other phpcompatinfo analyser:run . function constant class , and so on ...

When you don't specify analyser, its the summary what used.

@Mte90
Copy link
Author

Mte90 commented Aug 14, 2014

mte90@siduction:/var/www/mte.dev/wp-content/plugins/WordPress-Plugin-Boilerplate-Powered/plugin-name$ phpcompatinfo analyser:list
 Analyser Name Analyser Class                                 
 Class         Bartlett\CompatInfo\Analyser\ClassAnalyser     
 Constant      Bartlett\CompatInfo\Analyser\ConstantAnalyser  
 Extension     Bartlett\CompatInfo\Analyser\ExtensionAnalyser 
 Function      Bartlett\CompatInfo\Analyser\FunctionAnalyser  
 Interface     Bartlett\CompatInfo\Analyser\InterfaceAnalyser 
 Namespace     Bartlett\CompatInfo\Analyser\NamespaceAnalyser 
 Structure     Bartlett\Reflect\Analyser\StructureAnalyser    
 Summary       Bartlett\CompatInfo\Analyser\SummaryAnalyser   
 Trait         Bartlett\CompatInfo\Analyser\TraitAnalyser

WOW phpcompatinfo analyser:run . function constant class report every class or function, very useful.

But a paramenter like -min 5.2.4 that report if there is something that require a different bigger version? Actually the only way is read all the list, a reporting solution simplify the check.
In this way is possible create a grunt module or a bash script for example.

@llaville
Copy link
Owner

Could you provide an example (url if code is public) about such situation

@Mte90
Copy link
Author

Mte90 commented Aug 16, 2014

@llaville
Copy link
Owner

Hello @Mte90

I've took time to think about a solution that will change less and use the filter feature that is already available with all analysers.
I think I found a good solution, but I want your feedback.

I've reused the summary analyser that provide actually less (and probaly useless) informations.
It's new default behavior when you run something like phpcompatinfo analyser:run . or phpcompatinfo analyser:run . summary will render such ouput :

Data Source Analysed

Directories                                          7
Files                                              124

Global Analysis

                    Count PHP min Elements highlight
 Extensions         11    5.3.7   intl ...
 Namespaces         8     5.3.7   Bartlett\CompatInfo\Reference ...
 Interfaces         3     5.3.0   Bartlett\CompatInfo\Reference\ReferenceInterface ...
 Traits             0              
 Classes            134   5.3.0   Bartlett\CompatInfo\Reference\Extension\RecodeExtension ...
 User Functions     5     5.3.0   Bartlett\CompatInfo\Reference\closure-288-322 ...
 Internal Functions 49    5.2.0   json_decode ...
 Constants          11    5.3.7   INTL_ICU_VERSION ...
 Total                    5.3.7

And if you want to see elements that are greater a PHP limit, you have to use the filter (--php option) feature like this : phpcompatinfo analyser:run . --php=">= 5.3" that will alert you if components greater or equal than PHP 5.3.0 are used (for example).

 Data Source Analysed

Directories                                          7
Files                                              124

Global Analysis

 Extension    REF EXT min/Max PHP min/Max
 Core             5.3.0       5.3.0
 intl             2.0.0b1     5.3.7
 Total [2/11]                 5.3.7

and more output ...

@Mte90
Copy link
Author

Mte90 commented Aug 21, 2014

Uhm this solution is very better.
The detection for fix the problem with this --php filter becomes much easier.
I can imagine that a command like phpcompatinfo analyser:run . summary --php=">= 5.3" create a mix about this two report correct?

@llaville
Copy link
Owner

FYI, I run the new summary analyser version on your source code, with command phpcompatinfo analyser:run . I got such output

Data Source Analysed

Directories                                         17
Files                                               29

Global Analysis

                    Count PHP min Elements highlight
 Extensions         4     5.2.0   json
 Namespaces         1     5.2.0   +global
 Interfaces         0
 Traits             0
 Classes            12    5.0.0   WordPress_Requirement
 User Functions     5     4.0.0   pn_get_template_part
 Internal Functions 36    5.2.0   json_decode
 Constants          13    4.0.0   FALSE
 Total                    5.2.0

And if I filter (for example on PHP 5.0 or greater), with this command phpcompatinfo analyser:run . --php=">= 5.0" I got this output

Data Source Analysed

Directories                                         17
Files                                               29

Global Analysis

 Extension   REF EXT min/Max PHP min/Max
 json            5.2.0       5.2.0
 Total [1/4]                 5.2.0

 Namespace   REF EXT min/Max PHP min/Max
 +global                     5.2.0
 Total [1/1]                 5.2.0

 Interface   REF EXT min/Max PHP min/Max
 Total [0/0]                 5.2.0

 Class                     REF EXT min/Max PHP min/Max
 Fake_Page                                 5.0.0
 PHP_Extension_Requirement                 5.0.0
 PHP_Requirement                           5.0.0
 Plugin_Name                               5.0.0
 Plugin_Name_Admin                         5.0.0
 Plugin_Requirement                        5.0.0
 Plugin_Requirements                       5.0.0
 Pn_Debug                                  5.0.0
 Requirement_Error                         5.0.0
 WordPress_Requirement                     5.0.0
 Total [10/12]                             5.2.0

 Function     REF  EXT min/Max PHP min/Max
 json_decode  json 5.2.0       5.2.0
 json_encode  json 5.2.0       5.2.0
 Total [2/41]                  5.2.0

 Constant     REF EXT min/Max PHP min/Max
 Total [0/13]                 5.2.0

@Mte90
Copy link
Author

Mte90 commented Aug 21, 2014

WOW!!
now is perfect :-D

@llaville
Copy link
Owner

Almost : I have to fix dupplicated lines but I'll include it in final 3.3 version now you're agree

@llaville llaville added this to the 3.3.0 milestone Aug 21, 2014
@llaville llaville self-assigned this Aug 21, 2014
@Mte90
Copy link
Author

Mte90 commented Aug 21, 2014

👍

llaville added a commit that referenced this issue Aug 21, 2014
@llaville
Copy link
Owner

Done

@Mte90
Copy link
Author

Mte90 commented Sep 24, 2015

The parameter --php not exist anymore in phpcompatinfo 4.x there is a way to check for the minimum version?

@llaville
Copy link
Owner

@Mte90
Copy link
Author

Mte90 commented Sep 25, 2015

Well the command was very useful and fast respect a custom filters.
Maybe create a plugin is better with the configuration in phpcompatinfo.json.

@llaville
Copy link
Owner

Command was very limited, and filter with closure allow to customize all (or almost) data to return / render.

@Mte90
Copy link
Author

Mte90 commented Nov 18, 2015

an example for create a check by parameters?

@llaville
Copy link
Owner

I am not sure to have well understood your needs. Coul you explains more please ?

@Mte90
Copy link
Author

Mte90 commented Nov 19, 2015

like in the old version, with a parameter choose the minimum php version to scan

@llaville
Copy link
Owner

The filter feature available in version 4.x offer much more possibily that --php option on analyser:run in version 3.x
While in version 3 you could only filter results on PHP versions, v4 allow you to filter all parts of result report. This is the main reason that there is no equivalent with --php option.

Please use, --filter option in command line as explained in doc (already referencedin this thread)

@Mte90
Copy link
Author

Mte90 commented Nov 20, 2015

Thank you!
I have updated the instructions https://github.com/Mte90/WordPress-Plugin-Boilerplate-Powered/wiki/How-use-the-Scripts-and-CLI-tools and added a file in my project.

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

No branches or pull requests

2 participants