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

[9.x] Use request isMethod instead of method comparison #39526

Merged
merged 2 commits into from
Nov 8, 2021

Conversation

seriquynh
Copy link
Contributor

Symfony Request class has a built-in method called isMethod to determine which HTTP method a request is. Using the method isMethod is a little bit nicer than method comparison.

use Symfony\Component\HttpFoundation\Request;

$request = Request::create('/', 'POST');

// Using isMethod looks a bit nicer.
if ($request->isMethod('POST') {
    // do something...  
}

// than method comparison
if ($request->method() === 'POST') {
    // 
}

@seriquynh
Copy link
Contributor Author

All errors and failures in CI aren't related to these code changes. They're caused by testing setup environment (Eg, PHP version, extensions,...)

@X-Coder264
Copy link
Contributor

Not really. The skipped tests are due to the environment, but there is one test that is failing due to the request mock not being updated after this change.

There was 1 error:

1) Illuminate\Tests\Routing\RoutingRedirectorTest::testGuestPutPreviousUrlInSession
Mockery\Exception\BadMethodCallException: Received Mockery_130_Illuminate_Routing_UrlGenerator::full(), but no expectations were specified

/home/runner/work/framework/framework/src/Illuminate/Routing/Redirector.php:88
/home/runner/work/framework/framework/tests/Routing/RoutingRedirectorTest.php:90

@driesvints
Copy link
Member

Feel free to mark as ready when tests are passing. Thanks

@driesvints driesvints marked this pull request as draft November 8, 2021 10:15
@seriquynh seriquynh marked this pull request as ready for review November 8, 2021 10:34
@seriquynh
Copy link
Contributor Author

@X-Coder264 Thank you for figuring out the broken test! My bad! I've fixed it.

@taylorotwell taylorotwell merged commit 032c69a into laravel:master Nov 8, 2021
@seriquynh seriquynh deleted the use-request-isMethod branch November 9, 2021 00:05
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.

4 participants