public function findFirstPropertyFetchAssignment(array $statements, $variable, $property, $notFoundError = null)
    {
        foreach ($this->filterAssignments($statements) as $assign) {
            if (!$assign->var instanceof PropertyFetch) {
                continue;
            }
            if ($assign->var->name !== $property) {
                continue;
            }
            $var = $assign->var->var;
            if ($var instanceof Variable && $var->name === $variable) {
                return $assign;
            }
        }

        throw new \RuntimeException($notFoundError ?: sprintf('Variable assignment $%s->%s not found', $variable, $property));
    }
public function findFirstPropertyFetchAssignment(array $statements, $variable, $property, $notFoundError = null)
    {
        foreach ($this->filterAssignments($statements) as $assign) {
            if (!$assign->var instanceof PropertyFetch) {
                continue;
            }
            if ($assign->var->name !== $property) {
                continue;
            }
            $var = $assign->var->var;
            if ($var instanceof Variable && $var->name === $variable) {
                return $assign;
            }
        }

        throw new \RuntimeException($notFoundError ?: sprintf('Variable assignment $%s->%s not found', $variable, $property));
    }
public function findFirstPropertyFetchAssignment ( array $ statements , $ variable , $ property , $ notFoundError = null ) { foreach ( $ this -> filterAssignments ( $ statements ) as $ assign ) { if ( ! $ assign -> var instanceof PropertyFetch ) { continue ; } if ( $ assign -> var -> name !== $ property ) { continue ; } $ var = $ assign -> var -> var ; if ( $ var instanceof Variable && $ var -> name === $ variable ) { return $ assign ; } } throw new \ RuntimeException ( $ notFoundError ? : sprintf ( 'Variable assignment $%s->%s not found' , $ variable , $ property ) ) ; }
Find first property fetch assignment with a given name.

EG: Find $foo->bar = something.

@param array       $statements    PHP statements
@param string      $variable      The variable name, EG: foo in $foo->bar
@param string      $property      The property name, EG: bar in $foo->bar
@param string|null $notFoundError Use this error when not found

@return Assign
Find first property fetch assignment with a given name .