Skip to content

Commit 0c45325

Browse files
committed
Treat PHPDoc types as certain
1 parent 5510aff commit 0c45325

7 files changed

Lines changed: 18 additions & 22 deletions

File tree

phpstan.neon.dist

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,12 @@ parameters:
2121
identifier: staticMethod.dynamicCall
2222
path: tests
2323

24-
checkUninitializedProperties: true
25-
2624
checkBenevolentUnionTypes: true
2725
checkTooWideReturnTypesInProtectedAndPublicMethods: true
26+
checkUninitializedProperties: true
2827
reportAlwaysTrueInLastCondition: true
2928
reportPossiblyNonexistentConstantArrayOffset: true
30-
treatPhpDocTypesAsCertain: false
29+
3130
includes:
3231
- vendor/cuyz/valinor/qa/PHPStan/valinor-phpstan-configuration.php
3332
- vendor/phpstan/phpstan/conf/bleedingEdge.neon

src/Firebase/Auth/ActionCodeSettings/ValidatedActionCodeSettings.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,7 @@ public static function fromArray(array $settings): self
6060
switch (mb_strtolower($key)) {
6161
case 'continueurl':
6262
case 'url':
63-
$instance->continueUrl = ($value !== null)
64-
? Utils::uriFor(self::ensureNonEmptyString($value))
65-
: null;
63+
$instance->continueUrl = Utils::uriFor(self::ensureNonEmptyString($value));
6664

6765
break;
6866

src/Firebase/Messaging/AppInstance.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public static function fromRawData(RegistrationToken $registrationToken, array $
3838
$subscriptions = [];
3939

4040
foreach ($rawData['rel']['topics'] ?? [] as $topicName => $subscriptionInfo) {
41-
$topic = Topic::fromValue((string) $topicName);
41+
$topic = Topic::fromValue($topicName);
4242
$addedAt = DT::toUTCDateTimeImmutable($subscriptionInfo['addDate'] ?? null);
4343
$subscriptions[] = new TopicSubscription($topic, $registrationToken, $addedAt);
4444
}

src/Firebase/RemoteConfig/Template.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,12 +244,12 @@ private static function buildParameter(string $name, array $data): Parameter
244244
$valueType = ParameterValueType::tryFrom($data['valueType'] ?? '') ?? ParameterValueType::UNSPECIFIED;
245245

246246
$parameter = Parameter::named($name)
247-
->withDescription((string) ($data['description'] ?? ''))
247+
->withDescription($data['description'] ?? '')
248248
->withDefaultValue($data['defaultValue'] ?? null)
249249
->withValueType($valueType)
250250
;
251251

252-
foreach ((array) ($data['conditionalValues'] ?? []) as $key => $conditionalValueData) {
252+
foreach (($data['conditionalValues'] ?? []) as $key => $conditionalValueData) {
253253
$parameter = $parameter->withConditionalValue(new ConditionalValue($key, ParameterValue::fromArray($conditionalValueData)));
254254
}
255255

@@ -263,7 +263,7 @@ private static function buildParameter(string $name, array $data): Parameter
263263
private static function buildParameterGroup(string $name, array $parameterGroupData): ParameterGroup
264264
{
265265
$group = ParameterGroup::named($name)
266-
->withDescription((string) ($parameterGroupData['description'] ?? ''))
266+
->withDescription($parameterGroupData['description'] ?? '')
267267
;
268268

269269
foreach ($parameterGroupData['parameters'] as $parameterName => $parameterData) {

src/Firebase/Valinor/Source.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,17 @@ public static function file(string $value): self
5757
throw new InvalidArgumentException(message: $e->getMessage(), previous: $e);
5858
}
5959

60-
$content = $file->fread($file->getSize());
60+
$fileSize = $file->getSize();
6161
$pathName = $file->getPathname();
6262

63+
if (!is_int($fileSize)) {
64+
throw new InvalidArgumentException("Unable to get filesize of `$pathName`");
65+
}
66+
67+
$content = $file->fread($fileSize);
68+
6369
if ($content === false) {
64-
throw new InvalidArgumentException("Unable to parse `$pathName`");
70+
throw new InvalidArgumentException("Unable to read `$pathName`");
6571
}
6672

6773
return self::json($content);

tests/Unit/Http/HttpClientOptionsTest.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,6 @@ public function itAcceptsSingleCallableMiddlewares(): void
103103
$middlewares = $options->guzzleMiddlewares();
104104

105105
$this->assertCount(1, $middlewares);
106-
$this->assertIsCallable($middlewares[0]['middleware']);
107-
$this->assertSame('name', $middlewares[0]['name']);
108106
}
109107

110108
#[Test]
@@ -128,13 +126,8 @@ public static function handle(): void
128126

129127
$this->assertCount(3, $middlewares);
130128

131-
$this->assertIsCallable($middlewares[0]['middleware']);
132129
$this->assertSame('', $middlewares[0]['name']);
133-
134-
$this->assertIsCallable($middlewares[1]['middleware']);
135130
$this->assertSame('Foo', $middlewares[1]['name']);
136-
137-
$this->assertIsCallable($middlewares[2]['middleware']);
138131
$this->assertSame('Bar', $middlewares[2]['name']);
139132
}
140133

tests/Unit/ServiceAccountTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@
66

77
use Kreait\Firebase\ServiceAccount;
88
use Kreait\Firebase\Valinor\Mapper;
9+
use PHPUnit\Framework\Attributes\DoesNotPerformAssertions;
910
use PHPUnit\Framework\TestCase;
1011

1112
final class ServiceAccountTest extends TestCase
1213
{
1314
/**
1415
* @see https://github.com/kreait/firebase-php/pull/1034
1516
*/
17+
#[DoesNotPerformAssertions]
1618
public function testItCanBeMapped(): void
1719
{
1820
$mapper = (new Mapper())->allowSuperfluousKeys()->snakeToCamelCase();
@@ -24,8 +26,6 @@ public function testItCanBeMapped(): void
2426
'private_key' => 'private-key',
2527
];
2628

27-
$serviceAccount = $mapper->map(ServiceAccount::class, $input);
28-
29-
$this->assertInstanceOf(ServiceAccount::class, $serviceAccount);
29+
$mapper->map(ServiceAccount::class, $input);
3030
}
3131
}

0 commit comments

Comments
 (0)