]> granicus.if.org Git - php/commitdiff
Make line numbers for inheritance errors more precise
authorNikita Popov <nikita.ppv@gmail.com>
Wed, 27 Mar 2019 11:42:35 +0000 (12:42 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Wed, 27 Mar 2019 11:42:35 +0000 (12:42 +0100)
Use the line of the conflicting child method, rather than either the
first or last line of the class.

13 files changed:
Zend/tests/bug62358.phpt
Zend/tests/bug64988.phpt
Zend/tests/bug71428.1.phpt
Zend/tests/object_types/missing_return_type_inheritance_in_class.phpt
Zend/tests/return_types/008.phpt
Zend/tests/return_types/031.phpt
Zend/tests/return_types/generators003.phpt
Zend/tests/return_types/inheritance005.phpt
Zend/tests/return_types/inheritance006.phpt
Zend/tests/return_types/inheritance007.phpt
Zend/tests/return_types/rfc004.phpt
Zend/zend_inheritance.c
ext/opcache/tests/preload_006.phpt

index 97381c3403c26043ed39f5c4bc3c5a0e33018889..d10b42eaf3d8694fddd2cba52662933c08da6608 100644 (file)
@@ -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
index 971c864d6541de035c8cad4f99065df1646627aa..671d69de3b1e18a2d540369e48027e71b1ed4dfd 100644 (file)
@@ -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
index 2e9a52d3d0240cfba90c1473e73480ce0578257c..490fc30070fe95000413dd8a887735974353b19c 100644 (file)
@@ -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
index 023ae58634050cc93e90fef468d2fc84621ec004..0938b24d0a2acc8c4e124221a6beb6340d210bfa 100644 (file)
@@ -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
index f2e01299de2fbcdd433424ad7dc21e7c79bb16f5..a178607febc79efdb5619b6e9a294c9689ac5832 100644 (file)
@@ -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
index 6d0b71b23ba12f006031ad11d945470db2f1bef9..c41490fd09cc62f49c8f7667f310c3db94389399 100644 (file)
@@ -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
index 5502318e982a6e1755490114ae62d67749ad3987..489ef895a7391218b0116d1064fa5844ba27ebd7 100644 (file)
@@ -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
index 7415a72b9f59163284d05fb499400e7f8f791b59..6d8dfc8da9c8bd56c23dd39898d157fcd40d4707 100644 (file)
@@ -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
index 7d4bcbe57b00826ed0d5fefd37fbcfea9a08643e..65cb1d2f7229a680c667a0eaf452355593b39135 100644 (file)
@@ -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
index af1738f80769241e316052bdd8439d731dbeb0a1..d04ef71b1c21ea377b81446a543dc0f99230eb40 100644 (file)
@@ -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
index ed40e41b09f2101f614307a43b30fc4803c089b0..189d0553c69522770d23aaada2443fade1fca9a6 100644 (file)
@@ -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
index 1da300f68fe882d6e6f6c025093e7097a662f877..f7cb37e2dfd01f2239b74181dce9604eea471532 100644 (file)
@@ -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);
                        }
index bbecfcf9473c7be02f30c3427e6aff9652f5b0a3..17d792ecd12742e5d61c520102f143ae0eac9638 100644 (file)
@@ -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