Skip to content

Commit d2411d6

Browse files
committed
fix failing lints that are not deprecations
1 parent 480245d commit d2411d6

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
@@ -175,9 +173,6 @@ private function doProcessNode(Node\Expr $node, Scope $scope, string $keyChecked
175173
} elseif ($type instanceof ClosureType) {
176174
if ($scope->isInClass()) {
177175
$classReflection = $scope->getClassReflection();
178-
if ($classReflection === null) {
179-
throw new \PHPStan\ShouldNotHappenException();
180-
}
181176
$classType = new ObjectType($classReflection->getName());
182177
$formType = new ObjectType('\Drupal\Core\Form\FormInterface');
183178
if ($formType->isSuperTypeOf($classType)->yes()) {
@@ -245,7 +240,7 @@ private function getType(Node\Expr $node, Scope $scope): Type
245240
}
246241
// @see \PHPStan\Type\Constant\ConstantStringType::isCallable
247242
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);
248-
if ($matches !== null && count($matches) > 0) {
243+
if (count($matches) > 0) {
249244
return new ConstantArrayType(
250245
[new ConstantIntegerType(0), new ConstantIntegerType(1)],
251246
[

0 commit comments

Comments
 (0)