mirror of
https://github.com/php/php-src.git
synced 2025-08-16 14:08:47 +02:00
Make line numbers for inheritance errors more precise
Use the line of the conflicting child method, rather than either the first or last line of the class.
This commit is contained in:
parent
fd5d659779
commit
251f293cb7
13 changed files with 16 additions and 13 deletions
|
@ -23,4 +23,4 @@ class B extends A {
|
|||
}
|
||||
?>
|
||||
--EXPECTF--
|
||||
Fatal error: Declaration of B::foo($var) must be compatible with A::foo() in %sbug62358.php on line 17
|
||||
Fatal error: Declaration of B::foo($var) must be compatible with A::foo() in %sbug62358.php on line 18
|
||||
|
|
|
@ -26,5 +26,5 @@ $o = new Smooth1();
|
|||
echo "okey";
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: Declaration of Smooth1::insert(array $data) should be compatible with Noisy1::insert(array $data, $option1 = NULL) in %sbug64988.php on line 20
|
||||
Warning: Declaration of Smooth1::insert(array $data) should be compatible with Noisy1::insert(array $data, $option1 = NULL) in %sbug64988.php on line 17
|
||||
okey
|
||||
|
|
|
@ -9,4 +9,4 @@ class B extends A {
|
|||
public function m(array $a = []) {}
|
||||
}
|
||||
--EXPECTF--
|
||||
Warning: Declaration of B::m(array $a = Array) should be compatible with A::m(?array $a = NULL) in %sbug71428.1.php on line 7
|
||||
Warning: Declaration of B::m(array $a = Array) should be compatible with A::m(?array $a = NULL) in %sbug71428.1.php on line 6
|
||||
|
|
|
@ -11,4 +11,4 @@ class Two extends One {
|
|||
public function a() {}
|
||||
}
|
||||
--EXPECTF--
|
||||
Fatal error: Declaration of Two::a() must be compatible with One::a(): object in %s on line 9
|
||||
Fatal error: Declaration of Two::a() must be compatible with One::a(): object in %s on line 8
|
||||
|
|
|
@ -16,4 +16,4 @@ class qux implements foo {
|
|||
$qux = new qux();
|
||||
var_dump($qux->bar());
|
||||
--EXPECTF--
|
||||
Fatal error: Declaration of qux::bar(): qux must be compatible with foo::bar(): foo in %s008.php on line 7
|
||||
Fatal error: Declaration of qux::bar(): qux must be compatible with foo::bar(): foo in %s008.php on line 8
|
||||
|
|
|
@ -11,4 +11,4 @@ class B extends A {
|
|||
?>
|
||||
DONE
|
||||
--EXPECTF--
|
||||
Fatal error: Declaration of B::foo(): ?int must be compatible with A::foo(): int in %s031.php on line 7
|
||||
Fatal error: Declaration of B::foo(): ?int must be compatible with A::foo(): int in %s031.php on line 6
|
||||
|
|
|
@ -17,4 +17,4 @@ class SomeCollection implements Collection {
|
|||
$some = new SomeCollection();
|
||||
var_dump($some->getIterator());
|
||||
--EXPECTF--
|
||||
Fatal error: Declaration of SomeCollection::getIterator(): Generator must be compatible with Collection::getIterator(): Iterator in %sgenerators003.php on line 6
|
||||
Fatal error: Declaration of SomeCollection::getIterator(): Generator must be compatible with Collection::getIterator(): Iterator in %sgenerators003.php on line 7
|
||||
|
|
|
@ -14,4 +14,4 @@ class Bar extends Foo {
|
|||
}
|
||||
}
|
||||
--EXPECTF--
|
||||
Fatal error: Declaration of Bar::test(): Bar must be compatible with Foo::test(): Foo in %sinheritance005.php on line 12
|
||||
Fatal error: Declaration of Bar::test(): Bar must be compatible with Foo::test(): Foo in %sinheritance005.php on line 9
|
||||
|
|
|
@ -18,4 +18,4 @@ class Bar extends Foo {
|
|||
}
|
||||
}
|
||||
--EXPECTF--
|
||||
Fatal error: Declaration of Bar::test(): B must be compatible with Foo::test(): A in %sinheritance006.php on line 14
|
||||
Fatal error: Declaration of Bar::test(): B must be compatible with Foo::test(): A in %sinheritance006.php on line 11
|
||||
|
|
|
@ -16,4 +16,4 @@ class Bar extends Foo {
|
|||
}
|
||||
}
|
||||
--EXPECTF--
|
||||
Fatal error: Declaration of Bar::test(): ArrayObject must be compatible with Foo::test(): Traversable in %sinheritance007.php on line 12
|
||||
Fatal error: Declaration of Bar::test(): ArrayObject must be compatible with Foo::test(): Traversable in %sinheritance007.php on line 9
|
||||
|
|
|
@ -16,4 +16,4 @@ class UserGateway_MySql implements UserGateway {
|
|||
}
|
||||
}
|
||||
--EXPECTF--
|
||||
Fatal error: Declaration of UserGateway_MySql::find($id) must be compatible with UserGateway::find($id): User in %s on line 9
|
||||
Fatal error: Declaration of UserGateway_MySql::find($id) must be compatible with UserGateway::find($id): User in %s on line 11
|
||||
|
|
|
@ -639,7 +639,10 @@ static void do_inheritance_check_on_method(zend_function *child, zend_function *
|
|||
error_level = E_WARNING;
|
||||
error_verb = "should";
|
||||
}
|
||||
zend_error(error_level, "Declaration of %s %s be compatible with %s", ZSTR_VAL(child_prototype), error_verb, ZSTR_VAL(method_prototype));
|
||||
zend_error_at(error_level, NULL,
|
||||
child->common.type == ZEND_USER_FUNCTION ? child->op_array.line_start : 0,
|
||||
"Declaration of %s %s be compatible with %s",
|
||||
ZSTR_VAL(child_prototype), error_verb, ZSTR_VAL(method_prototype));
|
||||
zend_string_efree(child_prototype);
|
||||
zend_string_efree(method_prototype);
|
||||
}
|
||||
|
|
|
@ -12,4 +12,4 @@ opcache.preload={PWD}/preload_inheritance_error_ind.inc
|
|||
echo "Foobar\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
Fatal error: Declaration of B::foo($bar) must be compatible with A::foo() in %spreload_inheritance_error.inc on line 7
|
||||
Fatal error: Declaration of B::foo($bar) must be compatible with A::foo() in %spreload_inheritance_error.inc on line 8
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue