Skip to content

[DependencyInjection] Fix phpdoc for $configurator in Autoconfigure attribute #59820

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

Merged
merged 1 commit into from
Feb 21, 2025

Conversation

jfranclin
Copy link
Contributor

@jfranclin jfranclin commented Feb 20, 2025

Q A
Branch? 7.2
Bug fix? yes
New feature? no
Deprecations? no
Issues Fix #59821
License MIT

Since SF7.1, in Autoconfigure attribute, the $configurator phpdoc seems wrong :

* @param array<class-string, string>|string|null $configurator A PHP function, reference or an array containing a class/Reference and a method to call after the service is fully initialized

The doc is asking for a class-string key and a string value. However, this is not always the case because the first parameter could be a service, like @foo which is not a class-string. Moreover, the second parameter should not be empty.

@carsonbot
Copy link

Hey!

I see that this is your first PR. That is great! Welcome!

Symfony has a contribution guide which I suggest you to read.

In short:

  • Always add tests
  • Keep backward compatibility (see https://symfony.com/bc).
  • Bug fixes must be submitted against the lowest maintained branch where they apply (see https://symfony.com/releases)
  • Features and deprecations must be submitted against the 7.3 branch.

Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change.

When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor!
If this PR is merged in a lower version branch, it will be merged up to all maintained branches within a few days.

I am going to sit back now and wait for the reviews.

Cheers!

Carsonbot

@carsonbot
Copy link

Hey!

Oh no, it looks like you have made this PR towards a branch that is not maintained anymore. :/
Could you update the PR base branch to target one of these branches instead? 6.4, 7.2, 7.3.

Cheers!

Carsonbot

@jfranclin jfranclin force-pushed the fix/fix-phpdoc-autoconfigure branch from 1b43559 to c9b5a4b Compare February 20, 2025 18:34
@jfranclin jfranclin changed the base branch from 7.1 to 7.2 February 20, 2025 18:34
@jfranclin jfranclin force-pushed the fix/fix-phpdoc-autoconfigure branch from c9b5a4b to d9f9e20 Compare February 20, 2025 18:36
@jfranclin jfranclin changed the title [DependencyInjection] Fix phpdoc for in Autoconfigre attribute [DependencyInjection] Fix phpdoc for $configurator in Autoconfigre attribute Feb 20, 2025
@jfranclin jfranclin changed the title [DependencyInjection] Fix phpdoc for $configurator in Autoconfigre attribute [DependencyInjection] Fix phpdoc for $configurator in Autoconfigure attribute Feb 20, 2025
@jfranclin jfranclin force-pushed the fix/fix-phpdoc-autoconfigure branch from d9f9e20 to 4d68e58 Compare February 20, 2025 18:37
* @param bool|null $shared Whether to declare the service as shared
* @param bool|null $autowire Whether to declare the service as autowired
* @param array<string, mixed>|null $properties The properties to define when creating the service
* @param array{non-empty-string|class-string, non-empty-string}|non-empty-string|null $configurator A PHP function, reference or an array containing a class/Reference and a method to call after the service is fully initialized
Copy link
Member

@nicolas-grekas nicolas-grekas Feb 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's remove the empty- prefixes, they don't provide much
and let's merge class-string into string:

Suggested change
* @param array{non-empty-string|class-string, non-empty-string}|non-empty-string|null $configurator A PHP function, reference or an array containing a class/Reference and a method to call after the service is fully initialized
* @param array{string, string}|string|null $configurator A PHP function, reference or an array containing a class/reference and a method to call after the service is fully initialized

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @nicolas-grekas, thanks for the review!

I thought a non-empty string (as the first argument) would make sense since an empty string would trigger a RuntimeException in the PhpDumper :) . But anyway, using an empty string here doesn’t really make sense, so…

I've applied the changes you suggested. :)

@jfranclin jfranclin force-pushed the fix/fix-phpdoc-autoconfigure branch from 4d68e58 to 58bba2b Compare February 21, 2025 08:39
@nicolas-grekas nicolas-grekas force-pushed the fix/fix-phpdoc-autoconfigure branch from 58bba2b to ce03562 Compare February 21, 2025 08:43
@nicolas-grekas
Copy link
Member

Thank you @jfranclin.

@nicolas-grekas nicolas-grekas merged commit 385efaf into symfony:7.2 Feb 21, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants