From 44ebeb7e8f5df93bb7b34c3678cc5b75340de79b Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Sun, 7 May 2023 14:39:25 +0200 Subject: [PATCH] Fix support for readonly classes as plugins, fixes #11404 --- src/Composer/Plugin/PluginManager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Composer/Plugin/PluginManager.php b/src/Composer/Plugin/PluginManager.php index c0c86b7b6..29cca6a19 100644 --- a/src/Composer/Plugin/PluginManager.php +++ b/src/Composer/Plugin/PluginManager.php @@ -276,7 +276,7 @@ class PluginManager if ($separatorPos) { $className = substr($class, $separatorPos + 1); } - $code = Preg::replace('{^((?:final\s+)?(?:\s*))class\s+('.preg_quote($className).')}mi', '$1class $2_composer_tmp'.self::$classCounter, $code, 1); + $code = Preg::replace('{^((?:(?:final|readonly)\s+)*(?:\s*))class\s+('.preg_quote($className).')}mi', '$1class $2_composer_tmp'.self::$classCounter, $code, 1); $code = strtr($code, array( '__FILE__' => var_export($path, true), '__DIR__' => var_export(dirname($path), true),