File tree Expand file tree Collapse file tree 4 files changed +63
-1
lines changed Expand file tree Collapse file tree 4 files changed +63
-1
lines changed Original file line number Diff line number Diff line change 1616use FOS \RestBundle \Inflector \InflectorInterface ;
1717use FOS \RestBundle \Request \ParamReaderInterface ;
1818use FOS \RestBundle \Routing \RestRouteCollection ;
19+ use Psr \Http \Message \MessageInterface ;
1920use Symfony \Component \Routing \Route ;
2021
2122/**
@@ -476,6 +477,7 @@ private function getMethodArguments(\ReflectionMethod $method)
476477 \FOS \RestBundle \Request \ParamFetcherInterface::class,
477478 \Symfony \Component \Validator \ConstraintViolationListInterface::class,
478479 \Sensio \Bundle \FrameworkExtraBundle \Configuration \ParamConverter::class,
480+ MessageInterface::class,
479481 ];
480482
481483 $ arguments = [];
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ /*
4+ * This file is part of the FOSRestBundle package.
5+ *
6+ * (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
7+ *
8+ * For the full copyright and license information, please view the LICENSE
9+ * file that was distributed with this source code.
10+ */
11+
12+ namespace FOS \RestBundle \Tests \Fixtures \Controller ;
13+
14+ use FOS \RestBundle \Controller \Annotations as Rest ;
15+ use FOS \RestBundle \Controller \FOSRestController ;
16+ use FOS \RestBundle \Routing \ClassResourceInterface ;
17+ use Psr \Http \Message \MessageInterface ;
18+ use Psr \Http \Message \ServerRequestInterface ;
19+ use Symfony \Component \HttpFoundation \Request ;
20+
21+ /**
22+ * @Rest\RouteResource("Article")
23+ */
24+ class TypeHintedController implements ClassResourceInterface
25+ {
26+ public function cgetAction (Request $ request )
27+ {
28+ }
29+
30+ public function cpostAction (MessageInterface $ request )
31+ {
32+ }
33+
34+ public function getAction (Request $ request , $ id )
35+ {
36+ }
37+
38+ public function postAction (ServerRequestInterface $ request , $ id )
39+ {
40+ }
41+ }
Original file line number Diff line number Diff line change @@ -342,6 +342,24 @@ public function testNameMethodPrefixIsPrependingCorrectly()
342342 $ this ->assertNotNull ($ collection ->get ('post_users_bar ' ), 'route for "post_users_bar" does not exist ' );
343343 }
344344
345+ /**
346+ * RestActionReader::getMethodArguments should ignore certain types of
347+ * parameters.
348+ */
349+ public function testRequestTypeHintsIgnoredCorrectly ()
350+ {
351+ $ collection = $ this ->loadFromControllerFixture ('TypeHintedController ' );
352+
353+ $ this ->assertNotNull ($ collection ->get ('get_articles ' ), 'route for "get_articles" does not exist ' );
354+ $ this ->assertEquals ('/articles.{_format} ' , $ collection ->get ('get_articles ' )->getPath ());
355+ $ this ->assertNotNull ($ collection ->get ('post_articles ' ), 'route for "post_articles" does not exist ' );
356+ $ this ->assertEquals ('/articles.{_format} ' , $ collection ->get ('post_articles ' )->getPath ());
357+ $ this ->assertNotNull ($ collection ->get ('get_article ' ), 'route for "get_article" does not exist ' );
358+ $ this ->assertEquals ('/articles/{id}.{_format} ' , $ collection ->get ('get_article ' )->getPath ());
359+ $ this ->assertNotNull ($ collection ->get ('post_article ' ), 'route for "post_article" does not exist ' );
360+ $ this ->assertEquals ('/articles/{id}.{_format} ' , $ collection ->get ('post_article ' )->getPath ());
361+ }
362+
345363 /**
346364 * Load routes collection from fixture class under Tests\Fixtures directory.
347365 *
Original file line number Diff line number Diff line change 5454 "symfony/expression-language" : " ~2.7|^3.0" ,
5555 "symfony/css-selector" : " ^2.7|^3.0" ,
5656 "phpoption/phpoption" : " ^1.1" ,
57- "jms/serializer-bundle" : " ^1.0"
57+ "jms/serializer-bundle" : " ^1.0" ,
58+ "psr/http-message" : " ^1.0"
5859 },
5960
6061 "suggest" : {
You can’t perform that action at this time.
0 commit comments