Skip to content

Files

Latest commit

 

History

History
34 lines (24 loc) · 1.2 KB

Generic.PHP.ForbiddenFunctions.md

File metadata and controls

34 lines (24 loc) · 1.2 KB

Pattern: Use of alias function

Issue: -

Description

This rule discourages the use of alias functions that are kept in PHP for compatibility with older versions.

Configuration

Rule can be used to forbid the use of any function by setting the forbiddenFunctions property. The property is defined as an array, with the keys being the names of the functions to forbid and the values being the names of suggested alternative functions to use instead. If no alternative function exists (i.e., the function should never be used) specify null as the value.

<rule ref="Generic.PHP.ForbiddenFunctions">
    <properties>
        <property name="forbiddenFunctions" type="array"
            value="print=>echo,create_function=>null" />
     </properties>
</rule>

If the error property is set to false, a warning will be thrown for violations instead of an error.

<rule ref="Generic.PHP.ForbiddenFunctions">
    <properties>
        <property name="error" value="false" />
    </properties>
</rule>

Further Reading