From 996eaf43310edf1d908bc0030a18b37b8cf6eefd Mon Sep 17 00:00:00 2001 From: Arkadiusz Biczewski Date: Tue, 7 Sep 2021 20:16:55 +0200 Subject: [PATCH] Remove unnecessary reference assigment (#301) * Remove unnecessary reference assigment Proposed code is PHP5 and PHP7 compatible. PHP5 interpreted `$e->$type[$attr]` as `$e->{$type[$attr]}`, but the expected behavior based on workaround is consistent with PHP7 interpretation: `($e->$type)[$attr]`. By using curly braces `{$e->$type}[$attr]` there is a forced interpretation order working for both versions. Details can be found on https://www.php.net/manual/en/migration70.incompatible.php (section "Changes to the handling of indirect variables, properties, and methods") * Fix syntax Use correct syntax for indirect variable evaluation order change. --- library/HTMLPurifier/HTMLModule/Tidy.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/library/HTMLPurifier/HTMLModule/Tidy.php b/library/HTMLPurifier/HTMLModule/Tidy.php index 08aa2324..12173ba7 100644 --- a/library/HTMLPurifier/HTMLModule/Tidy.php +++ b/library/HTMLPurifier/HTMLModule/Tidy.php @@ -146,10 +146,7 @@ class HTMLPurifier_HTMLModule_Tidy extends HTMLPurifier_HTMLModule $type = "info_$type"; $e = $this; } - // PHP does some weird parsing when I do - // $e->$type[$attr], so I have to assign a ref. - $f =& $e->$type; - $f[$attr] = $fix; + $e->{$type}[$attr] = $fix; break; case 'tag_transform': $this->info_tag_transform[$params['element']] = $fix;