Skip to content
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

Allow reinitialization of a readonly property in __clone since PHP8.3 #3330

Open
wants to merge 2 commits into
base: 1.11.x
Choose a base branch
from

Conversation

takaram
Copy link
Contributor

@takaram takaram commented Aug 17, 2024


public function __clone()
{
$this->foo = 'baz';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to have more tests here:

  1. To verify double assignment is still detected as error (https://3v4l.org/oaLm9)
  2. To verify assignment to something else than $this is detected as error:
	public function __clone()
	{
		$s = new self();
		$s->foo = 'baz';
	}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a test for 2.

For 1., no error is reported on double assignment. This looks not so easy to implement.
I'll take a deeper look...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants