Respect / Config

A powerful, small, deadly simple configurator and dependency injection container DSL made to be easy
http://respect.github.io/Config
Other
98 stars 7 forks source link

Instantiator not able to resolve __constructor with alone argument #63

Open tonicospinelli opened 8 years ago

tonicospinelli commented 8 years ago

An excpetion was throwed when try to construct an object with only one parameter at constructor and it being a reference to another object.

[productRepository \Develop\Business\Application\Product\Repositories\Product]
__construct = [[databaseConnection]]
PHP Catchable fatal error:  Object of class Respect\Config\Instantiator could not be converted to string in /Users/aspinelli/Projects/tonicospinelli/developing-for-business/vendor/respect/config/library/Respect/Config/Container.php on line 310

So, works when I use property name instead of constructor call!

augustohp commented 6 years ago

Although there is a bug in the parser here, it will come to a point where we still need to solve an issue with the DSL we are using over INI files: [] is used to detect variables, but they also denote a sequence (e.g: [a] is variable a or a sequence containing element a?).

I was thinking on moving the variable expansion to @name:

[@db PDO]
dsn = "sqlite::memory:"

[@instanceName From\Class]
__construct[] = [@db]
appendSequence[] = [a]

I would prefer $, like in PHP, but I am not inclined to make people deal with variable expansion inside PHP scripts while dealing with Config.

Any thoughts against this @Respect/core ?