php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #64184 Enhance the -l (Lint) command line option
Submitted: 2013-02-10 13:27 UTC Modified: 2013-02-12 00:01 UTC
From: andyearnshaw at gmail dot com Assigned:
Status: Wont fix Package: *General Issues
PHP Version: Irrelevant OS: Any
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2013-02-10 13:27 UTC] andyearnshaw at gmail dot com
Description:
------------
It would be great if the command line -l option could be enhanced to do more than 
just syntax checking.  It would be infinitely more useful if it could also output 
warnings for the following:

 - Use of deprecated functions
 - Correct number of function arguments
 - Other useful warnings (creating default object from empty value, etc)
 - Optionally, best practices

This would make it more akin to the JavaScript linters available, with the added 
benefit of always being relevant to the version of PHP installed.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-02-11 23:33 UTC] rasmus@php.net
-Status: Open +Status: Wont fix
 [2013-02-11 23:33 UTC] rasmus@php.net
That would require writing a static analyzer which is outside our scope at this 
point. Right now it simply runs the compile-phase and none of the things you are 
asking for can be done by the compiler. The executor can do some of this, but not 
without actually executing the script, which you don't want. The closest thing to 
a full static analyzer is Facebook's HipHop project if you run it in analyze-only 
mode.
 [2013-02-11 23:38 UTC] andyearnshaw at gmail dot com
That's a shame.  One of the annoying things about not keeping up with every 
single PHP release is that you don't know things are deprecated until you've 
spent time developing and then check the error logs during the testing phase.  
Then you have to either spend time rewriting the code or live with using 
deprecated functions for a while.
 [2013-02-11 23:41 UTC] rasmus@php.net
You could read the UPGRADING doc we provide with every new release.
 [2013-02-11 23:45 UTC] andyearnshaw at gmail dot com
I could, but then there's the problem of reading a backlog of upgrading documents 
when I don't religiously update PHP, and also the issue of remembering which 
functions are deprecated and which aren't at the time of programming without 
checking the docs :-)

However, I do understand that this is beyond the scope of the compiler and, 
therefore, the -l command line option.
 [2013-02-12 00:01 UTC] rasmus@php.net
It's not like there are a lot of them to read:

Mar 2012 PHP 5.4
Jun 2009 PHP 5.3
Nov 2006 PHP 5.2
Nov 2005 PHP 5.1
Jul 2004 PHP 5.0

So 5 of them in the past 9 years or so. We don't deprecate anything in the point 
releases between these.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 05 13:01:30 2024 UTC