Skip to content

Commit acf13a0

Browse files
committed
simplify replacement callback
1 parent 0899b0b commit acf13a0

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

lib/PHPGGC/Enhancement/PublicProperties.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ class PublicProperties extends Enhancement
2626
{
2727

2828
/**
29-
* Post process step of the public-attributes technique: removes prefixes
30-
* denoting protected properties, converting them to public.
29+
* Post process step of the public-properties technique: removes prefixes
30+
* denoting protected or private properties, converting them to public.
3131
*/
3232
public function process_serialized($serialized)
3333
{
@@ -37,9 +37,7 @@ public function process_serialized($serialized)
3737
public function remove_prefix($matches)
3838
{
3939
$length = $matches[1];
40-
$reduction = strlen($matches[2]) + 2;
41-
$search = 's:' . $length . ':"' . chr(0) . $matches[2] . chr(0);
42-
$replace = 's:' . ($length - $reduction) . ':"';
43-
return str_replace($search, $replace, $matches[0]);
40+
$reduction = strlen($matches[2]) + 2; // prefix + 2 null bytes
41+
return 's:' . ($length - $reduction) . ':"';
4442
}
4543
}

0 commit comments

Comments
 (0)