West/Sniffs/PHP/NoNullSniff.php
public function process(File $phpcsFile, $stackPtr)
    {
        $tokens = $phpcsFile->getTokens();

        if (isset($tokens[$stackPtr]['nested_parenthesis']) === false) {
            // this isn't a default value
            // for a function
            $error = 'Use of null is forbidden';
            $phpcsFile->addError($error, $stackPtr, 'NullUsed');
            $phpcsFile->recordMetric($stackPtr, 'No null members', 'no');

            return;
        }

        // Check to see if this including statement is within the parenthesis
        // of a function.
        foreach ($tokens[$stackPtr]['nested_parenthesis'] as $left => $right) {
            $allowedPlacement = ['T_FUNCTION', 'T_IF', 'T_ELSEIF'];
            if (! isset($tokens[$left]['parenthesis_owner']) === true ||
                ! in_array($tokens[$tokens[$left]['parenthesis_owner']]['type'], $allowedPlacement)) {
                // this isn't a default value
                // for a function
                $error = 'Use of null is forbidden';
                $phpcsFile->addError($error, $stackPtr, 'NullUsed');
                $phpcsFile->recordMetric($stackPtr, 'No null members', 'no');

                return;
            }
        }
    }
public function process(File $phpcsFile, $stackPtr)
    {
        $tokens = $phpcsFile->getTokens();

        if (isset($tokens[$stackPtr]['nested_parenthesis']) === false) {
            // this isn't a default value
            // for a function
            $error = 'Use of null is forbidden';
            $phpcsFile->addError($error, $stackPtr, 'NullUsed');
            $phpcsFile->recordMetric($stackPtr, 'No null members', 'no');

            return;
        }

        // Check to see if this including statement is within the parenthesis
        // of a function.
        foreach ($tokens[$stackPtr]['nested_parenthesis'] as $left => $right) {
            $allowedPlacement = ['T_FUNCTION', 'T_IF', 'T_ELSEIF'];
            if (! isset($tokens[$left]['parenthesis_owner']) === true ||
                ! in_array($tokens[$tokens[$left]['parenthesis_owner']]['type'], $allowedPlacement)) {
                // this isn't a default value
                // for a function
                $error = 'Use of null is forbidden';
                $phpcsFile->addError($error, $stackPtr, 'NullUsed');
                $phpcsFile->recordMetric($stackPtr, 'No null members', 'no');

                return;
            }
        }
    }
{@inheritdoc}