private function scanMethod(\PHPParser_Node_Stmt_ClassMethod $stmt, MethodContainer $class) { $method = new Method($stmt->name); $method->setAstNode($stmt); $method->setReturnByRef($stmt->byRef); // convert PHPParser modifier to our modifier $modifier = 0; if (\PHPParser_Node_Stmt_Class::MODIFIER_ABSTRACT === ($stmt->type & \PHPParser_Node_Stmt_Class::MODIFIER_ABSTRACT)) { $modifier |= Method::MODIFIER_ABSTRACT; } if (\PHPParser_Node_Stmt_Class::MODIFIER_FINAL === ($stmt->type & \PHPParser_Node_Stmt_Class::MODIFIER_FINAL)) { $modifier |= Method::MODIFIER_FINAL; } if (\PHPParser_Node_Stmt_Class::MODIFIER_STATIC === ($stmt->type & \PHPParser_Node_Stmt_Class::MODIFIER_STATIC)) { $modifier |= Method::MODIFIER_STATIC; } // All interface methods are automatically abstract without being declared as such. if ($class instanceof InterfaceC) { $modifier |= Method::MODIFIER_ABSTRACT; } $method->setModifier($modifier); $method->setVisibility(\PHPParser_Node_Stmt_Class::MODIFIER_PRIVATE === ($stmt->type & \PHPParser_Node_Stmt_Class::MODIFIER_PRIVATE) ? Method::VISIBILITY_PRIVATE : (\PHPParser_Node_Stmt_Class::MODIFIER_PROTECTED === ($stmt->type & \PHPParser_Node_Stmt_Class::MODIFIER_PROTECTED) ? Method::VISIBILITY_PROTECTED : Method::VISIBILITY_PUBLIC)); foreach ($this->paramParser->parse($stmt->params, 'Scrutinizer\\PhpAnalyzer\\Model\\MethodParameter') as $param) { $method->addParameter($param); } foreach ($stmt->params as $i => $param) { if (null !== ($docType = $this->commentParser->getTypeFromParamAnnotation($param, $param->name, true))) { $method->setParamDocType($i, $docType); } } if (null !== ($returnDocType = $this->commentParser->getTypeFromReturnAnnotation($stmt, true))) { $method->setReturnDocType($returnDocType); } $class->addMethod($method); }
private function copyMethods(MethodContainer $a, MethodContainer $b) { // merge in methods from $b into $a foreach ($b->getMethods() as $containerMethod) { // method already exists on $a if ($a->hasMethod($containerMethod->getName())) { // TODO: Check types for the method in $a, and if not complete // copy over all available types from $b continue; } $method = $containerMethod->getMethod(); // We do copy over all methods, even private ones. See above for properties. $a->addMethod($method, $containerMethod->getDeclaringClass()); } }