Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compact symbol table #118

Merged
merged 5 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/Abstractions/FunctionAbstraction.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,10 @@ public function isVariadic() {
return true;
}
}
if ($this->function instanceof Function_ || $this->function instanceof \PhpParser\Node\Stmt\ClassMethod) {
return VariadicCheckVisitor::isVariadic($this->function->getStmts());
if ($this->function->getAttribute("variadic_implementation")) {
return true;
}

return false;
Comment on lines +150 to 154
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if ($this->function->getAttribute("variadic_implementation")) {
return true;
}
return false;
return $this->function->getAttribute("variadic_implementation");

}

Expand Down
18 changes: 10 additions & 8 deletions src/Checks/StaticCallCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,23 +82,25 @@ protected function checkAbstractClassMethod($fileName, StaticCall $node, ClassLi
$this->emitError($fileName, $node, ErrorConstants::TYPE_UNKNOWN_METHOD, "Unable to find method. $name::" . $node->name);
}
} else {
if (! $method->isStatic()) {
if (! $scope->isStatic() && $possibleDynamic) {
if (!$method->isStatic()) {
if (!$scope->isStatic() && $possibleDynamic) {
//if ($node->name != "__construct" && $node->class != "parent") {
// echo "Static call in $fileName " . $node->getLine() . "\n";
//}
} else {
$this->emitError($fileName, $node, ErrorConstants::TYPE_INCORRECT_DYNAMIC_CALL, "Attempt to call non-static method: $name::" . $node->name . " statically");
}
}
$minimumParams = $method->getMinimumRequiredParameters();
if (count($node->args) < $minimumParams) {
$this->emitError($fileName, $node, ErrorConstants::TYPE_SIGNATURE_COUNT, "Static call to method $name::" . $node->name . " does not pass enough parameters (" . count($node->args) . " passed $minimumParams required)");
}

$this->checkParams($fileName, $node, $method->getName(), $scope, $inside, $node->args, $method->getParameters());
}
if (!$node->isFirstClassCallable()) {
$minimumParams = $method->getMinimumRequiredParameters();
if (count($node->args) < $minimumParams) {
$this->emitError($fileName, $node, ErrorConstants::TYPE_SIGNATURE_COUNT, "Static call to method $name::" . $node->name . " does not pass enough parameters (" . count($node->args) . " passed $minimumParams required)");
}

$this->checkParams($fileName, $node, $method->getName(), $scope, $inside, $node->args, $method->getParameters());
}
}
}

/**
Expand Down
Loading
Loading