Skip to content

Add rector to migrate __sleep() to __serialize() - #7212

Merged
TomasVotruba merged 11 commits into
rectorphp:mainfrom
arshidkv12:__sleep__
Sep 11, 2025
Merged

Add rector to migrate __sleep() to __serialize()#7212
TomasVotruba merged 11 commits into
rectorphp:mainfrom
arshidkv12:__sleep__

Conversation

@arshidkv12

Copy link
Copy Markdown
Contributor

Comment threadrules/Php85/Rector/ClassMethod/SleepToSerializeRector.php
Comment threadrules/Php85/Rector/ClassMethod/SleepToSerializeRector.php Outdated
Comment threadrules/Php85/Rector/ClassMethod/SleepToSerializeRector.php
Comment threadrules/Php85/Rector/ClassMethod/SleepToSerializeRector.php Outdated
Comment threadrules/Php85/Rector/ClassMethod/SleepToSerializeRector.php

@samsonasiksamsonasik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you give link of example the error/deprecation notice on https://3v4l.org/ for this case?

Also probably handle __wakeup as well.

Thank you.

@arshidkv12

arshidkv12 commented Sep 3, 2025

Copy link
Copy Markdown
ContributorAuthor

Also probably handle __wakeup as well.

php/php-src#19435

Not implemented in PHP core yet. I think it will be added soon. I’ll add __wakeup soon.

@ddevsr

Copy link
Copy Markdown
Contributor

php/php-src#19682 already merged

@samsonasiksamsonasik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@arshidkv12 could you add @see comment to show deprecation notice when using old behaviour vs new behaviour via https://3v4l.org/ ? Thank you.

Comment threadrules/Php85/Rector/ClassMethod/SleepToSerializeRector.php
@arshidkv12

Copy link
Copy Markdown
ContributorAuthor

I can compile the new PHP source code and check it.

@arshidkv12

Copy link
Copy Markdown
ContributorAuthor
<?phpclass User {
private$id;
private$name;
publicfunction__sleep() {
return ['id', 'name'];
}
}
$u = newUser;
serialize($u);
scr5

@samsonasik

Copy link
Copy Markdown
Member

Okay, I think we can wait for more eye to check, or wait until can be reproduced at https://3v4l.org/

@arshidkv12

Copy link
Copy Markdown
ContributorAuthor

https://3v4l.org/51uu0#vgit.master Please check it.

Comment threadrules/Php85/Rector/ClassMethod/SleepToSerializeRector.php Outdated

@samsonasiksamsonasik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good 👍

@TomasVotruba

Copy link
Copy Markdown
Member

Thank you 👏

@TomasVotruba
TomasVotruba merged commit 4507adf into rectorphp:mainSep 11, 2025
49 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

This pull request has been automatically locked because it has been closed for 150 days. Please open a new PR if you want to continue the work.

@github-actionsgithub-actionsBot locked as resolved and limited conversation to collaborators Feb 22, 2026
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@arshidkv12@ddevsr@samsonasik@TomasVotruba