Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SingleDirectoryComponent::__construct should type against interface #125

Merged
merged 1 commit into from
Mar 3, 2024

Conversation

rpayanm
Copy link
Contributor

@rpayanm rpayanm commented Feb 22, 2024

I try to run drush generate and I get this error:

[error] TypeError: DrupalCodeGenerator\Command\SingleDirectoryComponent::__construct(): Argument #3 ($libraryDiscovery) must be of type Drupal\Core\Asset\LibraryDiscovery, Drupal\attachinline\Asset\LibraryDiscoveryDecorator given, called in /var/www/vendor/chi-teck/drupal-code-generator/src/Command/SingleDirectoryComponent.php on line 50 in DrupalCodeGenerator\Command\SingleDirectoryComponent->__construct() (line 35 of /var/www/vendor/chi-teck/drupal-code-generator/src/Command/SingleDirectoryComponent.php) #0 /var/www/vendor/chi-teck/drupal-code-generator/src/Command/SingleDirectoryComponent.php(50): DrupalCodeGenerator\Command\SingleDirectoryComponent->__construct(Object(Drupal\Core\Extension\ModuleHandler), Object(Drupal\Core\Extension\ThemeHandler), Object(Drupal\attachinline\Asset\LibraryDiscoveryDecorator)) #1 /var/www/web/core/lib/Drupal/Core/DependencyInjection/ClassResolver.php(28): DrupalCodeGenerator\Command\SingleDirectoryComponent::create(Object(Drupal\Core\DependencyInjection\Container)) #2 /var/www/vendor/chi-teck/drupal-code-generator/src/GeneratorFactory.php(58): Drupal\Core\DependencyInjection\ClassResolver->getInstanceFromDefinition('\\DrupalCodeGene...') #3 /var/www/vendor/chi-teck/drupal-code-generator/src/Application.php(99): DrupalCodeGenerator\GeneratorFactory->getGenerators() #4 /var/www/vendor/drush/drush/src/Commands/generate/ApplicationFactory.php(35): DrupalCodeGenerator\Application::create(Object(Drupal\Core\DependencyInjection\Container)) #5 /var/www/vendor/drush/drush/src/Commands/generate/GenerateCommands.php(60): Drush\Commands\generate\ApplicationFactory->create() #6 [internal function]: Drush\Commands\generate\GenerateCommands->generate('', Array) #7 /var/www/vendor/consolidation/annotated-command/src/CommandProcessor.php(276): call_user_func_array(Array, Array) #8 /var/www/vendor/consolidation/annotated-command/src/CommandProcessor.php(212): Consolidation\AnnotatedCommand\CommandProcessor->runCommandCallback(Array, Object(Consolidation\AnnotatedCommand\CommandData)) #9 /var/www/vendor/consolidation/annotated-command/src/CommandProcessor.php(176): Consolidation\AnnotatedCommand\CommandProcessor->validateRunAndAlter(Array, Array, Object(Consolidation\AnnotatedCommand\CommandData)) #10 /var/www/vendor/consolidation/annotated-command/src/AnnotatedCommand.php(391): Consolidation\AnnotatedCommand\CommandProcessor->process(Object(Symfony\Component\Console\Output\ConsoleOutput), Array, Array, Object(Consolidation\AnnotatedCommand\CommandData)) #11 /var/www/vendor/symfony/console/Command/Command.php(326): Consolidation\AnnotatedCommand\AnnotatedCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #12 /var/www/vendor/symfony/console/Application.php(1096): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #13 /var/www/vendor/symfony/console/Application.php(324): Symfony\Component\Console\Application->doRunCommand(Object(Consolidation\AnnotatedCommand\AnnotatedCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #14 /var/www/vendor/symfony/console/Application.php(175): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #15 /var/www/vendor/drush/drush/src/Runtime/Runtime.php(110): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #16 /var/www/vendor/drush/drush/src/Runtime/Runtime.php(40): Drush\Runtime\Runtime->doRun(Array, Object(Symfony\Component\Console\Output\ConsoleOutput)) #17 /var/www/vendor/drush/drush/drush.php(139): Drush\Runtime\Runtime->run(Array) #18 /var/www/vendor/drush/drush/drush(4): require('/var/www/vendor...') #19 /var/www/vendor/bin/drush(119): include('/var/www/vendor...') #20 {main}.

I saw this issue:
https://www.drupal.org/project/colorbox/issues/3280948

And applied the same fix, and it worked, it seems that:
The method definition for SingleDirectoryComponent::__construct() uses LibraryDiscovery as a type hint instead of the interface, which will result in errors if the service implementation is changed.

@Chi-teck Chi-teck merged commit b2bd619 into Chi-teck:3.x Mar 3, 2024
0 of 8 checks passed
@Chi-teck
Copy link
Owner

Chi-teck commented Mar 3, 2024

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants