diff options
author | Máté Kocsis <kocsismate@woohoolabs.com> | 2020-10-23 14:09:23 +0200 |
---|---|---|
committer | Máté Kocsis <kocsismate@woohoolabs.com> | 2020-10-23 16:33:16 +0200 |
commit | 47bbfe1fc0855e8f141de7b56668a2294daec344 (patch) | |
tree | 563ba79dbe1e3199cafbbd21adbb929888ea279f /build/gen_stub.php | |
parent | 0fb2374e06948212826454c775bece91c4221e43 (diff) | |
download | php-git-47bbfe1fc0855e8f141de7b56668a2294daec344.tar.gz |
Require stubs to declare return types for magic methods when possible
Closes GH-6376
Diffstat (limited to 'build/gen_stub.php')
-rwxr-xr-x | build/gen_stub.php | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/build/gen_stub.php b/build/gen_stub.php index 8e7d915452..e17e083cb4 100755 --- a/build/gen_stub.php +++ b/build/gen_stub.php @@ -359,9 +359,9 @@ interface FunctionOrMethodName { public function getDeclaration(): string; public function getArgInfoName(): string; public function __toString(): string; - public function isMagicMethod(): bool; public function isMethod(): bool; public function isConstructor(): bool; + public function isDestructor(): bool; } class FunctionName implements FunctionOrMethodName { @@ -403,15 +403,15 @@ class FunctionName implements FunctionOrMethodName { return $this->name->toString(); } - public function isMagicMethod(): bool { + public function isMethod(): bool { return false; } - public function isMethod(): bool { + public function isConstructor(): bool { return false; } - public function isConstructor(): bool { + public function isDestructor(): bool { return false; } } @@ -443,10 +443,6 @@ class MethodName implements FunctionOrMethodName { return "$this->className::$this->methodName"; } - public function isMagicMethod(): bool { - return strpos($this->methodName, '__') === 0; - } - public function isMethod(): bool { return true; } @@ -454,6 +450,10 @@ class MethodName implements FunctionOrMethodName { public function isConstructor(): bool { return $this->methodName === "__construct"; } + + public function isDestructor(): bool { + return $this->methodName === "__destruct"; + } } class ReturnInfo { @@ -879,7 +879,7 @@ function parseFunctionLike( } $returnType = $func->getReturnType(); - if ($returnType === null && !$haveDocReturnType && !$name->isMagicMethod()) { + if ($returnType === null && !$haveDocReturnType && !$name->isConstructor() && !$name->isDestructor()) { throw new Exception("Missing return type for function $name()"); } |