Semantic Analysis

Zend Studio's Code Analyzer and Semantic Analysis mechanisms can detect problems beyond the regular parsing warnings and errors. TheyThis helps developers to analyze static source code to enforce good coding practices and scan PHP code. The Code Analyzer/ Semantic Analysis feature achieves this functionality by attempting to reconcile problematic code and locating unreachable code (code that has been defined but is not used or with empty variables).

Code Analyzer/Semantic Analysis warning messages help to ensure that your code is written and formatted in a way that will result in optimal performance for your script. In addition, it supplies you with practical suggestions for improving the code.

Code Analyzer/Semantic Analysis problems will be displayed in the Problems view and be indicated in the code with warning and error icons (see Real Time Error Detection for more information).

Quick Fix

The Semantic Analysis Quick Fix option enables you to easily change your problematic code according to suggestions supplied by the Semantic Analysis mechanism. This includes suggested actions for element creation or implementation.

 

 

Usage Example

Example:

 

See Applying Quick Fixes for more information.

Preferences

To enable/disable Code Analyzer/ Semantic Analysis and to configure which occurrences will trigger warning or error messages, go to the Code Analyzer Preferences page, accessible by going to Window | Preferences | PHP | Code Analyzer and the Semantic Analysis Preferences page, accessible by going to Window | Preferences | PHP | Semantic Analysis Properties.

Note:

The Code Analyzer and Semantic Analysis use different mechanisms and can be used simultaneously. However, certain overlaps bcan cause some errors to appear twice and so the Code Analyzer is disabled by default.