What's new?
PHP 1.3.2
Bug Fixing
PHP 1.3.1
Quality Rule description changes
The following Quality Rules have had minor updates to their descriptions:
Avoid using regular expressions - 1007188 (was missing the "(PHP)" suffix)
Use Increment/decrement operators where possible - 1007028 (was missing the "(PHP)" suffix)
Avoid artifacts having recursive calls (PHP) - 1007242 ("Total" description is mentioned as "Number of methods" only but it should be "Number of methods and functions")
- Avoid direct definition of JavaScript Functions in a Web page (PHP) - 1007014 (the word "script" has been replaced with JavaScript)
- Avoid having Files without a naming convention (PHP) - 1007072 - minor update to the "Output" and "Total" fields in the description:
- Output: "This report lists all the files analysed that do not follow naming convention. The files considered for this QR are listed under heading "Source code requirements" in "Analysis Configuration" page. This QR provides the following information: File full name." - the list of file types referred to by this description is listed here.)
Bug Fixing
PHP 1.3.0
Log improvements for the PHP Preprocessor and PHP Code Sniffer
- Improvements have been introduced with regard to the log files that are produced during an analysis of PHP code with the extension. Specifically, the logs produced by the PHP Preprocessor and PHP Code Sniffer have been improved in this release of the extension. You can find out more information in PHP 1.3 - Analysis Configuration.
<unnamed> objects
- A fix has been implemented (see PHP 1.3 - Bug Fix List) to improve the resolution of PHP objects. Objects that were previously resolved as "<unamed>" (for example: phpMethod.<unnamed>) in the analysis results, should now be resolved. An exception is for PHP code that uses the heredoc syntax, which is currently unsupported.
Auto import of CAST Transaction Configuration Center (TCC) setup
- In previous releases of the extension, a TCCSetup file was shipped with the extension which could be manually imported into the CAST Transaction Configuration Center (TCC) to provide a pre-defined set of PHP Transaction Entry Points under "Free Definition". If you are using the PHP ≥ 1.3.x extension with CAST AIP ≥ 8.3.x, then this Entry Point configuration specifically for PHP is now automatically imported when the extension is installed. See PHP 1.3 - Download and installation for more information.
Bug Fixing
Changes in results post upgrade
Below is a list of changes made to the Quality Model in the current release of the PHP extension that are known to cause impacts to results.
PHP 1.3.1
PHP-916 - Avoid unreferenced Interfaces (PHP) - 1007062
A bug has been discovered that causes the Quality Rule to report false violations for unreferenced interfaces, when the interfaces are correctly referenced in the source code. This bug has now been fixed, therefore after an upgrade to PHP 1.3.1 and the generation of a post upgrade snapshot on the same source code, results may differ: there will be an decrease in the number of violations reported, improving accuracy.
PHP 1.3.0
- Avoid using include_once: A bug (PHP-625) has been discovered that causes the Quality Rule to not report violations when CAST AIP schemas are installed on an Oracle Server . This bug has now been fixed, therefore after an upgrade to PHP 1.3.0 and the generation of a post upgrade snapshot on the same source code, results may differ: there will be an increase in the number of violations reported, improving accuracy.
- All Quality Rules that depend on the PHP CodeSniffer: A bug (PHP-610) has been discovered that causes ALL the Quality Rules that depend on the PHP Code Sniffer (see the list here) to not report violations. This bug has now been fixed, therefore after an upgrade to PHP 1.3.0 and the generation of a post upgrade snapshot on the same source code, results may differ: there will be an increase in the number of violations reported, improving accuracy.
- Avoid using variable without testing them for initialisation: A bug (PHP-609) has been discovered that causes the Quality Rule to not report violations in PHP Constructor objects. This bug has now been fixed, therefore after an upgrade to PHP 1.3.0 and the generation of a post upgrade snapshot on the same source code, results may differ: there will be an increase in the number of violations reported, improving accuracy.
- Avoid using print function:
- A bug (PHP-608) has been discovered that causes the Quality Rule to not report violations in PHP Constructor objects. This bug has now been fixed, therefore after an upgrade to PHP 1.3.0 and the generation of a post upgrade snapshot on the same source code, results may differ: there will be an increase in the number of violations reported, improving accuracy.
- A bug (PHP-605) has been discovered that causes the Quality Rule to report false positive violations in PHP strings. This bug has now been fixed, therefore after an upgrade to PHP 1.3.0 and the generation of a post upgrade snapshot on the same source code, results may differ: there will be a decrease in the number of violations reported, improving accuracy.
- A bug (PHP-602) has been discovered that causes the Quality Rule to report violations only on PHP Section objects. This bug has now been fixed, therefore after an upgrade to PHP 1.3.0 and the generation of a post upgrade snapshot on the same source code, results may differ: violations will be reported on the correct object type, improving accuracy.
- Avoid using variable without testing them for initialisation:
- A bug (PHP-604) has been discovered that causes the Quality Rule to report false positive violations in PHP strings. This bug has now been fixed, therefore after an upgrade to PHP 1.3.0 and the generation of a post upgrade snapshot on the same source code, results may differ: there will be a decrease in the number of violations reported, improving accuracy.
- A bug (PHP-603) has been discovered that causes the Quality Rule to report violations only on PHP Section objects. This bug has now been fixed, therefore after an upgrade to PHP 1.3.0 and the generation of a post upgrade snapshot on the same source code, results may differ: violations will be reported on the correct object type, improving accuracy.
- Avoid artifacts with recursive calls: A bug (PHP-577) has been discovered that causes the Quality Rule to not report violations on objects containing recursive calls (false negative results). This bug has now been fixed, therefore after an upgrade to PHP 1.3.0 and the generation of a post upgrade snapshot on the same source code, results may differ: violations will be reported, improving accuracy.
- Function Points (transactions): a green tick indicates that OMG Function Point counting and Transaction Risk Index are supported
- Quality and Sizing: a green tick indicates that CAST can measure size and that a minimum set of Quality Rules exist
Function Points (transactions) | Quality and Sizing |
---|---|
Prerequisites | Description | Notes |
---|---|---|
Java JRE | Note that these prerequisites are only applicable in the following circumstances:
Therefore, if you are using CAST AIP ≥ 8.2.1, you don't need to set a JAVA_HOME. The PHP extension will use the JRE provided with CAST AIP and located in the installation folder.
| |
JAVA_HOME environment variable | ||
PHP / PHP Code Sniffer / PHPMD | The extension requires the installation of three third party items:
These items are provided with the extension, however, they must be installed manually as described in PHP 1.3 - Analysis Configuration. | N/A |
CAST recommends that you always install the latest release of an extension.
≥ 7.3.4 | 8.0.x | 8.1.x | 8.2.x |
---|---|---|---|
Supported DBMS servers
DBMS | Supported? |
---|---|
CSS | |
Oracle | |
Microsoft SQL Server |
Supported Versions of PHP
This version of the PHP extension provides partial support for the following PHP versions:
- 5.x
Licence Agreements
In order to provide a better solution and therefore increase the number of quality rules, the PHP configuration uses other external tools, such as:
PHP_CodeSniffer
More information about this tool is available here: http://pear.php.net/package/PHP_CodeSniffer
Version
CAST ships version 2.5.0 of the PHP_CodeSniffer.
License
The licence agreement for the PHP_CodeSniffer tool is available here:
and is detailed below:
Copyright (c) 2012, Squiz Pty Ltd (ABN 77 084 670 600)
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- Neither the name of Squiz Pty Ltd nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Quality Rules calculated by the PHP Code Sniffer tool
1007022 | Avoid FOR loops which can be simplified to a WHILE loop (PHP) |
1007024 | Avoid incrementer jumbling in loops (PHP) |
1007026 | Avoid using identical type operators rather than EQUAL operators (PHP) |
1007028 | Avoid using increment/decrement operator (PHP) |
1007030 | Avoid using empty statement (PHP) |
1007032 | Avoid empty class definition (PHP) |
1007034 | Avoid empty style definition (PHP) |
1007036 | Avoid classes having too many children (PHP) |
1007038 | Avoid classes having too many dependencies (PHP) |
1007040 | Avoid classes having too many parents (PHP) |
1007046 | Avoid Classes and Interfaces with a High Depth of Inheritance Tree (PHP) |
1007056 | Avoid unnecessary final modifiers inside final Classes (PHP) |
1007058 | Avoid unused Function parameters (PHP) |
1007080 | Avoid Classes not having the same name as the file (PHP) |
1007084 | Avoid uppercase keywords for control structures in Sections(PHP) |
1007086 | Avoid uppercase keywords for control structures in Functions and Methods(PHP) |
1007088 | Avoid having variable with a too short name (PHP) |
1007090 | Avoid having variable with a too long name (PHP) |
1007096 | Avoid ELSEIF statements. ELSE and IF should be separate (PHP) |
1007116 | Avoid Methods with Object Instantiation in loops (PHP) |
1007124 | Avoid empty catch blocks (PHP) |
1007126 | Avoid Functions throwing exceptions and not having a @Throws tag (PHP) |
1007128 | Avoid classes exceeding maximum length (PHP) |
1007130 | Avoid methods having too many parameters (PHP) |
1007132 | Avoid methods having lenght exceeding the maximum (PHP) |
1007134 | Avoid classes with too many fields (PHP) |
1007136 | Avoid classes with too many methods (PHP) |
1007138 | Avoid classes having a number of public methods and attributs exceeds maximum (PHP) |
1007140 | Avoid having unused variables (PHP) |
1007142 | Avoid unused private fields (PHP) |
1007144 | Avoid unused private methods (PHP) |
1007146 | Avoid classes exceeding number of weighted methods (PHP) |
1007148 | Avoid unconditional IF and ELSEIF statements (PHP) |
1007150 | Avoid useless overriding Methods (PHP) |
1007152 | Avoid unassigned default values in Functions (PHP) |
1007156 | Avoid using a goto statements (PHP) |
1007158 | Avoid using eval expressions (PHP) |
1007160 | Avoid using exit expressions (PHP) |
1007212 | Avoid having variables without naming conventions (PHP) |
1007226 | Avoid having For-loops that use a function call in the test expression (PHP) |
1007228 | Avoid having control structures without proper spacing in the open and close brace - PSR2 (PHP) |
1007230 | Avoid Having control structures without proper switch case declarations (PSR2) (PHP) |
1007232 | Avoid having variables passed by reference when calling a function (PHP) |
1007234 | Avoid having inline control statements (PHP) |
1007236 | Avoid having multiple classes defined in a single file - Symfony STD (PHP) |
1007238 | Avoid having class methods without scope modifiers - Symfony STD (PHP) |
1007240 | Avoid having object not instantiated using parenthesis - Symfony STD (PHP) |
PHPMD
More information about this tool is available here: http://phpmd.org/
The licence agreement for the PHPMD tool is available available in the file "LICENSE.txt" delivered in the source folder of the tool and is detailed below:
Copyright (c) 2009-2011, Manuel Pichler <mapi@phpmd.org>.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- Neither the name of Manuel Pichler nor the names of his contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
PHP Depend
More information about this tool is available here: http://pdepend.org/
The licence agreement for the PHP Depend tool is available in the file "LICENSE.txt" delivered in the source folder of the tool and is detailed below:
Copyright (c) 2008-2012, Manuel Pichler <mapi@pdepend.org>.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- Neither the name of Manuel Pichler nor the names of his contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Documentation of PHP Quality Rules and Metrics
Documentation of all CAST Metrics and Quality Rules specific to the PHP extension is delivered via a compiled HTML Help file (CHM). Please ensure that once the CHM has been downloaded you right-click on the CHM file in Windows Explorer and choose Properties > Unblock. This will ensure that the CHM is readable on your own PC:
Version | CHM |
---|---|
1.2.x - 1.3.x | metrics_PHP_1-2-0.chm |
1.3.1 + | metrics_PHP_1-3-1.chm |