Skip to content

Commit 9315cf7

Browse files
committed
Merge branch 'main' into issue/478
2 parents a49db03 + d2411d6 commit 9315cf7

File tree

4 files changed

+2
-14
lines changed

4 files changed

+2
-14
lines changed

src/Drupal/ExtensionDiscovery.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ protected function scanDirectory($dir): array
376376
// Determine extension type from info file.
377377
$type = false;
378378
$file = $fileinfo->openFile('r');
379-
while (!$type && !$file->eof()) {
379+
while ($type === false && !$file->eof()) {
380380
if ($line = $file->fgets()) {
381381
preg_match('@^type:\s*(\'|")?(\w+)\1?\s*$@', $line, $matches);
382382
if (isset($matches[2])) {

src/Rules/Drupal/GlobalDrupalDependencyInjectionRule.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@ public function processNode(Node $node, Scope $scope): array
2828
return [];
2929
}
3030
$scopeClassReflection = $scope->getClassReflection();
31-
if ($scopeClassReflection === null) {
32-
throw new ShouldNotHappenException();
33-
}
3431

3532
$allowed_list = [
3633
// Ignore tests.

src/Rules/Drupal/PluginManager/PluginManagerSetsCacheBackendRule.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,6 @@ public function processNode(Node $node, Scope $scope): array
3838

3939
$scopeClassReflection = $scope->getClassReflection();
4040

41-
if ($scopeClassReflection === null) {
42-
throw new ShouldNotHappenException();
43-
}
44-
4541
if (!$this->isPluginManager($scopeClassReflection)) {
4642
return [];
4743
}

src/Rules/Drupal/RenderCallbackRule.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ public function processNode(Node $node, Scope $scope): array
6868
if ($keyChecked === '#lazy_builder') {
6969
if ($scope->isInClass()) {
7070
$classReflection = $scope->getClassReflection();
71-
// @todo why doesn't isInClass assert this isn't null?
72-
assert($classReflection !== null);
7371
$classType = new ObjectType($classReflection->getName());
7472
// These classes use #lazy_builder in array_intersect_key. With
7573
// PHPStan 1.6, nodes do not track their parent/next/prev which
@@ -177,9 +175,6 @@ private function doProcessNode(Node\Expr $node, Scope $scope, string $keyChecked
177175
} elseif ($type instanceof ClosureType) {
178176
if ($scope->isInClass()) {
179177
$classReflection = $scope->getClassReflection();
180-
if ($classReflection === null) {
181-
throw new \PHPStan\ShouldNotHappenException();
182-
}
183178
$classType = new ObjectType($classReflection->getName());
184179
$formType = new ObjectType('\Drupal\Core\Form\FormInterface');
185180
if ($formType->isSuperTypeOf($classType)->yes()) {
@@ -247,7 +242,7 @@ private function getType(Node\Expr $node, Scope $scope): Type
247242
}
248243
// @see \PHPStan\Type\Constant\ConstantStringType::isCallable
249244
preg_match('#^([a-zA-Z_\\x7f-\\xff\\\\][a-zA-Z0-9_\\x7f-\\xff\\\\]*)::([a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*)\\z#', $type->getValue(), $matches);
250-
if ($matches !== null && count($matches) > 0) {
245+
if (count($matches) > 0) {
251246
return new ConstantArrayType(
252247
[new ConstantIntegerType(0), new ConstantIntegerType(1)],
253248
[

0 commit comments

Comments
 (0)