E57A bug #43376 [Runtime] Fix class validation of composer "extra.runtime.… · symfony/symfony@166ca8d · GitHub
[go: up one dir, main page]

Skip to content

Commit 166ca8d

Browse files
bug #43376 [Runtime] Fix class validation of composer "extra.runtime.class" (piku235)
This PR was merged into the 5.3 branch. Discussion ---------- [Runtime] Fix class validation of composer "extra.runtime.class" | Q | A | ------------- | --- | Branch? | 5.3 | Bug fix? | yes | New feature? | no | Deprecations? | no | License | MIT This PR fixes a bug of validating a runtime class from the composer param `extra.runtime.class`. When provided, it always fails. Taking as an example the `Runtime\Swoole\Runtime` of the `runtime/swoole` package, when executing the `composer dump-autoload`, it ends with the following exception, even though the `runtime/swoole` package was installed. ``` [InvalidArgumentException] Class "Runtime\Swoole\Runtime" listed under "extra.runtime.class" in your composer.json file not found. ``` When a composer plugin is executed, the composer autoloader for the project is not registered, thereby any reference to a class from installed packages won't work. The fix drops this check to avoid it. I don't think it's worth checking here if a runtime class is valid or not. For instance, anything that comes from the `$_SERVER['APP_RUNTIME']` is accepted, nothing is validated. Commits ------- 13f69f2 [Runtime] Drop class validation of composer "extra.runtime.class"
2 parents e556cec + 13f69f2 commit 166ca8d

File tree

1 file changed

+0
-5
lines changed

1 file changed

+0
-5
lines changed

src/Symfony/Component/Runtime/Internal/ComposerPlugin.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
use Composer\Plugin\PluginInterface;
1919
use Composer\Script\ScriptEvents;
2020
use Symfony\Component\Filesystem\Filesystem;
21-
use Symfony\Component\Runtime\RuntimeInterface;
2221
use Symfony\Component\Runtime\SymfonyRuntime;
2322

2423
/**
@@ -98,10 +97,6 @@ public function updateAutoloadFile(): void
9897

9998
$runtimeClass = $extra['class'] ?? SymfonyRuntime::class;
10099

101-
if (SymfonyRuntime::class !== $runtimeClass && !is_subclass_of($runtimeClass, RuntimeInterface::class)) {
102-
throw new \InvalidArgumentException(sprintf('Class "%s" listed under "extra.runtime.class" in your composer.json file '.(class_exists($runtimeClass) ? 'should implement "%s".' : 'not found.'), $runtimeClass, RuntimeInterface::class));
103-
}
104-
105100
unset($extra['class'], $extra['autoload_template']);
106101

107102
$code = strtr(file_get_contents($autoloadTemplate), [

0 commit comments

Comments
 (0)
0