Skip to content

Commit cdd1050

Browse files
committed
Remove Request::METHOD_* constants
1 parent 847feb7 commit cdd1050

File tree

20 files changed

+49
-57
lines changed

20 files changed

+49
-57
lines changed

features/bootstrap/GraphqlContext.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
use Behat\Gherkin\Node\PyStringNode;
1818
use Behatch\Context\RestContext;
1919
use Behatch\HttpCall\Request;
20-
use Symfony\Component\HttpFoundation\Request as HttpFoundationRequest;
2120

2221
/**
2322
* Context for GraphQL.
@@ -99,6 +98,6 @@ public function ISendTheGraphqlRequestWithOperation(string $operation)
9998
private function sendGraphqlRequest()
10099
{
101100
$this->request->setHttpHeader('Accept', null);
102-
$this->restContext->iSendARequestTo(HttpFoundationRequest::METHOD_GET, '/graphql?'.http_build_query($this->graphqlRequest));
101+
$this->restContext->iSendARequestTo('GET', '/graphql?'.http_build_query($this->graphqlRequest));
103102
}
104103
}

src/Bridge/Doctrine/EventListener/WriteListener.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
use ApiPlatform\Core\EventListener\WriteListener as BaseWriteListener;
1717
use Doctrine\Common\Persistence\ManagerRegistry;
1818
use Doctrine\Common\Persistence\ObjectManager;
19-
use Symfony\Component\HttpFoundation\Request;
2019
use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent;
2120

2221
/**
@@ -58,10 +57,10 @@ public function onKernelView(GetResponseForControllerResultEvent $event)
5857
}
5958

6059
switch ($request->getMethod()) {
61-
case Request::METHOD_POST:
60+
case 'POST':
6261
$objectManager->persist($controllerResult);
6362
break;
64-
case Request::METHOD_DELETE:
63+
case 'DELETE':
6564
$objectManager->remove($controllerResult);
6665
$event->setControllerResult(null);
6766
break;

src/Bridge/FosUser/EventListener.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
use ApiPlatform\Core\Util\RequestAttributesExtractor;
1717
use FOS\UserBundle\Model\UserInterface;
1818
use FOS\UserBundle\Model\UserManagerInterface;
19-
use Symfony\Component\HttpFoundation\Request;
2019
use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent;
2120

2221
/**
@@ -52,7 +51,7 @@ public function onKernelView(GetResponseForControllerResultEvent $event)
5251
}
5352

5453
switch ($request->getMethod()) {
55-
case Request::METHOD_DELETE:
54+
case 'DELETE':
5655
$this->userManager->deleteUser($user);
5756
$event->setControllerResult(null);
5857
break;

src/Bridge/NelmioApiDoc/Extractor/AnnotationsProvider/ApiPlatformProvider.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
use Nelmio\ApiDocBundle\Annotation\ApiDoc;
2525
use Nelmio\ApiDocBundle\Extractor\AnnotationsProviderInterface;
2626
use Psr\Container\ContainerInterface;
27-
use Symfony\Component\HttpFoundation\Request;
2827
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
2928

3029
/**
@@ -140,7 +139,7 @@ private function getApiDoc(bool $collection, string $resourceClass, ResourceMeta
140139
$data['output'] = sprintf('%s:%s:%s', ApiPlatformParser::OUT_PREFIX, $resourceClass, $operationName);
141140
}
142141

143-
if ($collection && Request::METHOD_GET === $method) {
142+
if ($collection && 'GET' === $method) {
144143
$resourceFilters = $resourceMetadata->getCollectionOperationAttribute($operationName, 'filters', [], true);
145144

146145
$data['filters'] = [];

src/Bridge/Symfony/Validator/EventListener/ValidateListener.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
use ApiPlatform\Core\Util\RequestAttributesExtractor;
1919
use ApiPlatform\Core\Validator\EventListener\ValidateListener as MainValidateListener;
2020
use Psr\Container\ContainerInterface;
21-
use Symfony\Component\HttpFoundation\Request;
2221
use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent;
2322
use Symfony\Component\Validator\Validator\ValidatorInterface;
2423

@@ -56,7 +55,7 @@ public function onKernelView(GetResponseForControllerResultEvent $event)
5655
$request = $event->getRequest();
5756
if (
5857
$request->isMethodSafe(false)
59-
|| $request->isMethod(Request::METHOD_DELETE)
58+
|| $request->isMethod('DELETE')
6059
|| !($attributes = RequestAttributesExtractor::extractAttributes($request))
6160
|| !$attributes['receive']
6261
) {

src/EventListener/DeserializeListener.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ public function onKernelRequest(GetResponseEvent $event)
4949
$request = $event->getRequest();
5050
if (
5151
$request->isMethodSafe(false)
52-
|| $request->isMethod(Request::METHOD_DELETE)
52+
|| $request->isMethod('DELETE')
5353
|| !($attributes = RequestAttributesExtractor::extractAttributes($request))
5454
|| !$attributes['receive']
55-
|| ('' === ($requestContent = $request->getContent()) && $request->isMethod(Request::METHOD_PUT))
55+
|| ('' === ($requestContent = $request->getContent()) && $request->isMethod('PUT'))
5656
) {
5757
return;
5858
}

src/EventListener/ReadListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public function onKernelRequest(GetResponseEvent $event)
9393
*/
9494
private function getCollectionData(Request $request, array $attributes, array $context)
9595
{
96-
if ($request->isMethod(Request::METHOD_POST)) {
96+
if ($request->isMethod('POST')) {
9797
return null;
9898
}
9999

src/EventListener/RespondListener.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
namespace ApiPlatform\Core\EventListener;
1515

16-
use Symfony\Component\HttpFoundation\Request;
1716
use Symfony\Component\HttpFoundation\Response;
1817
use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent;
1918

@@ -25,8 +24,8 @@
2524
final class RespondListener
2625
{
2726
const METHOD_TO_CODE = [
28-
Request::METHOD_POST => Response::HTTP_CREATED,
29-
Request::METHOD_DELETE => Response::HTTP_NO_CONTENT,
27+
'POST' => Response::HTTP_CREATED,
28+
'DELETE' => Response::HTTP_NO_CONTENT,
3029
];
3130

3231
/**

src/EventListener/WriteListener.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
namespace ApiPlatform\Core\EventListener;
1515

1616
use ApiPlatform\Core\DataPersister\DataPersisterInterface;
17-
use Symfony\Component\HttpFoundation\Request;
1817
use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent;
1918

2019
/**
@@ -48,12 +47,12 @@ public function onKernelView(GetResponseForControllerResultEvent $event)
4847
}
4948

5049
switch ($request->getMethod()) {
51-
case Request::METHOD_PUT:
52-
case Request::METHOD_PATCH:
53-
case Request::METHOD_POST:
50+
case 'PUT':
51+
case 'PATCH':
52+
case 'POST':
5453
$this->dataPersister->persist($controllerResult);
5554
break;
56-
case Request::METHOD_DELETE:
55+
case 'DELETE':
5756
$this->dataPersister->remove($controllerResult);
5857
$event->setControllerResult(null);
5958
break;

src/Serializer/SerializerContextBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function createFromRequest(Request $request, bool $normalization, array $
6969
$context['operation_type'] = $operationType ?: OperationType::ITEM;
7070

7171
if (!$normalization && !isset($context['api_allow_update'])) {
72-
$context['api_allow_update'] = in_array($request->getMethod(), [Request::METHOD_PUT, Request::METHOD_PATCH], true);
72+
$context['api_allow_update'] = in_array($request->getMethod(), ['PUT', 'PATCH'], true);
7373
}
7474

7575
$context['resource_class'] = $attributes['resource_class'];

0 commit comments

Comments
 (0)