com php-src: Make line numbers for inheritance errors more precise: 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/re turn_types/008.phpt Zend/tests/return_types/0 31.phpt
Zend/tests/return_types/generators003 .phpt Zend/tests/return_types/inheritance005.phpt Zend/tests/return_types/inheritance006.phpt Zend
/tests/return_types/inheritance007
| From: | Nikita Popov | Date: | Wed, 27 Mar 2019 11:42:35 +0000 |
| Subject: | com php-src: Make line numbers for inheritance errors more precise: 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/re turn_types/008.phpt Zend/tests/return_types/0 31.phpt Zend/tests/return_types/generators003 .phpt Zend/tests/return_types/inheritance005.phpt Zend/tests/return_types/inheritance006.phpt Zend /tests/return_types/inheritance007 |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-105366@lists.php.net to get a copy of this message | ||
Commit: 251f293cb7e6fa603885e912e455725efe4cd94e
Author: Nikita Popov <nikita.ppv@gmail.com> Wed, 27 Mar 2019 12:42:35 +0100
Parents: fd5d6597790ccc412b7781ee344a03affc5aa2a5
Branches: PHP-7.4 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=251f293cb7e6fa603885e912e455725efe4cd94e
Log:
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.
Changed paths:
M Zend/tests/bug62358.phpt
M Zend/tests/bug64988.phpt
M Zend/tests/bug71428.1.phpt
M Zend/tests/object_types/missing_return_type_inheritance_in_class.phpt
M Zend/tests/return_types/008.phpt
M Zend/tests/return_types/031.phpt
M Zend/tests/return_types/generators003.phpt
M Zend/tests/return_types/inheritance005.phpt
M Zend/tests/return_types/inheritance006.phpt
M Zend/tests/return_types/inheritance007.phpt
M Zend/tests/return_types/rfc004.phpt
M Zend/zend_inheritance.c
M ext/opcache/tests/preload_006.phpt
Diff:
diff --git a/Zend/tests/bug62358.phpt b/Zend/tests/bug62358.phpt
index 97381c3..d10b42e 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 971c864..671d69d 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 2e9a52d..490fc300 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 023ae58..0938b24 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 f2e0129..a178607 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 6d0b71b..c41490f 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 5502318..489ef89 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 7415a72..6d8dfc8 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 7d4bcbe..65cb1d2 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 af1738f..d04ef71 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 ed40e41..189d055 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 1da300f..f7cb37e 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);
}
diff --git a/ext/opcache/tests/preload_006.phpt b/ext/opcache/tests/preload_006.phpt
index bbecfcf..17d792e 100644
--- a/ext/opcache/tests/preload_006.phpt
+++ b/ext/opcache/tests/preload_006.phpt
@@ -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