/** * Will try to figure out if the passed assertion has a private context or not. * This information will be entered into the assertion which will then be returned. * * @param \TechDivision\PBC\Interfaces\AssertionInterface $assertion The assertion we need the minimal scope for * * @return void */ protected function determineMinimalScope(AssertionInterface $assertion) { // Get the string to check for dynamic properties $assertionString = $assertion->getString(); // Do we have method calls? If so we have at least structure scope $methodCalls = $this->filterMethodCalls($assertionString); if (!empty($methodCalls)) { $assertion->setMinScope('structure'); } // Do we have any attributes? If so we have at least structure scope $attributes = $this->filterAttributes($assertionString); if (!empty($attributes)) { $assertion->setMinScope('structure'); } }
/** * This method will check if a certain assertion mismatches the scope of this function. * * @param \TechDivision\PBC\Interfaces\AssertionInterface $assertion The assertion to check for a possible mismatch * within this function context * * @return boolean */ protected function conditionIsMismatch(AssertionInterface $assertion) { // If the minimal scope is above or below function scope we cannot determine if this is a mismatch in // function scope. if ($assertion->getMinScope() !== 'function') { return false; } // We will get all parameters and check if we can find any of it in the assertion string. // If not then we have a mismatch as the condition is only function scoped $assertionString = $assertion->getString(); $parameterIterator = $this->parameterDefinitions->getIterator(); foreach ($parameterIterator as $parameter) { if (strpos($assertionString, $parameter->name) !== false) { return false; } } // Still here, that does not sound good return true; }