Skip to content
This repository was archived by the owner on Mar 29, 2024. It is now read-only.

Commit 7828d6f

Browse files
committed
Alter tests to verify methods return type in advance to params type
1 parent 2a06480 commit 7828d6f

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

tests/001-verify-method-parameters-type.phpt renamed to tests/001-verify-methods-signature.phpt

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--TEST--
2-
Check whether all method parameters have valid type
2+
Check whether methods signature is valid
33
--SKIPIF--
44
<?php if (!extension_loaded("v8")) print "skip"; ?>
55
--FILE--
@@ -25,6 +25,31 @@ class Verifier
2525
foreach ($method->getParameters() as $p) {
2626
$this->verifyParameter($p);
2727
}
28+
29+
if ($method->getReturnType()) {
30+
$type = $method->getReturnType();
31+
32+
if (!$type || $type->isBuiltin()) {
33+
return;
34+
}
35+
36+
if(!class_exists($type) && !interface_exists($type)) {
37+
$method_name = $method->getDeclaringClass()->getName() . '::' . $method->getDeclaringFunction()->getName();
38+
$shortcut = $method_name . '/return type';
39+
if (isset($this->invalid[$shortcut])) {
40+
return;
41+
}
42+
43+
$this->invalid[$shortcut] = true;
44+
45+
echo "{$method_name}() method's return type is invalid ($type)", PHP_EOL;
46+
}
47+
}
48+
49+
}
50+
51+
protected function verifyReturnType(ReflectionType $rt) {
52+
2853
}
2954

3055
public function verifyParameter(ReflectionParameter $parameter)

0 commit comments

Comments
 (0)