-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix UPGRADING and #9556 "iterable" alias "array|Traversable" breaks PHP 8.1 code #9558
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--TEST-- | ||
A DNF type which contains object is redundant | ||
--FILE-- | ||
<?php | ||
|
||
interface A {} | ||
interface B {} | ||
|
||
function test(): (A&B)|object {} | ||
|
||
?> | ||
===DONE=== | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ===DONE=== is kinda pointless, since There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That |
||
--EXPECTF-- | ||
Fatal error: Type (A&B)|object contains both object and a class type, which is redundant in %s on line %d |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--TEST-- | ||
A DNF type which contains object is redundant 2 | ||
--FILE-- | ||
<?php | ||
|
||
interface A {} | ||
interface B {} | ||
|
||
function test(): object|(A&B) {} | ||
|
||
?> | ||
===DONE=== | ||
--EXPECTF-- | ||
Fatal error: Type (A&B)|object contains both object and a class type, which is redundant in %s on line %d |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--TEST-- | ||
iterable type with array should be redundant | ||
--FILE-- | ||
<?php | ||
|
||
function bar(): array|iterable|null { | ||
return null; | ||
} | ||
|
||
?> | ||
--EXPECTF-- | ||
Fatal error: Duplicate type array is redundant in %s on line %d |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--TEST-- | ||
iterable type with array should be redundant | ||
--FILE-- | ||
<?php | ||
|
||
function bar(): iterable|array|null { | ||
return null; | ||
} | ||
|
||
?> | ||
--EXPECTF-- | ||
Fatal error: Duplicate type array is redundant in %s on line %d |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--TEST-- | ||
iterable type with second iterable should be redundant | ||
--FILE-- | ||
<?php | ||
|
||
function bar(): iterable|iterable|null { | ||
return null; | ||
} | ||
|
||
?> | ||
--EXPECTF-- | ||
Fatal error: Duplicate type array is redundant in %s on line %d |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--TEST-- | ||
iterable type with object should NOT be redundant 1 | ||
--FILE-- | ||
<?php | ||
|
||
function bar(): iterable|object|null { | ||
return null; | ||
} | ||
|
||
?> | ||
===DONE=== | ||
--EXPECT-- | ||
===DONE=== |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--TEST-- | ||
iterable type with object should NOT be redundant 2 | ||
--FILE-- | ||
<?php | ||
|
||
function bar(): object|iterable|null { | ||
return null; | ||
} | ||
|
||
?> | ||
===DONE=== | ||
--EXPECT-- | ||
===DONE=== |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--TEST-- | ||
iterable type with object and class T should be redundant | ||
--FILE-- | ||
<?php | ||
|
||
function bar(): object|iterable|T|null { | ||
return null; | ||
} | ||
|
||
?> | ||
--EXPECTF-- | ||
Fatal error: Type Traversable|T|object|array|null contains both object and a class type, which is redundant in %s on line %d |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--TEST-- | ||
iterable type with object and class T should be redundant | ||
--FILE-- | ||
<?php | ||
|
||
function bar(): iterable|object|T|null { | ||
return null; | ||
} | ||
|
||
?> | ||
--EXPECTF-- | ||
Fatal error: Type Traversable|T|object|array|null contains both object and a class type, which is redundant in %s on line %d |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--TEST-- | ||
iterable type with object and class T should be redundant | ||
--FILE-- | ||
<?php | ||
|
||
function bar(): T|object|iterable|null { | ||
return null; | ||
} | ||
|
||
?> | ||
--EXPECTF-- | ||
Fatal error: Type T|Traversable|object|array|null contains both object and a class type, which is redundant in %s on line %d |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--TEST-- | ||
iterable type with object and class T should be redundant | ||
--FILE-- | ||
<?php | ||
|
||
function bar(): T|iterable|object|null { | ||
return null; | ||
} | ||
|
||
?> | ||
--EXPECTF-- | ||
Fatal error: Type T|Traversable|object|array|null contains both object and a class type, which is redundant in %s on line %d |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--TEST-- | ||
iterable type with object should be allowed in variance checks | ||
--FILE-- | ||
<?php | ||
|
||
class A { | ||
public object|iterable $x; | ||
public object|array $y; | ||
} | ||
class B extends A { | ||
public object|array $x; | ||
public object|iterable $y; | ||
} | ||
|
||
?> | ||
===DONE=== | ||
--EXPECT-- | ||
===DONE=== |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--TEST-- | ||
Using both object and a class type 2 | ||
--FILE-- | ||
<?php | ||
|
||
function test(): Test|object { | ||
} | ||
|
||
?> | ||
--EXPECTF-- | ||
Fatal error: Type Test|object contains both object and a class type, which is redundant in %s on line %d |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--TEST-- | ||
object and static are redundant 2 | ||
--FILE-- | ||
<?php | ||
|
||
class Test { | ||
public function foo(): object|static {} | ||
} | ||
|
||
?> | ||
--EXPECTF-- | ||
Fatal error: Type static|object contains both object and a class type, which is redundant in %s on line %d |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated?