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

As per PSR-7, type hint @return static #2134

Merged
merged 2 commits into from Jan 30, 2017
Merged

As per PSR-7, type hint @return static #2134

merged 2 commits into from Jan 30, 2017

Conversation

hannesvdvreken
Copy link
Contributor

Changed

  • Some type hints of with* methods should return type static.

This helps with situations like this where you're extending the Request class to add typed attribute getters.

class AuthenticatedRequest extends Request
{
     /**
      * @return static
      */
     public function withUser(User $user)
     {
         return $this->withAttribute('user', $user);
     }

     /**
      * @return User
      */
     public function getUser()
     {
         return $this->getAttribute('user');
     }
}

@coveralls
Copy link

Coverage Status

Coverage remained the same at 97.928% when pulling 7b6f5a0 on hannesvdvreken:3.x into fb5356a on slimphp:3.x.

@jdrieghe
Copy link

Would love to see this one released. It would improve type hinting in the project I'm working on.

@akrabat akrabat added this to the 3.8.0 milestone Jan 30, 2017
@akrabat akrabat merged commit 7b6f5a0 into slimphp:3.x Jan 30, 2017
akrabat added a commit that referenced this pull request Jan 30, 2017
akrabat added a commit that referenced this pull request Jan 30, 2017
akrabat added a commit that referenced this pull request Jan 30, 2017
@hannesvdvreken
Copy link
Contributor Author

Thanks, Rob!

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

Successfully merging this pull request may close these issues.

None yet

4 participants