-
Notifications
You must be signed in to change notification settings - Fork 22
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
Context name not populated when manually triggering the context #592
Comments
Thanks for the report. I agree that it may be misleading that the context name is not always available.
In your reproducer, calling
Here, I reproduce the issue and it can be fixed with a simple modification in the ContextRegistry, by calling |
Yes sorry, probably I missed something when writing and used the example case I have in my project and not the case I exposed in issue. But for example this context: #[AsContext(default: true, name: 'my_default')]
function defaultContext(): Context
{
return new Context()->withName('my_default_runtime');
} It will output :
But the same context (no call to #[AsContext(default: true, name: 'my_default')]
function defaultContext(): Context
{
return new Context();
} Will output:
I think if possible, we need to only have one way to define a name for context or we need to clarify them |
Thanks for the report. See #604 |
For certain checks, I need to determine which context is authorized by its name. To achieve this, I declared a context using the
AsContext
attribute:Here, the name
'symfony'
is set and accessible using code like:However, when I attempt to manually resolve the name like this:
The resulting array is:
The names are empty because, by default, the
name
property in theContext
constructor is not populated. While callingwithName('...')
works, the constructor comment states:// Do not use this argument, it is only used internally by the application
This raises concerns about potential side effects or breaking behavior if
withName()
is explicitly used by users.Current Behavior:
#[AsContext(name: '...')]
does not auto-populate the name of context instance.Expected Behavior:
AsContext
attribute upon instantiation.Possible Solutions:
name
property when instantiating a context if theAsContext
attribute is set with a name.withName()
without concerns, and clarify whether its use is officially supported.Environment:
Additional Notes:
It’s unclear if manually setting the
name
orwithName()
could cause issues. Is there any risk in doing so, or can it be safely permitted?The text was updated successfully, but these errors were encountered: