Skip to content

Concatenate static parameter with string ends with exception #288

@mildabre

Description

@mildabre

nette/di v 3.1.2

Bug Description

I have set static parameter in neon configuration file with call method of service. Using this parameter concatenated with another literal string throws Nette\InvalidArgumentException.

Steps To Reproduce

Just copy this code and use Test2 in presenter, Nette\InvalidArgumentException is thrown:
Unable to concatenate non-scalar parameter 'param' into '%param%cd'.

class Test1
{
    public function getParam(): string
    {
        return 'ab';
    }
}

class Test2
{
    public function __construct(private string $param)
    {
        bdump($this->param);	// expected abcd, but exception thrown
    }
}

parameters:
	param: @App\Test\Test1::getParam()


services:
	- App\Test\Test1
	- App\Test\Test2(param: %param%cd)

Expected Behavior

Im not sure wheather this is a real bug, or a specific feature, but the behaviour differs from documentation, where are code samples showing concatenation static parameters with strings like %param%abc

Possible Solution

a) best solution make concatenation possible, because this would be useful

b) if not possible a), just let me know and I would prepare PR to describe this feature in documentation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions