Skip to content

Commit a5cd01a

Browse files
committed
Fix PHPStan warnings
1 parent ea3b48d commit a5cd01a

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

build/BuildMetadataPHPFromXml.php

+4
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ private function writeMetadataToFile(array $metadataCollection, string $director
7171

7272
$pos = strrpos($namespaceAndClassPrefix, '\\');
7373

74+
if ($pos === false) {
75+
throw new \RuntimeException('Invalid namespaceAndClassPrefix: ' . $namespaceAndClassPrefix);
76+
}
77+
7478
$namespace = substr($namespaceAndClassPrefix, 0, $pos);
7579
$classPrefix = substr($namespaceAndClassPrefix, $pos + 1);
7680

build/Builders/PhoneMetadataBuilder.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
/**
1818
* @internal
19-
* @phpstan-import-type PhoneNumberDescArray from PhoneNumberDesc
2019
*/
2120
class PhoneMetadataBuilder extends PhoneMetadata
2221
{
@@ -360,7 +359,7 @@ public function toFile(string $className, string $namespaceName): PhpFile
360359
$class->removeProperty($property->getName());
361360

362361
if (!$propertyValue instanceof PhoneNumberDesc) {
363-
throw new RuntimeException('Unsupported type: ' . gettype($value));
362+
throw new RuntimeException('Unsupported type: ' . gettype($propertyValue));
364363
}
365364

366365
$chained = [];

src/MultiFileMetadataSourceImpl.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ public function loadMetadataFromFile(string $filePrefix, string $regionCode, int
6969

7070
$isNonGeoRegion = PhoneNumberUtil::REGION_CODE_FOR_NON_GEO_ENTITY === $regionCode;
7171

72-
7372
$class = $filePrefix . ($isNonGeoRegion ? $countryCallingCode : ucfirst($regionCode));
7473

7574
if (!class_exists($class)) {
@@ -78,6 +77,10 @@ public function loadMetadataFromFile(string $filePrefix, string $regionCode, int
7877

7978
$metadata = new $class();
8079

80+
if (!$metadata instanceof PhoneMetadata) {
81+
throw new RuntimeException('invalid metadata: ' . $class);
82+
}
83+
8184
if ($isNonGeoRegion) {
8285
$this->countryCodeToNonGeographicalMetadataMap[$countryCallingCode] = $metadata;
8386
} else {

0 commit comments

Comments
 (0)