Skip to content

Commit cf1fe6a

Browse files
committed
minor #4381 PHP7.4 - Add support for magic methods (un)serialize. (SpacePossum)
This PR was merged into the 2.14 branch. Discussion ---------- PHP7.4 - Add support for magic methods (un)serialize. @ see https://wiki.php.net/rfc/custom_object_serialization Commits ------- f89ea9f PHP7.4 - Add support for magic methods (un)serialize.
2 parents 013b6d8 + f89ea9f commit cf1fe6a

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

src/Fixer/Casing/MagicMethodCasingFixer.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,12 @@ final class MagicMethodCasingFixer extends AbstractFixer
3333
'__get' => '__get',
3434
'__invoke' => '__invoke',
3535
'__isset' => '__isset',
36+
'__serialize' => '__serialize',
3637
'__set' => '__set',
3738
'__set_state' => '__set_state',
3839
'__sleep' => '__sleep',
3940
'__tostring' => '__toString',
41+
'__unserialize' => '__unserialize',
4042
'__unset' => '__unset',
4143
'__wakeup' => '__wakeup',
4244
];

tests/Fixer/Casing/MagicMethodCasingFixerTest.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,35 @@ public function provideFixCases()
137137
'<?php trait Foo {public function __toString(){}}',
138138
'<?php trait Foo {public function __tostring(){}}',
139139
];
140+
141+
yield '(un)serialize' => [
142+
'<?php
143+
144+
class Foo extends Bar
145+
{
146+
public function __serialize() {
147+
$this->__serialize();
148+
}
149+
150+
public function __unserialize($payload) {
151+
$this->__unserialize($this_>$a);
152+
}
153+
}
154+
',
155+
'<?php
156+
157+
class Foo extends Bar
158+
{
159+
public function __SERIALIZE() {
160+
$this->__SERIALIZE();
161+
}
162+
163+
public function __unSERIALIZE($payload) {
164+
$this->__unSERIALIZE($this_>$a);
165+
}
166+
}
167+
',
168+
];
140169
}
141170

142171
/**

0 commit comments

Comments
 (0)