Skip to content

Commit 214943d

Browse files
committed
Always generate fatal error for LSP failures
1 parent 6d71d98 commit 214943d

40 files changed

+136
-169
lines changed

Zend/tests/argument_restriction_001.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ class Sub extends Base {
1313
}
1414
?>
1515
--EXPECTF--
16-
Warning: Declaration of & Sub::test() should be compatible with & Base::test($foo, array $bar, $option = NULL, $extra = 'llllllllll...') in %sargument_restriction_001.php on line %d
16+
Fatal error: Declaration of & Sub::test() must be compatible with & Base::test($foo, array $bar, $option = NULL, $extra = 'llllllllll...') in %sargument_restriction_001.php on line %d

Zend/tests/argument_restriction_002.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ class Sub extends Base {
1313
}
1414
?>
1515
--EXPECTF--
16-
Warning: Declaration of Sub::test($foo, array &$bar) should be compatible with Base::test($foo, array &$bar, $option = NULL, $extra = 3.1415926535898) in %sargument_restriction_002.php on line %d
16+
Fatal error: Declaration of Sub::test($foo, array &$bar) must be compatible with Base::test($foo, array &$bar, $option = NULL, $extra = 3.1415926535898) in %sargument_restriction_002.php on line %d

Zend/tests/argument_restriction_003.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ class Sub extends Base {
1616
}
1717
?>
1818
--EXPECTF--
19-
Warning: Declaration of Sub::test() should be compatible with Base::test(Foo $foo, array $bar, $option = NULL, $extra = 'llllllllll...') in %sargument_restriction_003.php on line %d
19+
Fatal error: Declaration of Sub::test() must be compatible with Base::test(Foo $foo, array $bar, $option = NULL, $extra = 'llllllllll...') in %sargument_restriction_003.php on line %d

Zend/tests/argument_restriction_006.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ class Sub extends Base {
1313
}
1414
?>
1515
--EXPECTF--
16-
Warning: Declaration of Sub::test($foo, $extra) should be compatible with Base::test($foo, $extra = Array) in %sargument_restriction_006.php on line %d
16+
Fatal error: Declaration of Sub::test($foo, $extra) must be compatible with Base::test($foo, $extra = Array) in %sargument_restriction_006.php on line %d

Zend/tests/bug47981.phpt

Lines changed: 0 additions & 17 deletions
This file was deleted.

Zend/tests/bug60573.phpt

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -53,32 +53,6 @@ public function setSelf(self $s) { }
5353

5454
}
5555

56-
class Foo5 extends Base {
57-
58-
public function setSelf(parent $s) { }
59-
60-
}
61-
62-
class Bar5 extends Foo5 {
63-
64-
public function setSelf(parent $s) { }
65-
66-
}
67-
68-
abstract class Foo6 extends Base {
69-
70-
abstract public function setSelf(parent $s);
71-
72-
}
73-
74-
class Bar6 extends Foo6 {
75-
76-
public function setSelf(Foo6 $s) { }
77-
78-
}
56+
?>
7957
--EXPECTF--
80-
Warning: Declaration of Bar4::setSelf(Bar4 $s) should be compatible with Foo4::setSelf(Foo4 $s) in %sbug60573.php on line %d
81-
82-
Warning: Declaration of Bar5::setSelf(Foo5 $s) should be compatible with Foo5::setSelf(Base $s) in %sbug60573.php on line %d
83-
84-
Fatal error: Declaration of Bar6::setSelf(Foo6 $s) must be compatible with Foo6::setSelf(Base $s) in %sbug60573.php on line %d
58+
Fatal error: Declaration of Bar4::setSelf(Bar4 $s) must be compatible with Foo4::setSelf(Foo4 $s) in /home/nikic/php-src/Zend/tests/bug60573.php on line 49

Zend/tests/bug60573_2.phpt

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
--TEST--
2+
Bug #60573 (type hinting with "self" keyword causes weird errors) -- variation 2
3+
--FILE--
4+
<?php
5+
class Foo1 {
6+
7+
public function setSelf(self $s) { }
8+
9+
}
10+
11+
class Bar1 extends Foo1 {
12+
13+
public function setSelf(parent $s) { }
14+
15+
}
16+
17+
class Foo2 {
18+
19+
public function setSelf(Foo2 $s) { }
20+
21+
}
22+
23+
class Bar2 extends Foo2 {
24+
25+
public function setSelf(parent $s) { }
26+
27+
}
28+
29+
class Base {
30+
}
31+
32+
class Foo3 extends Base{
33+
34+
public function setSelf(parent $s) { }
35+
36+
}
37+
38+
class Bar3 extends Foo3 {
39+
40+
public function setSelf(Base $s) { }
41+
42+
}
43+
44+
class Foo4 {
45+
46+
public function setSelf(self $s) { }
47+
48+
}
49+
50+
class Foo5 extends Base {
51+
52+
public function setSelf(parent $s) { }
53+
54+
}
55+
56+
class Bar5 extends Foo5 {
57+
58+
public function setSelf(parent $s) { }
59+
60+
}
61+
62+
?>
63+
--EXPECTF--
64+
Fatal error: Declaration of Bar5::setSelf(Foo5 $s) must be compatible with Foo5::setSelf(Base $s) in %sbug60573_2.php on line %d

Zend/tests/bug63336.phpt

Lines changed: 0 additions & 22 deletions
This file was deleted.

Zend/tests/bug64988.phpt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,4 @@ $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 17
30-
okey
29+
Fatal error: Declaration of Smooth1::insert(array $data) must be compatible with Noisy1::insert(array $data, $option1 = NULL) in %sbug64988.php on line 17

Zend/tests/bug65322.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ set_error_handler(function($_, $msg, $file) {
1515

1616
/* This is just a particular example of a non-fatal compile-time error
1717
* If this breaks in future, just find another example and use it instead */
18-
eval('class A { function test() { } } class B extends A { function test($a) { } }');
18+
eval('class A { private function __invoke() { } }');
1919

2020
?>
2121
--EXPECTF--
22-
string(62) "Declaration of B::test($a) should be compatible with A::test()"
22+
string(76) "The magic method __invoke() must have public visibility and cannot be static"
2323
string(%d) "%s(%d) : eval()'d code"
2424
string(1) "X"

0 commit comments

Comments
 (0)