-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[2.1] sub-requests are now created with the same class as their parent #7381
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
Conversation
jfsimon
commented
Mar 14, 2013
Q | A |
---|---|
Bug fix? | yes |
New feature? | no |
BC breaks? | no |
Deprecations? | no |
Tests pass? | yes |
Fixed tickets | #7185 |
oh .. i thought this was already the case! |
Thanks for the PR @jfsimon ! I just override the Request class for a custom getClientIp() method and I sure will need your fix in order for it to work in all scenarios. I'll test your patch in my project as soon as possible. |
This PR was merged into the 2.1 branch. Commits ------- e51432a sub-requests are now created with the same class as their parent Discussion ---------- [2.1] sub-requests are now created with the same class as their parent | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #7185 --------------------------------------------------------------------------- by lsmith77 at 2013-03-14T19:54:13Z oh .. i thought this was already the case! --------------------------------------------------------------------------- by gnutix at 2013-03-15T09:57:55Z Thanks for the PR @jfsimon ! I just override the Request class for a custom getClientIp() method and I sure will need your fix in order for it to work in all scenarios. I'll test your patch in my project as soon as possible.
@fabpot Thanks for the awesomely quick merge! :D |
Wouldnt it be simpler to do <?php
$subRequest = $request::create(); |
@henrikbjorn I didn't knew it was possible... it looks weird (but simpler yep). |
@jfsimon It's new to PHP 5.3. I too find the syntax a bit disturbing (as it kind of mix up static and non-static calls syntax). |
@gnutix mix up ? It is clear that it is a static call :) and in any case you can call static methods as nonstatic so |
@gnutix are you a bass player? cause I'm too ;) |
@henrikbjorn Visually, I'm not used to see static calls starting with "$" ("instance = not static" in my mind :P). But it's just a matter of habits. :) |
php > class Original { public static function create() { return new static(); } }
php > class Inherited extends Original { }
php > $original = new Original;
php > $inherited = new Inherited();
php > var_dump($original::create());
object(Original)#3 (0) {
}
php > var_dump($inherited::create());
object(Inherited)#2 (0) {
} Works fine :) |
@henrikbjorn I've tried too, but it's a syntax ( |
@asm89 In the second example,
However, it's probably not the right place to discuss it ! :) |
This PR was merged into the 2.1 branch. Commits ------- b9c37f2 changed sub-requests creation to '::create()' Discussion ---------- changed sub-requests creation to '::create()' Added @henrikbjorn suggestion to #7381
This PR was merged into the 2.2 branch. Commits ------- 53cf12b replaced new occurences of 'Request::create()' with '::create()' Discussion ---------- [2.2] sub-requests are now created with the same class as their parent Following #7381 | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #7185, #7186
…ss (fabpot) This PR was merged into the master branch. Discussion ---------- [HttpFoundation] added a way to override the Request class | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #7461, #7453 | License | MIT | Doc PR | symfony/symfony-docs#3021 This is an alternative implementation for #7461. I've also reverted #7381 and #7390 as these changes are not needed anymore. Todo: - [ ] add some tests Commits ------- 464439d [HttpFoundation] added a way to override the Request class