Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Concatenate static parameter with string ends with exception #288

Closed
mildabre opened this issue May 17, 2023 · 2 comments
Closed

Concatenate static parameter with string ends with exception #288

mildabre opened this issue May 17, 2023 · 2 comments

Comments

@mildabre
Copy link

mildabre commented May 17, 2023

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.

@mabar
Copy link
Contributor

mabar commented May 17, 2023

@App\Test\Test1::getParam() is Nette\DI\Statement, not a string. The method cannot be called before container is compiled and the static parameters are resolved before container is compiled.
Can you add link to the docs where this is done? There's probably a difference
If you need to solve some specific problem, ask at forum, I'll help you finding an alternative solution.

@mildabre
Copy link
Author

OK it is a feature, not a bug, so let close this issue. I have found easily alternative solution, I put this issue because of make clear weather the documentation should be changed or the code.

I think, some relevant notice about neon entities/(Statements versus strings in documentation would be useful. My opinion is that the documentation part about neon entities syntax is incomplete and not enough clear - this case and some other. I am intending to prepare PR in neon documentation with better explanation of important things. But I need some more time for this. I will put PR directly into nette/docs and in case I need some expert assistance I will ask on forum.

@dg dg closed this as completed in e574bf7 Sep 22, 2023
dg added a commit that referenced this issue Sep 23, 2023
…rameters via getParameter() [Closes #291][Closes #288]

- parameters with expressions are automatically treated as dynamic
dg added a commit that referenced this issue Sep 25, 2023
…rameters via getParameter() [Closes #291][Closes #288]

- parameters with expressions are automatically treated as dynamic
dg added a commit that referenced this issue Sep 25, 2023
…rameters via getParameter() [Closes #291][Closes #288]

- parameters with expressions are automatically treated as dynamic
dg added a commit that referenced this issue Sep 25, 2023
…rameters via getParameter() [Closes #291][Closes #288]

- parameters with expressions are automatically treated as dynamic
dg added a commit that referenced this issue Sep 28, 2023
…rameters via getParameter() [Closes #291][Closes #288]

- parameters with expressions are automatically treated as dynamic
dg added a commit that referenced this issue Sep 28, 2023
…rameters via getParameter() [Closes #291][Closes #288]

- parameters with expressions are automatically treated as dynamic
dg added a commit that referenced this issue Sep 28, 2023
…rameters via getParameter() [Closes #291][Closes #288]

- parameters with expressions are automatically treated as dynamic
dg added a commit that referenced this issue Sep 29, 2023
…rameters via getParameter() [Closes #291][Closes #288]

- parameters with expressions are automatically treated as dynamic
dg added a commit that referenced this issue Sep 29, 2023
…rameters via getParameter() [Closes #291][Closes #288]

- parameters with expressions are automatically treated as dynamic
dg added a commit that referenced this issue Sep 29, 2023
…rameters via getParameter() [Closes #291][Closes #288]

- parameters with expressions are automatically treated as dynamic
dg added a commit that referenced this issue Sep 29, 2023
…rameters via getParameter() [Closes #291][Closes #288]

- parameters with expressions are automatically treated as dynamic
dg added a commit that referenced this issue Sep 29, 2023
…rameters via getParameter() [Closes #291][Closes #288]

- parameters with expressions are automatically treated as dynamic
dg added a commit that referenced this issue Sep 29, 2023
…rameters via getParameter() [Closes #291][Closes #288]

- parameters with expressions are automatically treated as dynamic
dg added a commit that referenced this issue Oct 2, 2023
…rameters via getParameter() [Closes #291][Closes #288]

- parameters with expressions are automatically treated as dynamic
dg added a commit that referenced this issue Oct 2, 2023
…rameters via getParameter() [Closes #291][Closes #288]

- parameters with expressions are automatically treated as dynamic
dg added a commit that referenced this issue Oct 15, 2023
…rameters via getParameter() [Closes #291][Closes #288]

- parameters with expressions are automatically treated as dynamic
dg added a commit that referenced this issue Oct 15, 2023
…rameters via getParameter() [Closes #291][Closes #288]

- parameters with expressions are automatically treated as dynamic
dg added a commit that referenced this issue Oct 15, 2023
…rameters via getParameter() [Closes #291][Closes #288]

- parameters with expressions are automatically treated as dynamic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants