Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix various bugs related to DNF types
- GH-11958: DNF types in trait properties do not get bound properly - GH-11883: Memory leak in zend_type_release() for non-arena allocated DNF types - Internal trait bound to userland class would not be arena allocated - Property DNF types were not properly deep copied during lazy loading Co-authored-by: Ilija Tovilo <ilija.tovilo@me.com> Co-authored-by: ju1ius <jules.bernable@gmail.com>
- Loading branch information
1 parent
0b516ae
commit 02a80c5
Showing
7 changed files
with
113 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
Zend/tests/type_declarations/dnf_types/variance/invalid_invariance1_var.phpt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--TEST-- | ||
Property types must be invariant | ||
--FILE-- | ||
<?php | ||
|
||
interface X {} | ||
interface Y {} | ||
|
||
class A { | ||
public (X&Y&Z)|L $prop; | ||
} | ||
class B extends A { | ||
public (X&Y)|L $prop; | ||
} | ||
|
||
?> | ||
--EXPECTF-- | ||
Fatal error: Type of B::$prop must be (X&Y&Z)|L (as in class A) in %s on line %d |
39 changes: 39 additions & 0 deletions
39
Zend/tests/type_declarations/union_types/internal_trait_use_typed_union.phpt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
--TEST-- | ||
Internal trait used typed property (union type) | ||
--EXTENSIONS-- | ||
zend_test | ||
--FILE-- | ||
<?php | ||
|
||
class C { | ||
use _ZendTestTrait; | ||
} | ||
|
||
$o = new C(); | ||
var_dump($o); | ||
|
||
$prop = new \ReflectionProperty(C::class, 'classUnionProp'); | ||
$union = $prop->getType(); | ||
$types = $union->getTypes(); | ||
var_dump($types, (string)$types[0], (string)$types[1]); | ||
|
||
?> | ||
===DONE=== | ||
--EXPECT-- | ||
object(C)#1 (1) { | ||
["testProp"]=> | ||
NULL | ||
["classUnionProp"]=> | ||
uninitialized(Traversable|Countable) | ||
} | ||
array(2) { | ||
[0]=> | ||
object(ReflectionNamedType)#4 (0) { | ||
} | ||
[1]=> | ||
object(ReflectionNamedType)#5 (0) { | ||
} | ||
} | ||
string(11) "Traversable" | ||
string(9) "Countable" | ||
===DONE=== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.