-
Notifications
You must be signed in to change notification settings - Fork 7.7k
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
Bind trait props/consts before parent class #15878
base: master
Are you sure you want to change the base?
Changes from all commits
76f7e03
172515b
691c93f
eb8ba60
10a38b7
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,44 @@ | ||
--TEST-- | ||
GH-16198: Incorrect trait constant conflict when declared via trait | ||
--FILE-- | ||
<?php | ||
|
||
trait T1 | ||
{ | ||
final public const string C1 = 'T1'; | ||
} | ||
|
||
interface I1 | ||
{ | ||
public const ?string C1 = null; | ||
public const ?string C2 = null; | ||
} | ||
|
||
final class O1 implements I1 | ||
{ | ||
final public const string C2 = 'O1'; | ||
} | ||
|
||
final class O2 implements I1 | ||
{ | ||
use T1; | ||
} | ||
|
||
abstract class A1 implements I1 | ||
{ | ||
} | ||
|
||
final class O3 extends A1 | ||
{ | ||
final public const string C2 = 'O3'; | ||
} | ||
|
||
final class O4 extends A1 | ||
{ | ||
use T1; | ||
} | ||
|
||
?> | ||
===DONE=== | ||
--EXPECT-- | ||
===DONE=== |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--TEST-- | ||
GH-16198: Usage of super in cloned trait method | ||
--FILE-- | ||
<?php | ||
|
||
trait T { | ||
public function __destruct() { | ||
parent::__destruct(); | ||
} | ||
} | ||
|
||
class P { | ||
public function __destruct() { | ||
var_dump(__METHOD__); | ||
} | ||
} | ||
|
||
class C extends P { | ||
use T; | ||
} | ||
|
||
$c = new C(); | ||
unset($c); | ||
|
||
?> | ||
--EXPECT-- | ||
string(13) "P::__destruct" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--TEST-- | ||
GH-15753: Overriding readonly properties from traits don't allow assignment from the child | ||
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. The test works fine on unpatched master, but fails on PHP-8.2. Is this a backport? 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. No, this works on |
||
--FILE-- | ||
<?php | ||
|
||
class P { | ||
protected readonly int $prop; | ||
} | ||
|
||
trait T { | ||
protected readonly int $prop; | ||
} | ||
|
||
class C extends P { | ||
use T; | ||
|
||
public function __construct() { | ||
$this->prop = 20; | ||
} | ||
} | ||
|
||
$c = new C(); | ||
var_dump($c); | ||
|
||
?> | ||
--EXPECT-- | ||
object(C)#1 (1) { | ||
["prop":protected]=> | ||
int(20) | ||
} |
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.
This is a behavior change, that may break some PHP code.
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.
Right. This is (IMO) clearly a bug, but it may be better to commit to
master
anyway.