-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix nonexistent InputBag on Symfony 4.x
- Loading branch information
1 parent
390cfa1
commit c1627fc
Showing
5 changed files
with
82 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace PHPStan\Symfony; | ||
|
||
use PHPStan\PhpDoc\StubFilesExtension; | ||
|
||
class InputBagStubFilesExtension implements StubFilesExtension | ||
{ | ||
|
||
public function getFiles(): array | ||
{ | ||
if (!class_exists('Symfony\Component\HttpFoundation\InputBag')) { | ||
return []; | ||
} | ||
|
||
return [ | ||
__DIR__ . '/../../stubs/Symfony/Component/HttpFoundation/InputBag.stub', | ||
__DIR__ . '/../../stubs/Symfony/Component/HttpFoundation/Request.stub', | ||
]; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace PHPStan\Rules; | ||
|
||
use PHPStan\Rules\Methods\CallMethodsRule; | ||
use PHPStan\Testing\RuleTestCase; | ||
|
||
/** | ||
* @extends RuleTestCase<CallMethodsRule> | ||
*/ | ||
class NonexistentInputBagClassTest extends RuleTestCase | ||
{ | ||
|
||
protected function getRule(): \PHPStan\Rules\Rule | ||
{ | ||
return self::getContainer()->getByType(CallMethodsRule::class); | ||
} | ||
|
||
public function testInputBag(): void | ||
{ | ||
$this->analyse([__DIR__ . '/data/input_bag.php'], []); | ||
} | ||
|
||
public static function getAdditionalConfigFiles(): array | ||
{ | ||
return [ | ||
__DIR__ . '/../../extension.neon', | ||
__DIR__ . '/../../rules.neon', | ||
]; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace InputBagTest; | ||
|
||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\HttpFoundation\Response; | ||
use Symfony\Component\Routing\Annotation\Route; | ||
|
||
class TestController extends AbstractController | ||
{ | ||
/** | ||
* @Route("/test", name="test") | ||
*/ | ||
public function index(Request $request): Response | ||
{ | ||
$foo = $request->query->get('foo'); | ||
|
||
return $this->render('test/index.html.twig', [ | ||
'controller_name' => 'TestController', | ||
]); | ||
} | ||
} |