diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2019-03-27 12:42:35 +0100 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2019-03-27 12:42:35 +0100 |
commit | 251f293cb7e6fa603885e912e455725efe4cd94e (patch) | |
tree | 9a47b7c353be68effec0d5817ea593b2f545fe50 /Zend | |
parent | fd5d6597790ccc412b7781ee344a03affc5aa2a5 (diff) | |
download | php-git-251f293cb7e6fa603885e912e455725efe4cd94e.tar.gz |
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.
Diffstat (limited to 'Zend')
-rw-r--r-- | Zend/tests/bug62358.phpt | 2 | ||||
-rw-r--r-- | Zend/tests/bug64988.phpt | 2 | ||||
-rw-r--r-- | Zend/tests/bug71428.1.phpt | 2 | ||||
-rw-r--r-- | Zend/tests/object_types/missing_return_type_inheritance_in_class.phpt | 2 | ||||
-rw-r--r-- | Zend/tests/return_types/008.phpt | 2 | ||||
-rw-r--r-- | Zend/tests/return_types/031.phpt | 2 | ||||
-rw-r--r-- | Zend/tests/return_types/generators003.phpt | 2 | ||||
-rw-r--r-- | Zend/tests/return_types/inheritance005.phpt | 2 | ||||
-rw-r--r-- | Zend/tests/return_types/inheritance006.phpt | 2 | ||||
-rw-r--r-- | Zend/tests/return_types/inheritance007.phpt | 2 | ||||
-rw-r--r-- | Zend/tests/return_types/rfc004.phpt | 2 | ||||
-rw-r--r-- | Zend/zend_inheritance.c | 5 |
12 files changed, 15 insertions, 12 deletions
diff --git a/Zend/tests/bug62358.phpt b/Zend/tests/bug62358.phpt index 97381c3403..d10b42eaf3 100644 --- a/Zend/tests/bug62358.phpt +++ b/Zend/tests/bug62358.phpt @@ -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 diff --git a/Zend/tests/bug64988.phpt b/Zend/tests/bug64988.phpt index 971c864d65..671d69de3b 100644 --- a/Zend/tests/bug64988.phpt +++ b/Zend/tests/bug64988.phpt @@ -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 diff --git a/Zend/tests/bug71428.1.phpt b/Zend/tests/bug71428.1.phpt index 2e9a52d3d0..490fc30070 100644 --- a/Zend/tests/bug71428.1.phpt +++ b/Zend/tests/bug71428.1.phpt @@ -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 diff --git a/Zend/tests/object_types/missing_return_type_inheritance_in_class.phpt b/Zend/tests/object_types/missing_return_type_inheritance_in_class.phpt index 023ae58634..0938b24d0a 100644 --- a/Zend/tests/object_types/missing_return_type_inheritance_in_class.phpt +++ b/Zend/tests/object_types/missing_return_type_inheritance_in_class.phpt @@ -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 diff --git a/Zend/tests/return_types/008.phpt b/Zend/tests/return_types/008.phpt index f2e01299de..a178607feb 100644 --- a/Zend/tests/return_types/008.phpt +++ b/Zend/tests/return_types/008.phpt @@ -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 diff --git a/Zend/tests/return_types/031.phpt b/Zend/tests/return_types/031.phpt index 6d0b71b23b..c41490fd09 100644 --- a/Zend/tests/return_types/031.phpt +++ b/Zend/tests/return_types/031.phpt @@ -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 diff --git a/Zend/tests/return_types/generators003.phpt b/Zend/tests/return_types/generators003.phpt index 5502318e98..489ef895a7 100644 --- a/Zend/tests/return_types/generators003.phpt +++ b/Zend/tests/return_types/generators003.phpt @@ -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 diff --git a/Zend/tests/return_types/inheritance005.phpt b/Zend/tests/return_types/inheritance005.phpt index 7415a72b9f..6d8dfc8da9 100644 --- a/Zend/tests/return_types/inheritance005.phpt +++ b/Zend/tests/return_types/inheritance005.phpt @@ -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 diff --git a/Zend/tests/return_types/inheritance006.phpt b/Zend/tests/return_types/inheritance006.phpt index 7d4bcbe57b..65cb1d2f72 100644 --- a/Zend/tests/return_types/inheritance006.phpt +++ b/Zend/tests/return_types/inheritance006.phpt @@ -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 diff --git a/Zend/tests/return_types/inheritance007.phpt b/Zend/tests/return_types/inheritance007.phpt index af1738f807..d04ef71b1c 100644 --- a/Zend/tests/return_types/inheritance007.phpt +++ b/Zend/tests/return_types/inheritance007.phpt @@ -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 diff --git a/Zend/tests/return_types/rfc004.phpt b/Zend/tests/return_types/rfc004.phpt index ed40e41b09..189d0553c6 100644 --- a/Zend/tests/return_types/rfc004.phpt +++ b/Zend/tests/return_types/rfc004.phpt @@ -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 diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c index 1da300f68f..f7cb37e2df 100644 --- a/Zend/zend_inheritance.c +++ b/Zend/zend_inheritance.c @@ -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); } |