Skip to content

Always generate fatal error for LSP failures #4000

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Zend/tests/argument_restriction_001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ class Sub extends Base {
}
?>
--EXPECTF--
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
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
2 changes: 1 addition & 1 deletion Zend/tests/argument_restriction_002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ class Sub extends Base {
}
?>
--EXPECTF--
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
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
2 changes: 1 addition & 1 deletion Zend/tests/argument_restriction_003.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ class Sub extends Base {
}
?>
--EXPECTF--
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
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
2 changes: 1 addition & 1 deletion Zend/tests/argument_restriction_006.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ class Sub extends Base {
}
?>
--EXPECTF--
Warning: Declaration of Sub::test($foo, $extra) should be compatible with Base::test($foo, $extra = Array) in %sargument_restriction_006.php on line %d
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
17 changes: 0 additions & 17 deletions Zend/tests/bug47981.phpt

This file was deleted.

30 changes: 2 additions & 28 deletions Zend/tests/bug60573.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -53,32 +53,6 @@ public function setSelf(self $s) { }

}

class Foo5 extends Base {

public function setSelf(parent $s) { }

}

class Bar5 extends Foo5 {

public function setSelf(parent $s) { }

}

abstract class Foo6 extends Base {

abstract public function setSelf(parent $s);

}

class Bar6 extends Foo6 {

public function setSelf(Foo6 $s) { }

}
?>
--EXPECTF--
Warning: Declaration of Bar4::setSelf(Bar4 $s) should be compatible with Foo4::setSelf(Foo4 $s) in %sbug60573.php on line %d

Warning: Declaration of Bar5::setSelf(Foo5 $s) should be compatible with Foo5::setSelf(Base $s) in %sbug60573.php on line %d

Fatal error: Declaration of Bar6::setSelf(Foo6 $s) must be compatible with Foo6::setSelf(Base $s) in %sbug60573.php on line %d
Fatal error: Declaration of Bar4::setSelf(Bar4 $s) must be compatible with Foo4::setSelf(Foo4 $s) in %s on line %d
64 changes: 64 additions & 0 deletions Zend/tests/bug60573_2.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
--TEST--
Bug #60573 (type hinting with "self" keyword causes weird errors) -- variation 2
--FILE--
<?php
class Foo1 {

public function setSelf(self $s) { }

}

class Bar1 extends Foo1 {

public function setSelf(parent $s) { }

}

class Foo2 {

public function setSelf(Foo2 $s) { }

}

class Bar2 extends Foo2 {

public function setSelf(parent $s) { }

}

class Base {
}

class Foo3 extends Base{

public function setSelf(parent $s) { }

}

class Bar3 extends Foo3 {

public function setSelf(Base $s) { }

}

class Foo4 {

public function setSelf(self $s) { }

}

class Foo5 extends Base {

public function setSelf(parent $s) { }

}

class Bar5 extends Foo5 {

public function setSelf(parent $s) { }

}

?>
--EXPECTF--
Fatal error: Declaration of Bar5::setSelf(Foo5 $s) must be compatible with Foo5::setSelf(Base $s) in %sbug60573_2.php on line %d
22 changes: 0 additions & 22 deletions Zend/tests/bug63336.phpt

This file was deleted.

3 changes: 1 addition & 2 deletions Zend/tests/bug64988.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,4 @@ $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 17
okey
Fatal error: Declaration of Smooth1::insert(array $data) must be compatible with Noisy1::insert(array $data, $option1 = NULL) in %sbug64988.php on line 17
4 changes: 2 additions & 2 deletions Zend/tests/bug65322.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ set_error_handler(function($_, $msg, $file) {

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

?>
--EXPECTF--
string(62) "Declaration of B::test($a) should be compatible with A::test()"
string(76) "The magic method __invoke() must have public visibility and cannot be static"
string(%d) "%s(%d) : eval()'d code"
string(1) "X"
4 changes: 3 additions & 1 deletion Zend/tests/bug67436/b.inc
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<?php

class b extends a {
public function test() {
private function __invoke() {}

public function test($arg = c::TESTCONSTANT) {
echo __METHOD__ . "()\n";
parent::test();
}
Expand Down
4 changes: 4 additions & 0 deletions Zend/tests/bug67436/bug67436.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
bug67436: Autoloader isn't called if user defined error handler is present
--INI--
error_reporting=-1
--SKIPIF--
<?php if (extension_loaded('Zend OPCache')) die('skip Opcache overrides error handler'); ?>
--FILE--
<?php

Expand All @@ -12,12 +14,14 @@ spl_autoload_register(function($classname) {
});

set_error_handler(function ($errno, $errstr, $errfile, $errline) {
var_dump($errstr);
}, error_reporting());

a::staticTest();

$b = new b();
$b->test();
--EXPECT--
string(76) "The magic method __invoke() must have public visibility and cannot be static"
b::test()
a::test(c::TESTCONSTANT)
2 changes: 1 addition & 1 deletion Zend/tests/bug67436/bug67436_nohandler.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ a::staticTest();
$b = new b();
$b->test();
--EXPECTF--
Warning: Declaration of b::test() should be compatible with a::test($arg = c::TESTCONSTANT) in %s%ebug67436%eb.inc on line %d
Warning: The magic method __invoke() must have public visibility and cannot be static in %s on line %d
b::test()
a::test(c::TESTCONSTANT)
2 changes: 1 addition & 1 deletion Zend/tests/bug70957.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ class B extends Foo
}
?>
--EXPECTF--
Warning: Declaration of T::bar() should be compatible with Foo::bar($a = 'Foo') in %sbug70957.php on line %d
Fatal error: Declaration of T::bar() must be compatible with Foo::bar($a = 'Foo') in %sbug70957.php on line %d
2 changes: 1 addition & 1 deletion Zend/tests/bug71428.1.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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 6
Fatal error: Declaration of B::m(array $a = Array) must be compatible with A::m(?array $a = NULL) in %sbug71428.1.php on line 6
2 changes: 1 addition & 1 deletion Zend/tests/bug71428.3.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ class B { public function m(A $a = NULL, $n) { echo "B.m";} };
class C extends B { public function m(A $a , $n) { echo "C.m";} };
?>
--EXPECTF--
Warning: Declaration of C::m(A $a, $n) should be compatible with B::m(?A $a, $n) in %sbug71428.3.php on line 4
Fatal error: Declaration of C::m(A $a, $n) must be compatible with B::m(?A $a, $n) in %sbug71428.3.php on line 4
4 changes: 2 additions & 2 deletions Zend/tests/errmsg_045.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ set_error_handler(function($_, $msg, $file) {

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

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

Notice: Undefined variable: undefined in %s on line %d
3 changes: 1 addition & 2 deletions Zend/tests/objects_002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,4 @@ class test3 extends test {
echo "Done\n";
?>
--EXPECTF--
Warning: Declaration of test3::foo($arg) should be compatible with test::foo() in %s on line %d
Done
Fatal error: Declaration of test3::foo($arg) must be compatible with test::foo() in %s on line %d
3 changes: 1 addition & 2 deletions Zend/tests/objects_003.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,4 @@ class test3 extends test {
echo "Done\n";
?>
--EXPECTF--
Warning: Declaration of test3::foo($arg, $arg2) should be compatible with test::foo($arg) in %s on line %d
Done
Fatal error: Declaration of test3::foo($arg, $arg2) must be compatible with test::foo($arg) in %s on line %d
3 changes: 1 addition & 2 deletions Zend/tests/objects_004.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,4 @@ class test3 extends test {
echo "Done\n";
?>
--EXPECTF--
Warning: Declaration of test3::foo(&$arg) should be compatible with test::foo($arg) in %s on line %d
Done
Fatal error: Declaration of test3::foo(&$arg) must be compatible with test::foo($arg) in %s on line %d
3 changes: 1 addition & 2 deletions Zend/tests/objects_005.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,4 @@ class test3 extends test {
echo "Done\n";
?>
--EXPECTF--
Warning: Declaration of test3::foo() should be compatible with & test::foo() in %s on line %d
Done
Fatal error: Declaration of test3::foo() must be compatible with & test::foo() in %s on line %d
3 changes: 1 addition & 2 deletions Zend/tests/objects_006.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,4 @@ class test3 extends test {
echo "Done\n";
?>
--EXPECTF--
Warning: Declaration of test3::foo($arg, $arg2) should be compatible with test::foo($arg, $arg2 = NULL) in %s on line %d
Done
Fatal error: Declaration of test3::foo($arg, $arg2) must be compatible with test::foo($arg, $arg2 = NULL) in %s on line %d
3 changes: 1 addition & 2 deletions Zend/tests/objects_007.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,4 @@ class test3 extends test {
echo "Done\n";
?>
--EXPECTF--
Warning: Declaration of test3::foo($arg, &$arg2) should be compatible with test::foo($arg, &$arg2 = NULL) in %s on line %d
Done
Fatal error: Declaration of test3::foo($arg, &$arg2) must be compatible with test::foo($arg, &$arg2 = NULL) in %s on line %d
3 changes: 1 addition & 2 deletions Zend/tests/objects_008.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,4 @@ class test3 extends test {
echo "Done\n";
?>
--EXPECTF--
Warning: Declaration of test3::foo(Test3 $arg) should be compatible with test::foo(Test $arg) in %s on line %d
Done
Fatal error: Declaration of test3::foo(Test3 $arg) must be compatible with test::foo(Test $arg) in %s on line %d
10 changes: 1 addition & 9 deletions Zend/tests/return_types/bug71978.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@
Bug #71978 (Existence of return type hint affects other compatibility rules)
--FILE--
<?php
class A {
function foo(int $a) {}
}
class B extends A {
function foo(string $a) {}
}
class A1 {
function foo(int $a): int {}
}
Expand All @@ -16,6 +10,4 @@ class B1 extends A1 {
}
?>
--EXPECTF--
Warning: Declaration of B::foo(string $a) should be compatible with A::foo(int $a) in %s on line %d

Warning: Declaration of B1::foo(string $a): int should be compatible with A1::foo(int $a): int in %s on line %d
Fatal error: Declaration of B1::foo(string $a): int must be compatible with A1::foo(int $a): int in %s on line %d
2 changes: 1 addition & 1 deletion Zend/tests/type_declarations/iterable_004.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ class Bar extends Foo {

?>
--EXPECTF--
Warning: Declaration of Bar::testScalar(iterable $iterable) should be compatible with Foo::testScalar(int $int) in %s on line %d
Fatal error: Declaration of Bar::testScalar(iterable $iterable) must be compatible with Foo::testScalar(int $int) in %s on line %d
16 changes: 2 additions & 14 deletions Zend/tests/type_declarations/parameter_type_variance.phpt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--TEST--
Parameter variance with no type
Parameter variance with no type (class)
--FILE--
<?php

Expand All @@ -8,27 +8,15 @@ class Foo {
function testBothClass(Foo $foo) {}
function testChildClass($foo) {}
function testNoneClass($foo) {}

function testParentBuiltin(int $foo) {}
function testBothBuiltin(int $foo) {}
function testChildBuiltin($foo) {}
function testNoneBuiltin($foo) {}
}

class Bar extends Foo {
function testParentClass($foo) {}
function testBothClass(Foo $foo) {}
function testChildClass(Foo $foo) {}
function testNoneClass($foo) {}

function testParentBuiltin($foo) {}
function testBothBuiltin(int $foo) {}
function testChildBuiltin(int $foo) {}
function testNoneBuiltin($foo) {}
}

?>
--EXPECTF--
Warning: Declaration of Bar::testChildClass(Foo $foo) should be compatible with Foo::testChildClass($foo) in %s on line %d

Warning: Declaration of Bar::testChildBuiltin(int $foo) should be compatible with Foo::testChildBuiltin($foo) in %s on line %d
Fatal error: Declaration of Bar::testChildClass(Foo $foo) must be compatible with Foo::testChildClass($foo) in %s on line %d
22 changes: 22 additions & 0 deletions Zend/tests/type_declarations/parameter_type_variance_2.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
--TEST--
Parameter variance with no type (builtin)
--FILE--
<?php

class Foo {
function testParentBuiltin(int $foo) {}
function testBothBuiltin(int $foo) {}
function testChildBuiltin($foo) {}
function testNoneBuiltin($foo) {}
}

class Bar extends Foo {
function testParentBuiltin($foo) {}
function testBothBuiltin(int $foo) {}
function testChildBuiltin(int $foo) {}
function testNoneBuiltin($foo) {}
}

?>
--EXPECTF--
Fatal error: Declaration of Bar::testChildBuiltin(int $foo) must be compatible with Foo::testChildBuiltin($foo) in %s on line %d
Loading