public function search($name, $type = null, $deepSearch = true)
    {
        /** @var TokenInterface[] $array */
        $array = $this->getArrayCopy();

        foreach ($array as $token) {
            if (fnmatch($name, $token->getName())) {
                if ($type === null) {
                    return $token;
                }
                if ($token->getTokenType() === $type) {
                    return $token;
                }
            }
            if ($token instanceof Block && $token->hasChildren() && $deepSearch) {
                if ($res = $this->deepSearch($token, $name, $type)) {
                    return $res;
                }
            }
        }
        return null;
    }
public function search($name, $type = null, $deepSearch = true)
    {
        /** @var TokenInterface[] $array */
        $array = $this->getArrayCopy();

        foreach ($array as $token) {
            if (fnmatch($name, $token->getName())) {
                if ($type === null) {
                    return $token;
                }
                if ($token->getTokenType() === $type) {
                    return $token;
                }
            }
            if ($token instanceof Block && $token->hasChildren() && $deepSearch) {
                if ($res = $this->deepSearch($token, $name, $type)) {
                    return $res;
                }
            }
        }
        return null;
    }
public function search ( $ name , $ type = null , $ deepSearch = true ) { /** @var TokenInterface[] $array */ $ array = $ this -> getArrayCopy ( ) ; foreach ( $ array as $ token ) { if ( fnmatch ( $ name , $ token -> getName ( ) ) ) { if ( $ type === null ) { return $ token ; } if ( $ token -> getTokenType ( ) === $ type ) { return $ token ; } } if ( $ token instanceof Block && $ token -> hasChildren ( ) && $ deepSearch ) { if ( $ res = $ this -> deepSearch ( $ token , $ name , $ type ) ) { return $ res ; } } } return null ; }
Search this object for a Token with a specific name and return the first match

@param string $name [required] Name of the token
@param int $type [optional] TOKEN_DIRECTIVE | TOKEN_BLOCK
@param bool $deepSearch [optional] If the search should be multidimensional. Default is true
@return null|TokenInterface Returns the Token or null if none is found
Search this object for a Token with a specific name and return the first match