_function = $function; $this->_aliased_classes = $source->getAliasedClasses(); $this->_namespace = $source->getNamespace(); $this->_class_name = $source->getClassName(); $this->_class_extends = $source->getClassExtends(); $this->_file_name = $source->getFileName(); $this->_absolute_class = $source->getAbsoluteClass(); $this->_statements_checker = new StatementsChecker($this, substr($this->_file_name, -4) === '.php'); if ($function instanceof PhpParser\Node\Stmt\ClassMethod) { $this->_statements_checker->registerMethod($function); $this->_is_static = $function->isStatic(); } } public function check($extra_scope_vars = []) { if ($this->_function->stmts) { $vars_in_scope = $extra_scope_vars; $vars_possibly_in_scope = $extra_scope_vars; foreach ($this->_function->params as $param) { if ($param->type) { if (is_object($param->type)) { if (!in_array($param->type->parts[0], ['self', 'parent'])) { ClassChecker::checkClassName($param->type, $this->_namespace, $this->_aliased_classes, $this->_file_name); } } } $vars_in_scope[$param->name] = true; $vars_possibly_in_scope[$param->name] = true; $this->_statements_checker->registerVariable($param->name, $param->getLine()); if ($param->type && is_object($param->type)) { $vars_in_scope[$param->name] = $param->type->parts === ['self'] ? $this->_absolute_class : ClassChecker::getAbsoluteClassFromName($param->type, $this->_namespace, $this->_aliased_classes); } } $this->_statements_checker->check($this->_function->stmts, $vars_in_scope, $vars_possibly_in_scope); } } public function getNamespace() { return $this->_namespace; } public function getAliasedClasses() { return $this->_aliased_classes; } public function getAbsoluteClass() { return $this->_absolute_class; } public function getClassName() { return $this->_class_name; } public function getClassExtends() { return $this->_class_extends; } public function getFileName() { return $this->_file_name; } public function isStatic() { return $this->_is_static; } }