fmasa / auto-di

:star: :wrench: Automatic registration and configuration of services for Nette DI
MIT License
15 stars 3 forks source link

Skip classes which has parameters without typehints #11

Closed dakorpar closed 5 years ago

dakorpar commented 5 years ago

There's problem when U have class which needs to be registered manually but it's in namespace which is configured with autoDI For example if U have class there which receives string $path you'll get error

Parameter $path in App\Services\MyService::__construct() has no class type hint or default value, so its value must be specified.

This is correct. but then if I add this service to config.neon

services:
    - App\Services\MyService(path: %appDir%/subfolder)

I'll get:

Multiple services of type App\Services\MyService found: ...

This is kinda important to work IMHO, any ideas? @fmasa

edit: on description page there's:

When extension founds service, that is already registered (by services section, different extension or previous autoDI definition), it's skipped.

This allows manual registration of specific services that need specific configuration.

But this does not work...

fmasa commented 5 years ago

Hi, sorry for late response. Do you have registerOnConfiguration set to true (default is false)?

Can you provide some minimal scenario for reproducing? Ideally failing test.

dakorpar commented 5 years ago

sorry I don't remember anymore of this, I'm closing it, I don't have this problem anymore