HEX
Server: Apache
System: Linux pdx1-shared-a1-38 6.6.104-grsec-jammy+ #3 SMP Tue Sep 16 00:28:11 UTC 2025 x86_64
User: mmickelson (3396398)
PHP: 8.1.31
Disabled: NONE
Upload Files
File: //usr/local/wp/vendor/wp-coding-standards/wpcs/WordPress/Docs/PHP/StrictInArrayStandard.xml
<?xml version="1.0"?>
<documentation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="https://phpcsstandards.github.io/PHPCSDevTools/phpcsdocs.xsd"
    title="Strict In Array Syntax"
    >
    <standard>
    <![CDATA[
    When using functions which compare a value to a range of values in an array, make sure a strict comparison is executed.

    Typically, this rule verifies function calls to the PHP native `in_array()`, `array_search()` and `array_keys()` functions pass the `$strict` parameter.
    ]]>
    </standard>
    <code_comparison>
        <code title="Valid: Calling in_array() with the $strict parameter set to `true`.">
        <![CDATA[
$array = array( '1', 1, true );
if ( in_array( $value, $array, <em>true</em> ) ) {}
        ]]>
        </code>
        <code title="Invalid: Calling in_array() without passing the $strict parameter.">
        <![CDATA[
$array = array( '1', 1, true );
if ( in_array( $value, $array<em> </em>) ) {}
        ]]>
        </code>
    </code_comparison>

    <code_comparison>
        <code title="Valid: Calling array_search() with the $strict parameter set to `true`.">
        <![CDATA[
$key = array_search( 1, $array, <em>true</em> );
        ]]>
        </code>
        <code title="Invalid: Calling array_search() without passing the $strict parameter.">
        <![CDATA[
$key = array_search( 1, $array<em> </em>);
        ]]>
        </code>
    </code_comparison>

    <code_comparison>
        <code title="Valid: Calling array_keys() with a $search_value and the $strict parameter set to `true`.">
        <![CDATA[
$keys = array_keys( $array, $key, <em>true</em> );
        ]]>
        </code>
        <code title="Invalid: Calling array_keys() with a $search_value without passing the $strict parameter.">
        <![CDATA[
$keys = array_keys( $array, $key<em> </em>);
        ]]>
        </code>
    </code_comparison>
</documentation>