Skip to content

Commit a83c0b0

Browse files
committed
Correct lineno of compile-time variance LSP error
1 parent f674035 commit a83c0b0

File tree

8 files changed

+11
-8
lines changed

8 files changed

+11
-8
lines changed

Zend/tests/bug62358.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ class B extends A {
2323
}
2424
?>
2525
--EXPECTF--
26-
Fatal error: Declaration of B::foo($var) must be compatible with A::foo() in %sbug62358.php on line 17
26+
Fatal error: Declaration of B::foo($var) must be compatible with A::foo() in %sbug62358.php on line 18

Zend/tests/bug64988.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@ $o = new Smooth1();
2626
echo "okey";
2727
?>
2828
--EXPECTF--
29-
Warning: Declaration of Smooth1::insert(array $data) should be compatible with Noisy1::insert(array $data, $option1 = NULL) in %sbug64988.php on line 20
29+
Warning: Declaration of Smooth1::insert(array $data) should be compatible with Noisy1::insert(array $data, $option1 = NULL) in %sbug64988.php on line 17
3030
okey

Zend/tests/bug71428.1.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ class B extends A {
99
public function m(array $a = []) {}
1010
}
1111
--EXPECTF--
12-
Warning: Declaration of B::m(array $a = Array) should be compatible with A::m(?array $a = NULL) in %sbug71428.1.php on line 7
12+
Warning: Declaration of B::m(array $a = Array) should be compatible with A::m(?array $a = NULL) in %sbug71428.1.php on line 6

Zend/tests/object_types/missing_return_type_inheritance_in_class.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ class Two extends One {
1111
public function a() {}
1212
}
1313
--EXPECTF--
14-
Fatal error: Declaration of Two::a() must be compatible with One::a(): object in %s on line 9
14+
Fatal error: Declaration of Two::a() must be compatible with One::a(): object in %s on line 8

Zend/tests/return_types/031.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ class B extends A {
1111
?>
1212
DONE
1313
--EXPECTF--
14-
Fatal error: Declaration of B::foo(): ?int must be compatible with A::foo(): int in %s031.php on line 7
14+
Fatal error: Declaration of B::foo(): ?int must be compatible with A::foo(): int in %s031.php on line 6

Zend/tests/return_types/rfc004.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ class UserGateway_MySql implements UserGateway {
1616
}
1717
}
1818
--EXPECTF--
19-
Fatal error: Declaration of UserGateway_MySql::find($id) must be compatible with UserGateway::find($id): User in %s on line 9
19+
Fatal error: Declaration of UserGateway_MySql::find($id) must be compatible with UserGateway::find($id): User in %s on line 11

Zend/tests/type_declarations/variance/parent_in_class.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,6 @@ class B4 extends A4 {
4040

4141
?>
4242
--EXPECTF--
43-
Warning: Declaration of B4::method(A4 $x) should be compatible with A4::method(P4 $x) in %s on line 36
43+
Warning: Declaration of B4::method(A4 $x) should be compatible with A4::method(P4 $x) in %s on line 35
4444

4545
Warning: Declaration of B::method(A $x) should be compatible with A::method(parent $x) in %s on line 8

Zend/zend_inheritance.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,10 @@ static void do_inheritance_check_on_method(zend_function *child, zend_function *
717717
error_level = E_WARNING;
718718
error_verb = "should";
719719
}
720-
zend_error(error_level, "Declaration of %s %s be compatible with %s", ZSTR_VAL(child_prototype), error_verb, ZSTR_VAL(method_prototype));
720+
zend_error_at(error_level, NULL,
721+
child->type == ZEND_USER_FUNCTION ? child->op_array.line_start : 0,
722+
"Declaration of %s %s be compatible with %s",
723+
ZSTR_VAL(child_prototype), error_verb, ZSTR_VAL(method_prototype));
721724
zend_string_efree(child_prototype);
722725
zend_string_efree(method_prototype);
723726
}

0 commit comments

Comments
 (0)