deprecated-packages / symplify

[DISCONTINUED] Check split packages in their own repositories :)
MIT License
621 stars 189 forks source link

[Statie] int argument passed instead of string into Symfony DI #482

Closed dakur closed 6 years ago

dakur commented 6 years ago

On RC4, simple run of vendor/bin/statie ends with:

[ERROR] Argument 1 passed to Symfony\Component\DependencyInjection\Reference::__construct() must be of the type string, integer given, called in /.../vendor/symplify/package-builder/src/DependencyInjection/DefinitionCollector.php on line 21
TomasVotruba commented 6 years ago

Hey, thanks for such a fast report!

Do you have any idea what is causing it?

I'm trying it on my personal website and it works. Could you share your statie.neon and composer.json please?

dakur commented 6 years ago

Yep, we find it out. statie.neon registers service like this:

services:
    -
        class: App\TranslationProvider

This NEON structure is translated into ['services'][0]['class'] and then in Symplify\PackageBuilder\DependencyInjection\DefinitionCollector, you're trying to register those services into Symfony DI (if I understood it well), but it does not support 0 as a service name. Thus, it looks like a bug in symplify/package-builder, which should automatically prefix number-indexed services with some string to satisfy Symfony\Component\DependencyInjection\Reference constructor.

dakur commented 6 years ago

Thanks @jiripudil for explanation, I would not understand it. :-)

TomasVotruba commented 6 years ago

That looks like Nette syntax, but Statie uses Symfony.

Where correct syntax would be:

services:
    App\TranslationProvider: ~
dakur commented 6 years ago

Hm, in previous version it worked.
But yes, this way it works.

TomasVotruba commented 6 years ago

That's probably because Symfony 3 supported some older syntax. Statie 3 runs on Symfony 4.

TomasVotruba commented 6 years ago

Just wondering, what exactly do you use this service for?

dakur commented 6 years ago

Hm, ok.

dakur commented 6 years ago

For translating the content, obviously. :-)

TomasVotruba commented 6 years ago

I mean in details, PHP code would be nice :)

dakur commented 6 years ago

I wrote you on pehapkari Slack.

TomasVotruba commented 6 years ago

I don't use Slack, sorry. If it's private or too much work, nevermind. I was just curious how Statie is used out there :)

TomasVotruba commented 6 years ago

To your issue, do you think it would be helpful to use statie.yml instead?

It is clearly confusing to use statie.neon with Symfony syntax. It's only for historical reasons, no real useful feature.

dakur commented 6 years ago

I did not know about easier way how to contact you privately. I don't want to share the code in here, but the point is to have to different instances (in different languages) of the same static website.

I think that it is much more about documentation than the tools itself. Even if you would not use NEON, you use Latte so I would probably still - as a Nette user - expect the config behaving like I'm used to.
I would say, that the problem is more in the poor documentation. For example, it just says that you can register services via statie.neon, but does not show what do you mean with service in this context, does not show any examples, what they are for or could be for and does not show any basic examples of usage. The only other mention about services is when you use statie.neon in a bad way and the error message informs you, that there is a services section available, which is not documented neither. So, if this would be there, I guess it does not matter whether the config is NEON or YAML. :-)

TomasVotruba commented 6 years ago

I did not know about easier way how to contact you privately. I don't want to share the code in here, but the point is to have to different instances (in different languages) of the same static website.

Link with Private Gist is just fine to any contact

For example, it just says that you can register services via statie.neon, but does not show what do you mean with service in this context, does not show any examples, what they are for or could be for and does not show any basic examples of usage.

I see, thanks for expalining. I'd love to have rich documentation that explain all you need to read. Yet I'm not the best to write it, since I naturally focus on more advanced features as I write the code. I just use it with Symfony DI and Symfony config. I realize that might be complication for Nette users.

Could I ask you to send PR with such documentation about services in Statie? Example with your TranslationProvider would be great.