Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 3178f15

Browse files
Revert "Remove nullable type after calling HeaderBag::has"
This reverts commit 7389207.
1 parent 7389207 commit 3178f15

File tree

4 files changed

+6
-30
lines changed

4 files changed

+6
-30
lines changed

‎extension.neon

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -298,14 +298,5 @@ services:
298298

299299
# InputBag::get() type specification
300300
-
301-
factory: PHPStan\Type\Symfony\BagTypeSpecifyingExtension
301+
factory: PHPStan\Type\Symfony\InputBagTypeSpecifyingExtension
302302
tags: [phpstan.typeSpecifier.methodTypeSpecifyingExtension]
303-
arguments:
304-
className: Symfony\Component\HttpFoundation\InputBag
305-
306-
# HeaderBag::get() type specification
307-
-
308-
factory: PHPStan\Type\Symfony\BagTypeSpecifyingExtension
309-
tags: [phpstan.typeSpecifier.methodTypeSpecifyingExtension]
310-
arguments:
311-
className: Symfony\Component\HttpFoundation\HeaderBag

‎src/Type/Symfony/BagTypeSpecifyingExtension.php renamed to ‎src/Type/Symfony/InputBagTypeSpecifyingExtension.php

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,30 +11,21 @@
1111
use PHPStan\Reflection\MethodReflection;
1212
use PHPStan\Type\MethodTypeSpecifyingExtension;
1313
use PHPStan\Type\NullType;
14+
use Symfony\Component\HttpFoundation\InputBag;
1415

15-
final class BagTypeSpecifyingExtension implements MethodTypeSpecifyingExtension, TypeSpecifierAwareExtension
16+
final class InputBagTypeSpecifyingExtension implements MethodTypeSpecifyingExtension, TypeSpecifierAwareExtension
1617
{
1718

19+
private const INPUT_BAG_CLASS = InputBag::class;
1820
private const HAS_METHOD_NAME = 'has';
1921
private const GET_METHOD_NAME = 'get';
2022

2123
/** @var TypeSpecifier */
2224
private $typeSpecifier;
2325

24-
/** @var class-string */
25-
private $className;
26-
27-
/**
28-
* @param class-string $className
29-
*/
30-
public function __construct(string $className)
31-
{
32-
$this->className = $className;
33-
}
34-
3526
public function getClass(): string
3627
{
37-
return $this->className;
28+
return self::INPUT_BAG_CLASS;
3829
}
3930

4031
public function isMethodSupported(MethodReflection $methodReflection, MethodCall $node, TypeSpecifierContext $context): bool

‎tests/Type/Symfony/ExtensionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class ExtensionTest extends TypeInferenceTestCase
1515
public function dataFileAsserts(): iterable
1616
{
1717
yield from $this->gatherAssertTypes(__DIR__ . '/data/envelope_all.php');
18-
yield from $this->gatherAssertTypes(__DIR__ . '/data/header_bag.php');
18+
yield from $this->gatherAssertTypes(__DIR__ . '/data/header_bag_get.php');
1919
yield from $this->gatherAssertTypes(__DIR__ . '/data/response_header_bag_get_cookies.php');
2020

2121
if (class_exists('Symfony\Component\HttpFoundation\InputBag')) {

‎tests/Type/Symfony/data/header_bag.php renamed to ‎tests/Type/Symfony/data/header_bag_get.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,6 @@
44

55
$bag = new \Symfony\Component\HttpFoundation\HeaderBag(['foo' => ['bar']]);
66

7-
if ($bag->has('bar')) {
8-
assertType('string', $bag->get('bar'));
9-
} else {
10-
assertType('null', $bag->get('bar'));
11-
}
12-
137
assertType('string|null', $bag->get('foo'));
148
assertType('string|null', $bag->get('foo', null));
159
assertType('string', $bag->get('foo', 'baz'));

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /