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

[HttpFoundation] Allow array style callable setting for Request setFactory method #54333

Merged
merged 1 commit into from Mar 19, 2024

Conversation

jan-simbera
Copy link

@jan-simbera jan-simbera commented Mar 19, 2024

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

Allowing to use the array notation for callback for the setFactory static method of the request.

Unit test added to confirm bug/fixing the bug.

@carsonbot carsonbot added this to the 7.1 milestone Mar 19, 2024
@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.1 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

Copy link
Member

@derrabus derrabus left a comment

Choose a reason for hiding this comment

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

Thank you. Please find a meaningful title for your PR. We compose our changelog out of those titles.

Comment on lines 385 to 390
if(null === $callable) {
self::$requestFactory = null;
return;
}

self::$requestFactory = $callable(...);
Copy link
Member

Choose a reason for hiding this comment

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

We usually use a ternary expression when resolving this kind of union.

Suggested change
if(null === $callable) {
self::$requestFactory = null;
return;
}
self::$requestFactory = $callable(...);
if(null === $callable) {
self::$requestFactory = null;
return;
}
self::$requestFactory = null === $callable ? null : $callable(...);

Copy link
Author

Choose a reason for hiding this comment

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

Fixed.

src/Symfony/Component/HttpFoundation/Tests/RequestTest.php Outdated Show resolved Hide resolved
src/Symfony/Component/HttpFoundation/Tests/RequestTest.php Outdated Show resolved Hide resolved
@derrabus derrabus changed the base branch from 7.1 to 7.0 March 19, 2024 10:04
@derrabus derrabus modified the milestones: 7.1, 7.0 Mar 19, 2024
@carsonbot carsonbot changed the title bug fix with test for #54321 [HttpFoundation] bug fix with test for #54321 Mar 19, 2024
@jan-simbera jan-simbera changed the title [HttpFoundation] bug fix with test for #54321 [HttpFoundation] Allow array style callable setting for Request setFactory method #54321 Mar 19, 2024
@derrabus derrabus changed the title [HttpFoundation] Allow array style callable setting for Request setFactory method #54321 [HttpFoundation] Allow array style callable setting for Request setFactory method Mar 19, 2024
@derrabus
Copy link
Member

Good catch, thanks @jan-simbera.

@derrabus derrabus merged commit ea80120 into symfony:7.0 Mar 19, 2024
3 of 10 checks passed
@fabpot fabpot mentioned this pull request Apr 3, 2024
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.

[HttpFoundation] Type mismatch between Request::$requestFactory and Request::setFactory()
3 participants