src/Tool/DeclareStrictTypes.php
public function run(string $file, Node $node): array
    {
        // This inspection only works to top level statements in each file.
        if ($this->inspectedFile === $file) {
            return [];
        }

        $found = false;
        foreach ($node->children as $child) {
            if (!$child instanceof Node) {
                continue;
            }

            if ($child->kind !== \ast\AST_DECLARE) {
                continue;
            }

            $declares = $child->children["declares"];
            if ($declares->kind !== \ast\AST_CONST_DECL) {
                continue;
            }

            foreach ($declares->children as $declare) {
                if ($declare->kind === \ast\AST_CONST_ELEM && $declare->children["name"] === "strict_types") {
                    $found = true;
                }
            }
        }
        $this->inspectedFile = $file;

        if (!$found) {
            return [new Hint(
                self::HINT_TYPE,
                self::HINT_MESSAGE,
                $file,
                $node->lineno,
                self::HINT_LINK
            )];
        }

        return [];
    }
public function run(string $file, Node $node): array
    {
        // This inspection only works to top level statements in each file.
        if ($this->inspectedFile === $file) {
            return [];
        }

        $found = false;
        foreach ($node->children as $child) {
            if (!$child instanceof Node) {
                continue;
            }

            if ($child->kind !== \ast\AST_DECLARE) {
                continue;
            }

            $declares = $child->children["declares"];
            if ($declares->kind !== \ast\AST_CONST_DECL) {
                continue;
            }

            foreach ($declares->children as $declare) {
                if ($declare->kind === \ast\AST_CONST_ELEM && $declare->children["name"] === "strict_types") {
                    $found = true;
                }
            }
        }
        $this->inspectedFile = $file;

        if (!$found) {
            return [new Hint(
                self::HINT_TYPE,
                self::HINT_MESSAGE,
                $file,
                $node->lineno,
                self::HINT_LINK
            )];
        }

        return [];
    }
public function run ( string $ file , Node $ node ) : array { // This inspection only works to top level statements in each file. if ( $ this -> inspectedFile === $ file ) { return [ ] ; } $ found = false ; foreach ( $ node -> children as $ child ) { if ( ! $ child instanceof Node ) { continue ; } if ( $ child -> kind !== \ ast \ AST_DECLARE ) { continue ; } $ declares = $ child -> children [ "declares" ] ; if ( $ declares -> kind !== \ ast \ AST_CONST_DECL ) { continue ; } foreach ( $ declares -> children as $ declare ) { if ( $ declare -> kind === \ ast \ AST_CONST_ELEM && $ declare -> children [ "name" ] === "strict_types" ) { $ found = true ; } } } $ this -> inspectedFile = $ file ; if ( ! $ found ) { return [ new Hint ( self :: HINT_TYPE , self :: HINT_MESSAGE , $ file , $ node -> lineno , self :: HINT_LINK ) ] ; } return [ ] ; }
Check whether the passed node has `strict_types` declaration.

@param string $file File name to be analyzed.
@param Node   $node AST node to be analyzed.
@return Hint[] List of hints obtained from results.
Check whether the passed node has strict_types declaration .