Home > PHP > PHP Version Not Specified Warning In CodeSniffer

PHP Version Not Specified Warning In CodeSniffer

October 13th, 2008 Leave a comment Go to comments

In my last post I talked about the PHP CodeSniffer, so today I thought I would solve a common problem that doesn’t seem to have any documentation. Whilst correcting a class file I had there was this one warning that just wouldn’t go away.

FILE: myclass.php
--------------------------------------------------------------------------------
FOUND 0 ERROR(S) AND 1 WARNING(S) AFFECTING 1 LINE(S)
--------------------------------------------------------------------------------
11 | WARNING | PHP version not specified
--------------------------------------------------------------------------------

There is no documentation (that I could find) on the CodeSniffer site about how to solve this, so I dove into the source files for the CodeSniffer extension and found this line.

* PHP Version 5

Add this to the file docs at the top of your file. You can change the version to be more specific if you wish, so if your class required at least PHP version 5.0.1 then use this as the version. I hope this little snippet helps someone.

  1. Xedecimal
    January 28th, 2009 at 04:14 | #1

    This helped me, that’s for dang sure!

  2. anonymous
    September 2nd, 2009 at 19:35 | #2

    I try this and didn’t work.

    Use PHP version 5 instead of PHP Version 5 (lowecase v)

    Example:

    /**
    * MyClass
    *
    * PHP version 5
    *
    * …
    */

  1. October 14th, 2008 at 08:41 | #1