8000 [HttpFoundation] Add ReturnTypeWillChange to SessionHandlers by nikic · Pull Request #41495 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[HttpFoundation] Add ReturnTypeWillChange to SessionHandlers #41495

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
Jun 1, 2021

Conversation

nikic
Copy link
Contributor
@nikic nikic commented Jun 1, 2021
Q A
Branch? 4.4
Bug fix? yes
New feature? no
Deprecations? maybe?
Tickets
License MIT
Doc PR

This adds #[ReturnTypeWillChange] annotations for SessionHandler methods to satisfy the Tentative Return Types RFC. This doesn't cover all classes (e.g. MockPdo is also affected), just the ones relating to SessionHandler etc.

It's worth noting that the gc() method is spec'd as int|false on our side, so I've updated type hints accordingly. The method used to return bool prior to PHP 7.1.

@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 5.4 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
@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

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

thanks for the PR!

public function gc($maxlifetime)
{
return (bool) $this->handler->gc($maxlifetime);
return (int) $this->handler->gc($maxlifetime);
Copy link
Member

Choose a reason for hiding this comment

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

should we remove the cast to let false get through?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've adjusted this to pass through the false return value. I would be happy to just drop it completely though, I'm not sure why these casts are present.

Copy link
Member

Choose a reason for hiding this comment

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

I would say the cast was there to make implementations returning int|false satisfy the @return bool that was assumed. I don't think it makes sense to convert that to a int cast.

@nikic nikic force-pushed the return-type-will-change branch from 2528bfc to 2247d0b Compare June 1, 2021 14:08
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 for your first Symfony contribution, @nikic! 😅

@carsonbot carsonbot changed the title Add ReturnTypeWillChange to SessionHandlers [HttpFoundation] Add ReturnTypeWillChange to SessionHandlers Jun 1, 2021
@derrabus derrabus force-pushed the return-type-will-change branch from 1f91140 to 8954b4f Compare June 1, 2021 19:14
@derrabus
Copy link
Member
derrabus commented Jun 1, 2021

Thank you @nikic.

@derrabus derrabus merged commit b439213 into symfony:4.4 Jun 1, 2021
@stof
Copy link
Member
stof commented Jun 2, 2021

When merging that to the 6.0 branch, I think we should add the actual return type rather than the attribute

@fabpot fabpot mentioned this pull request Jun 2, 2021
@derrabus
Copy link
Member
derrabus commented Jun 2, 2021

Following the discussion on #41290, I suggest to merge these changes up as-is until we are able to trigger deprecation warnings based on the attribute.

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.

5 participants
0