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

[Bug] Type error when trying to convert config/services.yaml #42

Open
COil opened this issue Dec 3, 2024 · 9 comments
Open

[Bug] Type error when trying to convert config/services.yaml #42

COil opened this issue Dec 3, 2024 · 9 comments

Comments

@COil
Copy link

COil commented Dec 3, 2024

Stack

  • PHP 8.2
  • Symfony 7.2.0

Bug

Hello, I used simplify/config-transformer on MicroSymfony (PR), it worked well except for the config/services.yaml file, I had to convert manually. I have the following error :

   ~/Sites/microsymfony  $ feat/use-php-config !14 ?12 $ vendor/bin/config-transformer switch-format config/services.yaml                                                                                                                                               ✔   8.4.1  17:47:04
PHP Fatal error:  Uncaught TypeError: Symplify\PhpConfigPrinter\NodeFactory\Service\AutoBindNodeFactory::createBindMethodCall(): Argument #2 ($bindValues) must be of type array, null given, called in /Users/coil/Sites/microsymfony/vendor/symplify/config-transformer/vendor/symplify/php-config-printer/src/NodeFactory/Service/AutoBindNodeFactory.php on line 48 and defined in /Users/coil/Sites/microsymfony/vendor/symplify/config-transformer/vendor/symplify/php-config-printer/src/NodeFactory/Service/AutoBindNodeFactory.php:59
Stack trace:
#0 /Users/coil/Sites/microsymfony/vendor/symplify/config-transformer/vendor/symplify/php-config-printer/src/NodeFactory/Service/AutoBindNodeFactory.php(48): Symplify\PhpConfigPrinter\NodeFactory\Service\AutoBindNodeFactory->createBindMethodCall(Object(ConfigTransformerPrefix202401\PhpParser\Node\Expr\MethodCall), NULL)
#1 /Users/coil/Sites/microsymfony/vendor/symplify/config-transformer/vendor/symplify/php-config-printer/src/CaseConverter/ServicesDefaultsCaseConverter.php(33): Symplify\PhpConfigPrinter\NodeFactory\Service\AutoBindNodeFactory->createAutoBindCalls(Array, Object(ConfigTransformerPrefix202401\PhpParser\Node\Expr\MethodCall))
#2 /Users/coil/Sites/microsymfony/vendor/symplify/config-transformer/vendor/symplify/php-config-printer/src/NodeFactory/ContainerConfiguratorReturnClosureFactory.php(192): Symplify\PhpConfigPrinter\CaseConverter\ServicesDefaultsCaseConverter->convertToMethodCallStmt('_defaults', Array)
#3 /Users/coil/Sites/microsymfony/vendor/symplify/config-transformer/vendor/symplify/php-config-printer/src/NodeFactory/ContainerConfiguratorReturnClosureFactory.php(90): Symplify\PhpConfigPrinter\NodeFactory\ContainerConfiguratorReturnClosureFactory->resolveStmt('services', '_defaults', Array)
#4 /Users/coil/Sites/microsymfony/vendor/symplify/config-transformer/vendor/symplify/php-config-printer/src/NodeFactory/ContainerConfiguratorReturnClosureFactory.php(69): Symplify\PhpConfigPrinter\NodeFactory\ContainerConfiguratorReturnClosureFactory->createStmtsFromCaseConverters(Array)
#5 /Users/coil/Sites/microsymfony/vendor/symplify/config-transformer/vendor/symplify/php-config-printer/src/NodeFactory/ContainerConfiguratorReturnClosureFactory.php(58): Symplify\PhpConfigPrinter\NodeFactory\ContainerConfiguratorReturnClosureFactory->createClosureStmts(Array)
#6 /Users/coil/Sites/microsymfony/vendor/symplify/config-transformer/src/Converter/YamlToPhpConverter.php(76): Symplify\PhpConfigPrinter\NodeFactory\ContainerConfiguratorReturnClosureFactory->createFromYamlArray(Array)
#7 /Users/coil/Sites/microsymfony/vendor/symplify/config-transformer/src/Converter/YamlToPhpConverter.php(65): Symplify\ConfigTransformer\Converter\YamlToPhpConverter->convertYamlArray(Array, '/Users/coil/Sit...')
#8 /Users/coil/Sites/microsymfony/vendor/symplify/config-transformer/src/Converter/ConfigFormatConverter.php(40): Symplify\ConfigTransformer\Converter\YamlToPhpConverter->convert('# This file is ...', '/Users/coil/Sit...')
#9 /Users/coil/Sites/microsymfony/vendor/symplify/config-transformer/src/Console/Command/SwitchFormatCommand.php(74): Symplify\ConfigTransformer\Converter\ConfigFormatConverter->convert(Object(ConfigTransformerPrefix202401\Symfony\Component\Finder\SplFileInfo))
#10 /Users/coil/Sites/microsymfony/vendor/symplify/config-transformer/vendor/symfony/console/Command/Command.php(327): Symplify\ConfigTransformer\Console\Command\SwitchFormatCommand->execute(Object(ConfigTransformerPrefix202401\Symfony\Component\Console\Input\ArgvInput), Object(ConfigTransformerPrefix202401\Symfony\Component\Console\Output\ConsoleOutput))
#11 /Users/coil/Sites/microsymfony/vendor/symplify/config-transformer/vendor/symfony/console/Application.php(960): ConfigTransformerPrefix202401\Symfony\Component\Console\Command\Command->run(Object(ConfigTransformerPrefix202401\Symfony\Component\Console\Input\ArgvInput), Object(ConfigTransformerPrefix202401\Symfony\Component\Console\Output\ConsoleOutput))
#12 /Users/coil/Sites/microsymfony/vendor/symplify/config-transformer/vendor/symfony/console/Application.php(333): ConfigTransformerPrefix202401\Symfony\Component\Console\Application->doRunCommand(Object(Symplify\ConfigTransformer\Console\Command\SwitchFormatCommand), Object(ConfigTransformerPrefix202401\Symfony\Component\Console\Input\ArgvInput), Object(ConfigTransformerPrefix202401\Symfony\Component\Console\Output\ConsoleOutput))
#13 /Users/coil/Sites/microsymfony/vendor/symplify/config-transformer/vendor/symfony/console/Application.php(216): ConfigTransformerPrefix202401\Symfony\Component\Console\Application->doRun(Object(ConfigTransformerPrefix202401\Symfony\Component\Console\Input\ArgvInput), Object(ConfigTransformerPrefix202401\Symfony\Component\Console\Output\ConsoleOutput))
#14 /Users/coil/Sites/microsymfony/vendor/symplify/config-transformer/bin/config-transformer.php(34): ConfigTransformerPrefix202401\Symfony\Component\Console\Application->run(Object(ConfigTransformerPrefix202401\Symfony\Component\Console\Input\ArgvInput), Object(ConfigTransformerPrefix202401\Symfony\Component\Console\Output\ConsoleOutput))
#15 /Users/coil/Sites/microsymfony/vendor/symplify/config-transformer/bin/config-transformer(5): require('/Users/coil/Sit...')
#16 /Users/coil/Sites/microsymfony/vendor/bin/config-transformer(119): include('/Users/coil/Sit...')
#17 {main}
  thrown in /Users/coil/Sites/microsymfony/vendor/symplify/config-transformer/vendor/symplify/php-config-printer/src/NodeFactory/Service/AutoBindNodeFactory.php on line 59

Reproducer

It can be reproduced on the main branch of MicroSymfony.

Thanks. See you. COil

@COil COil changed the title [Bug] Cannot [Bug] Type error when trying to convert config/services.yaml Dec 3, 2024
@TomasVotruba
Copy link
Member

Thanks for sharing.
What was the minimal line causing this?

@COil
Copy link
Author

COil commented Dec 4, 2024

I just retried and it works now! Thanks.

@COil COil closed this as completed Dec 4, 2024
@COil
Copy link
Author

COil commented Dec 4, 2024

I have made a PR a MicroSymfony, does that seems OK to you @TomasVotruba? See you.

@COil
Copy link
Author

COil commented Dec 4, 2024

I have also added a link in the README to your blog post (https://tomasvotruba.com/blog/2020/07/27/how-to-switch-from-yaml-xml-configs-to-php-today-with-migrify/). See you, and thanks for this library. :)

@COil
Copy link
Author

COil commented Dec 5, 2024

Ok, I have reproduced on another project, the bug comes from this line:

        bind:
            # bind examples
            #string $environment: '%kernel.environment%'
            #string $debug: '%kernel.debug%'

It is because the bind section is empty and only contains comments. If the examples are uncommented, then it works.

@COil COil reopened this Dec 5, 2024
@TomasVotruba
Copy link
Member

I see, thanks for finding the buggy place 🙏

Could you send failing test fixture in here?

https://github.com/symplify/config-transformer/tree/main/tests/Converter/ConfigFormatConverter/YamlToPhp/Fixture/normal

COil added a commit to COil/config-transformer that referenced this issue Dec 6, 2024
@COil
Copy link
Author

COil commented Dec 12, 2024

Hello @TomasVotruba , should I fix the bug too?

@TomasVotruba
Copy link
Member

Hey, that would definitelly speed up the process 👍

@COil
Copy link
Author

COil commented Dec 18, 2024

But the fix is in another repo right?

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

No branches or pull requests

2 participants