Summary: This document provides information about the extension providing PHP support.
Extension ID
com.castsoftware.php
What's new?
Please see PHP 3.1 - Release Notes for more information.
Description
This extension provides support for applications written using the PHP language.
In what situation should you install this extension?
If your application contains source code written using PHP and you want to view these object types and their links with other objects, then you should install this extension.
Supported versions
This version of the extension provides support for:
Technology | Supported | Notes |
---|---|---|
PHP 5.x | - | |
Symfony Framework | Doctrine is NOT supported. |
Function Point, Quality and Sizing support
- 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 |
AIP Core compatibility
AIP Core release | Supported? |
---|---|
8.3.x |
Supported DBMS servers
DBMS | Supported? |
---|---|
CSS / PostgreSQL |
Download and installation instructions
The extension will be automatically downloaded and installed in AIP Console when you deliver PHP code. You can also manually install the extension using the Application - Extensions interface. Once the extension is downloaded and installed, you can now package your source code and run an analysis. The process of preparing and delivering your source code is described below.
Upgrading from previous releases of the PHP Analyzer
Previous releases of the PHP Analyzer required that an instance of PHP was installed on the Node (i.e. the machine on which the analysis is run). This requirement has been removed in ≥ 3.1.0. The PHP Analyzer now uses an instance of PHP embedded within the extension (v. 5.4.3). Therefore, please note the following:
- If you have already installed a previous version of the PHP Analyzer on your Node and already have a functioning PHP install from that extension, please ensure that you uninstall PHP before proceeding with the instructions below. To remove the PHP installation provided with the PHP Analyzer:
- delete the folder into which it was installed (by default this is usually set to C:\php).
- delete the system environment variable PHP_HOME
- Please check that you do not have an existing third party (i.e. not provided by CAST) installation of PHP on this machine. If a third party installation of PHP already exists, please follow the PHP uninstall procedure for the install method that was used, before starting an analysis. Third party PHP installations are not compatible with the PHP extension.
Prepare and deliver the source code
Source code preparation
- Only files with following extensions will be analyzed *.php; *.php4; *.php5; *.php6; *.inc; *.phtml. The *.yml and *.yaml extensions are also supported for Symfony framework.
- The analysis of XML and XSL files contained in the PHP application is not supported.
- The analysis of any HTML and JavaScript source code delivered with the PHP code is managed by the HTML and JavaScript extension / .NET analyzer, to be configured in addition to the PHP analysis.
Source code preprocessing
PHP source code needs to be preprocessed so that CAST can understand it and analyze it correctly. This code preprocessing is actioned automatically when an analysis is launched or a snapshot is generated (the code is preprocessed before the analysis starts). In other words you only need to package, deliver and launch an analysis/generate a snapshot for the preprocessing to be completed. The PHP Preprocessor log file is stored in the following location:
%PROGRAMDATA%\CAST\CAST\Logs\<application_name>\Execute_Analysis_<guid>\com.castsoftware.php.<_extension_version>.prepro_YYYYMMDDHHMMSS.log
Short tags
PHP short tags <? and <?= in the delivered source code cannot be handled as is, therefor the analyzer will automatically convert them to <?php tags with an added comment, for example: <?=$string?> will be transformed into <?php /*php short tag*/echo $string>.
Deliver the source code
Using AIP Console
Using CAST Management Studio
Analysis configuration and execution
Using AIP Console
AIP Console exposes the technology configuration options once a version has been accepted/imported, or an analysis has been run. Click Universal Technology (3) in the Config (1) > Analysis (2) tab to display the available options for your PHP source code:
Then choose the relevant Analysis Unit (1) to view the configuration:
Using CAST Management Studio
What results can you expect?
Objects
PHP Objects
Icon | Metamodel Name |
---|---|
PHP Array | |
PHP Class | |
PHP Class Constant | |
PHP Constructor | |
PHP Define | |
PHP Function | |
PHP Interface | |
PHP Member | |
PHP Method | |
PHP Section | |
Script Function | |
Script Section |
Symfony Framework objects
Icon | Metamodel Name |
---|---|
PHP Symfony Controller | |
PHP Symfony Controller Class | |
PHP Symfony Route | |
PHP Symfony Service |
In CAST Enlighten, all Symfony objects will appear under their respective folders as shown below :
PHP Symfony Controller Class
- Supported scenario: If the Class name ends with Controller, we will create PHP Symfony Controller Class objects
- Links:
- PHP Symfony Controller Class --- Refer Link ---> PHP Class
- Limitations: Alternate syntax where you can give the class name that does not have suffix "Controller" is not supported
PHP Symfony Controller
- Supported scenario: If the method or function ends with suffix "Action", then PHP Symfony Controller Object will be created
- Links:
- PHP Symfony Controller --- Refer Link ---> PHP Symfony Route
- PHP Symfony Controller --- Refer Link ---> PHP Method\Function
PHP Symfony Route
- Supported scenario:
- If a route has been declared in the yml file, a route object will be created
- If a route has been declared in PHP file an annotation route object will be created as follows:
- Default naming convention for route annotation when declared without name above class "<classname>_Class_Annotation_<number>"
- Default naming convention for route annotation when declared without name above method "<methodname>_Method_Annotation_<number>"
- Links:
- PHP Symfony Route --- Call Link ---> PHP Symfony Controller
PHP Symfony Service
- Supported scenario: If a service has been declared in the yml configuration files, PHP Symfony Service Object will be created
- Links:
- PHP Symfony Service --- Call Link ---> PHP Method
- PHP Symfony Service --- Call Link ---> PHP Property
- PHP Symfony Service --- Call Link ---> PHP Class constructor
- Limitation: Inheritance is not supported while determining property setter or constructor injection - they need to be defined in the same class which is being referred to in the service
Structural Rules
The following structural rules are provided:
You can also find a global list here:
https://technologies.castsoftware.com/rules?sec=t_1017000&ref=||
Logging mechanism
Analysis log files
Analysis logs are stored in the default locations.
PHP Preprocessor
PHP Preprocessor log file name (the preprocessor is launched automatically during an analysis) would be in format com.castsoftware.php.prepro_<ExtensionVersion>_<YYYYMMDDHHMMSS>.log
PHP Plugin
PHP Plugin, which uses PHP CodeSniffer, PDepend, PMD, log file name (the PHP Plugin is launched automatically during an analysis) would be of format com.castsoftware.php.plugin_<ExtensionVersion>_<YYYYMMDDHHMMSS>.log.
Errors and Warnings
The PHP configuration included in the extension uses external plugins. During the analysis, the Universal Analyzer or the plugin can throw errors or warnings. The table below list the most significant errors/warnings and lists a suggested remediation action:
Tool | Error or Warning | Action |
---|---|---|
Analyzer & Code Sniffer | UA Plugin : No property (......) found in meta model for php... | No action required. The analyzer is telling you that not all the properties are considered to be injected into the Analysis Service. |
Limitations
License agreements
The PHP extension uses several third-party tools. The Licence Agreements for these tools are listed below: