public function __construct(Clazz $class, Method $method, $declaringClass = null) { $this->class = $class; $this->method = $method; $this->name = strtolower($method->getName()); if ($class->getName() === $declaringClass) { $declaringClass = null; } $this->declaringClass = $declaringClass; }
public function __construct(InterfaceC $interface, Method $method, $declaringInterface = null) { $this->interface = $interface; $this->method = $method; $this->name = strtolower($method->getName()); if ($interface->getName() === $declaringInterface) { $declaringInterface = null; } $this->declaringInterface = $declaringInterface; }
public function addMethod(Method $method, $declaringInterface = null) { $interfaceMethod = new InterfaceMethod($this, $method, $declaringInterface); $this->methods->set(strtolower($method->getName()), $interfaceMethod); }
public function addMethod(Method $method, $declaringClass = null) { $classMethod = new ClassMethod($this, $method, $declaringClass); $this->methods->set(strtolower($method->getName()), $classMethod); }
/** * Parses the method definition (@method), and extract * * This should ideally all be extracted to a dedicated parser component. There is * no point in keeping this hidden away in here. * * @param string $def * * @return null|Method */ private function parseCommentMethodDef($def) { // We use some half-assed regular expression, and hope that it will work out. // To bad that there is no well defined structure, and also no well written // parser :-( if (!preg_match('/ # Syntax: [return type] [name]([type] [parameter], [...]) [<description>] # Possible Type Name (?:([^\\s]+)\\s+)? # Method Name (must be followed by "()") ([^\\s(]+) # Arguments \\(([^)]*)\\) /xs', $def, $match)) { $this->logger->warning(sprintf('Could not parse @method tag "%s".', $def)); return null; } list(, $typeName, $methodName, $arguments) = $match; $method = new Method($methodName); if (!empty($typeName) && null !== ($returnType = $this->commentParser->tryGettingType($typeName))) { $method->setReturnType($returnType); } $arguments = trim($arguments); if (empty($arguments)) { return $method; } foreach (explode(',', $arguments) as $i => $argument) { if (!preg_match('/(?:([^\\s]+)\\s+)?\\$?([^\\s,]+)/', $argument, $match)) { $this->logger->warning(sprintf('Could not parse argument "%s" of @method "%s"; skipping all further arguments.', $argument, $method->getName())); break; } $parameter = new \Scrutinizer\PhpAnalyzer\Model\MethodParameter($match[2], $i); if (!empty($match[1]) && null !== ($paramType = $this->commentParser->tryGettingType($match[1]))) { $parameter->setPhpType($paramType); } $method->addParameter($parameter); } return $method; }
private function insertMethod(Method $method, $packageVersionId) { $this->methodStmt->bindValue(1, $this->phpType->convertToDatabaseValue($method->getReturnType(), $this->platform)); $this->methodStmt->bindValue(2, $method->getName()); $this->methodStmt->bindValue(3, $method->isReturnByRef() ? 1 : 0, \PDO::PARAM_INT); $this->methodStmt->bindValue(4, $method->getModifier(), \PDO::PARAM_INT); $this->methodStmt->bindValue(5, $method->getVisibility(), \PDO::PARAM_INT); $this->methodStmt->bindValue(6, $packageVersionId, \PDO::PARAM_INT); $this->methodStmt->bindValue(7, $method->hasVariableParameters() ? 1 : 0, \PDO::PARAM_INT); $this->methodStmt->bindValue(8, json_encode($method->getDocTypes()), \PDO::PARAM_STR); $this->methodStmt->execute(); $this->methodIdRef->setValue($method, $methodId = $this->con->lastInsertId()); foreach ($method->getParameters() as $param) { $this->paramPersister->persist($param, $method); } foreach ($method->getInCallSites() as $callSite) { $this->callSitePersister->persist($callSite); } foreach ($method->getOutCallSites() as $callSite) { $this->callSitePersister->persist($callSite); } return $methodId; }