public function parse(string $pointcutExpression, string $sourceHint): PointcutFilterComposite
    {
        $this->sourceHint = $sourceHint;

        if (!is_string($pointcutExpression) || strlen($pointcutExpression) === 0) {
            throw new InvalidPointcutExpressionException(sprintf('Pointcut expression must be a valid string, "%s" given, defined in "%s"', gettype($pointcutExpression), $this->sourceHint), 1168874738);
        }
        $pointcutFilterComposite = new PointcutFilterComposite();
        $pointcutExpressionParts = preg_split(self::PATTERN_SPLITBYOPERATOR, $pointcutExpression, -1, PREG_SPLIT_DELIM_CAPTURE);

        $count = count($pointcutExpressionParts);
        for ($partIndex = 0; $partIndex < $count; $partIndex += 2) {
            $operator = ($partIndex > 0) ? trim($pointcutExpressionParts[$partIndex - 1]) : '&&';
            $expression = trim($pointcutExpressionParts[$partIndex]);

            if ($expression[0] === '!') {
                $expression = trim(substr($expression, 1));
                $operator .= '!';
            }

            if (strpos($expression, '(') === false) {
                $this->parseDesignatorPointcut($operator, $expression, $pointcutFilterComposite);
            } else {
                $matches = [];
                $numberOfMatches = preg_match(self::PATTERN_MATCHPOINTCUTDESIGNATOR, $expression, $matches);
                if ($numberOfMatches !== 1) {
                    throw new InvalidPointcutExpressionException('Syntax error: Pointcut designator expected near "' . $expression . '", defined in ' . $this->sourceHint, 1168874739);
                }
                $pointcutDesignator = $matches[0];
                $signaturePattern = $this->getSubstringBetweenParentheses($expression);
                switch ($pointcutDesignator) {
                    case 'classAnnotatedWith':
                    case 'class':
                    case 'methodAnnotatedWith':
                    case 'method':
                    case 'within':
                    case 'filter':
                    case 'setting':
                        $parseMethodName = 'parseDesignator' . ucfirst($pointcutDesignator);
                        $this->$parseMethodName($operator, $signaturePattern, $pointcutFilterComposite);
                    break;
                    case 'evaluate':
                        $this->parseRuntimeEvaluations($operator, $signaturePattern, $pointcutFilterComposite);
                    break;
                    default:
                        throw new AopException('Support for pointcut designator "' . $pointcutDesignator . '" has not been implemented (yet), defined in ' . $this->sourceHint, 1168874740);
                }
            }
        }
        return $pointcutFilterComposite;
    }
public function parse(string $pointcutExpression, string $sourceHint): PointcutFilterComposite
    {
        $this->sourceHint = $sourceHint;

        if (!is_string($pointcutExpression) || strlen($pointcutExpression) === 0) {
            throw new InvalidPointcutExpressionException(sprintf('Pointcut expression must be a valid string, "%s" given, defined in "%s"', gettype($pointcutExpression), $this->sourceHint), 1168874738);
        }
        $pointcutFilterComposite = new PointcutFilterComposite();
        $pointcutExpressionParts = preg_split(self::PATTERN_SPLITBYOPERATOR, $pointcutExpression, -1, PREG_SPLIT_DELIM_CAPTURE);

        $count = count($pointcutExpressionParts);
        for ($partIndex = 0; $partIndex < $count; $partIndex += 2) {
            $operator = ($partIndex > 0) ? trim($pointcutExpressionParts[$partIndex - 1]) : '&&';
            $expression = trim($pointcutExpressionParts[$partIndex]);

            if ($expression[0] === '!') {
                $expression = trim(substr($expression, 1));
                $operator .= '!';
            }

            if (strpos($expression, '(') === false) {
                $this->parseDesignatorPointcut($operator, $expression, $pointcutFilterComposite);
            } else {
                $matches = [];
                $numberOfMatches = preg_match(self::PATTERN_MATCHPOINTCUTDESIGNATOR, $expression, $matches);
                if ($numberOfMatches !== 1) {
                    throw new InvalidPointcutExpressionException('Syntax error: Pointcut designator expected near "' . $expression . '", defined in ' . $this->sourceHint, 1168874739);
                }
                $pointcutDesignator = $matches[0];
                $signaturePattern = $this->getSubstringBetweenParentheses($expression);
                switch ($pointcutDesignator) {
                    case 'classAnnotatedWith':
                    case 'class':
                    case 'methodAnnotatedWith':
                    case 'method':
                    case 'within':
                    case 'filter':
                    case 'setting':
                        $parseMethodName = 'parseDesignator' . ucfirst($pointcutDesignator);
                        $this->$parseMethodName($operator, $signaturePattern, $pointcutFilterComposite);
                    break;
                    case 'evaluate':
                        $this->parseRuntimeEvaluations($operator, $signaturePattern, $pointcutFilterComposite);
                    break;
                    default:
                        throw new AopException('Support for pointcut designator "' . $pointcutDesignator . '" has not been implemented (yet), defined in ' . $this->sourceHint, 1168874740);
                }
            }
        }
        return $pointcutFilterComposite;
    }
public function parse ( string $ pointcutExpression , string $ sourceHint ) : PointcutFilterComposite { $ this -> sourceHint = $ sourceHint ; if ( ! is_string ( $ pointcutExpression ) || strlen ( $ pointcutExpression ) === 0 ) { throw new InvalidPointcutExpressionException ( sprintf ( 'Pointcut expression must be a valid string, "%s" given, defined in "%s"' , gettype ( $ pointcutExpression ) , $ this -> sourceHint ) , 1168874738 ) ; } $ pointcutFilterComposite = new PointcutFilterComposite ( ) ; $ pointcutExpressionParts = preg_split ( self :: PATTERN_SPLITBYOPERATOR , $ pointcutExpression , - 1 , PREG_SPLIT_DELIM_CAPTURE ) ; $ count = count ( $ pointcutExpressionParts ) ; for ( $ partIndex = 0 ; $ partIndex < $ count ; $ partIndex += 2 ) { $ operator = ( $ partIndex > 0 ) ? trim ( $ pointcutExpressionParts [ $ partIndex - 1 ] ) : '&&' ; $ expression = trim ( $ pointcutExpressionParts [ $ partIndex ] ) ; if ( $ expression [ 0 ] === '!' ) { $ expression = trim ( substr ( $ expression , 1 ) ) ; $ operator .= '!' ; } if ( strpos ( $ expression , '(' ) === false ) { $ this -> parseDesignatorPointcut ( $ operator , $ expression , $ pointcutFilterComposite ) ; } else { $ matches = [ ] ; $ numberOfMatches = preg_match ( self :: PATTERN_MATCHPOINTCUTDESIGNATOR , $ expression , $ matches ) ; if ( $ numberOfMatches !== 1 ) { throw new InvalidPointcutExpressionException ( 'Syntax error: Pointcut designator expected near "' . $ expression . '", defined in ' . $ this -> sourceHint , 1168874739 ) ; } $ pointcutDesignator = $ matches [ 0 ] ; $ signaturePattern = $ this -> getSubstringBetweenParentheses ( $ expression ) ; switch ( $ pointcutDesignator ) { case 'classAnnotatedWith' : case 'class' : case 'methodAnnotatedWith' : case 'method' : case 'within' : case 'filter' : case 'setting' : $ parseMethodName = 'parseDesignator' . ucfirst ( $ pointcutDesignator ) ; $ this -> $ parseMethodName ( $ operator , $ signaturePattern , $ pointcutFilterComposite ) ; break ; case 'evaluate' : $ this -> parseRuntimeEvaluations ( $ operator , $ signaturePattern , $ pointcutFilterComposite ) ; break ; default : throw new AopException ( 'Support for pointcut designator "' . $ pointcutDesignator . '" has not been implemented (yet), defined in ' . $ this -> sourceHint , 1168874740 ) ; } } } return $ pointcutFilterComposite ; }
Parses a string pointcut expression and returns the pointcut
objects accordingly

@param string $pointcutExpression The expression defining the pointcut
@param string $sourceHint A message giving a hint on where the expression was defined. This is used in error messages.
@return PointcutFilterComposite A composite of class-filters, method-filters and pointcuts
@throws InvalidPointcutExpressionException
@throws AopException
Parses a string pointcut expression and returns the pointcut objects accordingly