public function matchExecutionPoint(Token $aToken) { $bIsPattern = $this->weaveMethodIsPattern(); // 模糊匹配每个方法 if ($bIsPattern and $aToken instanceof FunctionDefine) { // 必须是一个类方法 if (!($aClass = $aToken->belongsClass())) { return false; } if (!$this->matchClass($aClass->fullName())) { return false; } return preg_match($this->weaveMethodNameRegexp(), $aToken->name()) ? true : false; } else { if (!$bIsPattern and $aToken instanceof ClosureToken) { // 必须是一个 "}" if ($aToken->tokenType() != Token::T_BRACE_CLOSE) { return false; } // 必须成对 if (!$aToken->theOther()) { return false; } $aClass = $aToken->theOther()->belongsClass(); if (null === $aClass) { return false; } // 必须做为 class 的结束边界 if ($aToken->theOther() !== $aClass->bodyToken()) { return false; } if (!$this->matchClass($aClass->fullName())) { return false; } return true; } } }