Skip to content

Commit

Permalink
feat: apply rector rule ReturnTypeFromReturnNewRector to all codebase
Browse files Browse the repository at this point in the history
  • Loading branch information
shakaran committed Mar 13, 2024
1 parent 3b97786 commit 45fc256
Show file tree
Hide file tree
Showing 12 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Resources/doc/examples/RssHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function __construct(LoggerInterface $logger = null)
*
* @return Response
*/
public function createResponse(ViewHandler $handler, View $view, Request $request)
public function createResponse(ViewHandler $handler, View $view, Request $request): \Symfony\Component\HttpFoundation\Response
{
try {
$content = $this->createFeed($view->getData());
Expand Down
2 changes: 1 addition & 1 deletion Tests/EventListener/ParamFetcherListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public function setParamFetcherByTypehintProvider()
return $paramFetcher;
}

protected function getEvent(Request $request, $actionMethod = 'byNameAction')
protected function getEvent(Request $request, $actionMethod = 'byNameAction'): \Symfony\Component\HttpKernel\Event\ControllerEvent
{
$this->requestStack->push($request);

Expand Down
4 changes: 2 additions & 2 deletions Tests/EventListener/ViewResponseListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class ViewResponseListenerTest extends TestCase
/**
* @return ControllerEvent|\PHPUnit_Framework_MockObject_MockObject
*/
protected function getFilterEvent(Request $request)
protected function getFilterEvent(Request $request): \Symfony\Component\HttpKernel\Event\ControllerEvent
{
$controller = new FooController();
$kernel = $this->createMock(HttpKernelInterface::class);
Expand All @@ -63,7 +63,7 @@ protected function getFilterEvent(Request $request)
*
* @return ViewEvent|\PHPUnit_Framework_MockObject_MockObject
*/
protected function getResponseEvent(Request $request, $result)
protected function getResponseEvent(Request $request, $result): \Symfony\Component\HttpKernel\Event\ViewEvent
{
$kernel = $this->createMock(HttpKernelInterface::class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

class AllowedMethodsController
{
public function indexAction()
public function indexAction(): \Symfony\Component\HttpFoundation\Response
{
return new Response();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@

class CommentController
{
public function loginAction()
public function loginAction(): \Symfony\Component\HttpFoundation\JsonResponse
{
return new JsonResponse('login');
}

public function getCommentAction($id)
public function getCommentAction($id): \Symfony\Component\HttpFoundation\JsonResponse
{
return new JsonResponse(['id' => (int) $id]);
}

public function getComments()
public function getComments(): \Symfony\Component\HttpFoundation\JsonResponse
{
return new JsonResponse([]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@

class CommentController
{
public function getCommentAction($id)
public function getCommentAction($id): \Symfony\Component\HttpFoundation\Response
{
return new Response("<html><body>$id</body>");
}

public function getComments()
public function getComments(): \Symfony\Component\HttpFoundation\Response
{
return new Response('<html><body>comments ..</body>');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class ParamFetcherController extends AbstractFOSRestController
* @QueryParam(name="foz", requirements="[a-z]+")
* @QueryParam(name="baz", requirements="[a-z]+", incompatibles={"foz"})
*/
public function paramsAction(ParamFetcherInterface $fetcher)
public function paramsAction(ParamFetcherInterface $fetcher): \Symfony\Component\HttpFoundation\JsonResponse
{
return new JsonResponse($fetcher->all());
}
Expand All @@ -40,7 +40,7 @@ public function paramsAction(ParamFetcherInterface $fetcher)
* @QueryParam(name="foo", default="invalid")
* @RequestParam(name="bar", default="%foo%")
*/
public function testAction(Request $request, ParamFetcherInterface $fetcher)
public function testAction(Request $request, ParamFetcherInterface $fetcher): \Symfony\Component\HttpFoundation\JsonResponse
{
$paramsBefore = $fetcher->all();

Expand All @@ -61,7 +61,7 @@ public function testAction(Request $request, ParamFetcherInterface $fetcher)
/**
* @FileParam(name="single_file", strict=false, default="noFile")
*/
public function singleFileAction(ParamFetcherInterface $fetcher)
public function singleFileAction(ParamFetcherInterface $fetcher): \Symfony\Component\HttpFoundation\JsonResponse
{
/** @var UploadedFile $file */
$file = $fetcher->get('single_file');
Expand All @@ -74,7 +74,7 @@ public function singleFileAction(ParamFetcherInterface $fetcher)
/**
* @FileParam(name="array_files", map=true)
*/
public function fileCollectionAction(ParamFetcherInterface $fetcher)
public function fileCollectionAction(ParamFetcherInterface $fetcher): \Symfony\Component\HttpFoundation\JsonResponse
{
$files = $fetcher->get('array_files');

Expand All @@ -89,7 +89,7 @@ public function fileCollectionAction(ParamFetcherInterface $fetcher)
/**
* @FileParam(name="array_images", image=true, strict=false, map=true, default="NotAnImage")
*/
public function imageCollectionAction(ParamFetcherInterface $fetcher)
public function imageCollectionAction(ParamFetcherInterface $fetcher): \Symfony\Component\HttpFoundation\JsonResponse
{
$files = $fetcher->get('array_images');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class RequestBodyParamConverterController extends AbstractController
/**
* @ParamConverter("post", converter="fos_rest.request_body")
*/
public function putPostAction(Post $post, \Datetime $date)
public function putPostAction(Post $post, \Datetime $date): \Symfony\Component\HttpFoundation\Response
{
return new Response($post->getName());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function authenticate(Request $request): PassportInterface
throw new BadCredentialsException();
}

$userBadge = new UserBadge($this->tokenValue, function () {
$userBadge = new UserBadge($this->tokenValue, function (): \FOS\RestBundle\Tests\Functional\Bundle\TestBundle\Entity\User {
$user = new User();
$user->username = 'foo';
$user->roles[] = 'ROLE_API';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function authenticate(Request $request): Passport
throw new BadCredentialsException();
}

$userBadge = new UserBadge($this->tokenValue, function () {
$userBadge = new UserBadge($this->tokenValue, function (): \FOS\RestBundle\Tests\Functional\Bundle\TestBundle\Entity\User {
$user = new User();
$user->username = 'foo';
$user->roles[] = 'ROLE_API';
Expand Down
4 changes: 2 additions & 2 deletions Tests/Request/RequestBodyParamConverterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ protected function launchExecution($converter, $request = null, $configuration =
return $converter->apply($request, $configuration);
}

protected function createConfiguration($class, $name = null, array $options = [])
protected function createConfiguration($class, $name = null, array $options = []): \Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter
{
return new ParamConverter([
'name' => (string) $name,
Expand All @@ -281,7 +281,7 @@ protected function createConfiguration($class, $name = null, array $options = []
]);
}

protected function createRequest($body = null, $contentType = null)
protected function createRequest($body = null, $contentType = null): \Symfony\Component\HttpFoundation\Request
{
$request = new Request(
[],
Expand Down
4 changes: 2 additions & 2 deletions Tests/View/ViewHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ public static function createSerializeNullDataValuesDataProvider()
public function testCreateResponse($expected, $formats)
{
$viewHandler = $this->createViewHandler($formats);
$viewHandler->registerHandler('html', function ($handler, View $view) {
$viewHandler->registerHandler('html', function ($handler, View $view): \Symfony\Component\HttpFoundation\Response {
return new Response('', $view->getStatusCode());
});

Expand All @@ -349,7 +349,7 @@ public static function createResponseDataProvider()
public function testHandleCustom()
{
$viewHandler = $this->createViewHandler([]);
$viewHandler->registerHandler('html', (function () {
$viewHandler->registerHandler('html', (function (): \Symfony\Component\HttpFoundation\Response {
return new Response('foo');
}));

Expand Down

0 comments on commit 45fc256

Please sign in to comment.