protected function findRelationMethodCall($methodBody)
    {
        $methodBody = trim(preg_replace('#\\n\\s*#', '', $methodBody));

        // find the last potential relation method opener and position
        $foundOpener  = null;
        $lastPosition = -1;

        foreach ($this->relationMethodCallOpeners() as $opener) {

            if (    false === ($pos = strrpos($methodBody, $opener))
                ||  $pos <= $lastPosition
            ) {
                continue;
            }

            $foundOpener  = $opener;
            $lastPosition = $pos;
        }


        if ( ! $foundOpener || $lastPosition < 0) {
            return false;
        }

        // todo further checks to prevent false positives
        // use https://github.com/nikic/PHP-Parser/

        return $foundOpener;
    }
protected function findRelationMethodCall($methodBody)
    {
        $methodBody = trim(preg_replace('#\\n\\s*#', '', $methodBody));

        // find the last potential relation method opener and position
        $foundOpener  = null;
        $lastPosition = -1;

        foreach ($this->relationMethodCallOpeners() as $opener) {

            if (    false === ($pos = strrpos($methodBody, $opener))
                ||  $pos <= $lastPosition
            ) {
                continue;
            }

            $foundOpener  = $opener;
            $lastPosition = $pos;
        }


        if ( ! $foundOpener || $lastPosition < 0) {
            return false;
        }

        // todo further checks to prevent false positives
        // use https://github.com/nikic/PHP-Parser/

        return $foundOpener;
    }
protected function findRelationMethodCall ( $ methodBody ) { $ methodBody = trim ( preg_replace ( '#\\n\\s*#' , '' , $ methodBody ) ) ; // find the last potential relation method opener and position $ foundOpener = null ; $ lastPosition = - 1 ; foreach ( $ this -> relationMethodCallOpeners ( ) as $ opener ) { if ( false === ( $ pos = strrpos ( $ methodBody , $ opener ) ) || $ pos <= $ lastPosition ) { continue ; } $ foundOpener = $ opener ; $ lastPosition = $ pos ; } if ( ! $ foundOpener || $ lastPosition < 0 ) { return false ; } // todo further checks to prevent false positives // use https://github.com/nikic/PHP-Parser/ return $ foundOpener ; }
Attempts to find the relation method call in a string method body.

This looks for $this->belongsTo(...) and the like.

@param string $methodBody
@return string|false
Attempts to find the relation method call in a string method body .