ITADN

[Bug]: Generator `Too few arguments` for constructor of models

#165ClosedToshY 创建于 2025-07-21
bug
T
ToshYcommented
### Package version(s) affected 7.0.0 ### Description The workflow run for the generator shows error when generating mapping. ```shell PHP Fatal error: Uncaught ArgumentCountError: Too few arguments to function ToshY\BunnyNet\Model\Api\Base\StreamVideoLibrary\RemoveBlockedReferer::__construct(), 0 passed and at least 1 expected in /home/runner/work/BunnyNet-PHP/BunnyNet-PHP/src/Model/Api/Base/StreamVideoLibrary/RemoveBlockedReferer.php:22 Stack trace: #0 [internal function]: ToshY\BunnyNet\Model\Api\Base\StreamVideoLibrary\RemoveBlockedReferer->__construct() #1 /home/runner/work/BunnyNet-PHP/BunnyNet-PHP/generator/Generator/MapGenerator.php(118): ReflectionClass->newInstance() #2 /home/runner/work/BunnyNet-PHP/BunnyNet-PHP/generator/Generator/MapGenerator.php(77): ToshY\BunnyNet\Generator\Generator\MapGenerator::scanExistingModelEndpointClasses() #3 /home/runner/work/BunnyNet-PHP/BunnyNet-PHP/generator/Command/generate-maps.php(74): ToshY\BunnyNet\Generator\Generator\MapGenerator->generate() #4 {main} thrown in /home/runner/work/BunnyNet-PHP/BunnyNet-PHP/src/Model/Api/Base/StreamVideoLibrary/RemoveBlockedReferer.php on line 22 ``` This seems to be beacuse `ReflectionClass->newInstance()` requires the arguments for the constructor. Previously there were no constructors for the models, so thats why it never failed before. ### How to reproduce ```shell php generator/Command/generate-maps.php ``` ### Possible Solution Maybe use `ReflectionClass::newInstanceWithoutConstructor` instead. https://www.php.net/manual/en/reflectionclass.newinstancewithoutconstructor.php ### Additional Context https://github.com/ToshY/BunnyNet-PHP/actions/runs/16406792540/job/46354003524
关闭于 2025-07-21 0 条评论