/** * 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 context for * * @return void */ protected function determinePrivateContext(AssertionInterface $assertion) { // Get the string to check for dynamic properties $assertionString = $assertion->getString(); // Do we have method calls? $methodCalls = $this->filterMethodCalls($assertionString); if (!empty($methodCalls)) { // Iterate over all method calls and check if they are private foreach ($methodCalls as $methodCall) { // Get the function definition, but do not get recursive conditions $functionDefinition = $this->currentDefinition->getFunctionDefinitions()->get($methodCall); // If we found something private we can end here if ($functionDefinition instanceof FunctionDefinition && $functionDefinition->visibility === 'private') { // Set the private context to true and return it $assertion->setPrivateContext(true); return; } } } // Do we have any attributes? $attributes = $this->filterAttributes($assertionString); if (!empty($attributes)) { // Iterate over all attributes and check if they are private foreach ($attributes as $attribute) { $attributeDefinition = $this->currentDefinition->getAttributeDefinitions()->get($attribute); // If we found something private we can end here if ($attributeDefinition instanceof AttributeDefinition && $attributeDefinition->visibility === 'private') { // Set the private context to true and return it $assertion->setPrivateContext(true); return; } } } }