Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PHP 8.4] Fixes for implicit nullability deprecation #5

Merged
merged 1 commit into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/ClassMapGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function __construct(array $extensions = ['php', 'inc'])
*
* @return $this
*/
public function avoidDuplicateScans(FileList $scannedFiles = null): self
public function avoidDuplicateScans(?FileList $scannedFiles = null): self
{
$this->scannedFiles = $scannedFiles ?? new FileList;

Expand Down Expand Up @@ -100,7 +100,7 @@ public function getClassMap(): ClassMap
*
* @throws \RuntimeException When the path is neither an existing file nor directory
*/
public function scanPaths($path, string $excluded = null, string $autoloadType = 'classmap', ?string $namespace = null): void
public function scanPaths($path, ?string $excluded = null, string $autoloadType = 'classmap', ?string $namespace = null): void
{
if (!in_array($autoloadType, ['psr-0', 'psr-4', 'classmap'], true)) {
throw new \InvalidArgumentException('$autoloadType must be one of: "psr-0", "psr-4" or "classmap"');
Expand Down
2 changes: 1 addition & 1 deletion src/PhpFileCleaner.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@
}

if ($char === "<" && $this->peek('<') && $this->match('{<<<[ \t]*+([\'"]?)([a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*+)\\1(?:\r\n|\n|\r)}A', $match)) {
$this->index += \strlen($match[0]);

Check failure on line 102 in src/PhpFileCleaner.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.2)

Offset 0 might not exist on array<int, string>|null.

Check failure on line 102 in src/PhpFileCleaner.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.1)

Offset 0 might not exist on array<int, string>|null.
$this->skipHeredoc($match[2]);

Check failure on line 103 in src/PhpFileCleaner.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.2)

Offset 2 might not exist on array<int, string>|null.

Check failure on line 103 in src/PhpFileCleaner.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.1)

Offset 2 might not exist on array<int, string>|null.
$clean .= 'null';
continue;
}
Expand Down Expand Up @@ -129,9 +129,9 @@
}

$this->index += 1;
if ($this->match(self::$restPattern, $match)) {

Check failure on line 132 in src/PhpFileCleaner.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.2)

Parameter #2 $match of method Composer\ClassMapGenerator\PhpFileCleaner::match() expects array<int, string>|null, array<int|string, string|null>|null given.

Check failure on line 132 in src/PhpFileCleaner.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.1)

Parameter #2 $match of method Composer\ClassMapGenerator\PhpFileCleaner::match() expects array<int, string>|null, array<int|string, string|null>|null given.
$clean .= $char . $match[0];

Check failure on line 133 in src/PhpFileCleaner.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.2)

Offset 0 might not exist on array<int, string>|null.

Check failure on line 133 in src/PhpFileCleaner.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.1)

Offset 0 might not exist on array<int, string>|null.
$this->index += \strlen($match[0]);

Check failure on line 134 in src/PhpFileCleaner.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.2)

Offset 0 might not exist on array<int, string>|null.

Check failure on line 134 in src/PhpFileCleaner.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.1)

Offset 0 might not exist on array<int, string>|null.
} else {
$clean .= $char;
}
Expand Down Expand Up @@ -240,8 +240,8 @@
* @param non-empty-string $regex
* @param null|array<int, string> $match
*/
private function match(string $regex, array &$match = null): bool
private function match(string $regex, ?array &$match = null): bool
{
return Preg::isMatch($regex, $this->contents, $match, 0, $this->index);

Check failure on line 245 in src/PhpFileCleaner.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.2)

Parameter &$match by-ref type of method Composer\ClassMapGenerator\PhpFileCleaner::match() expects array<int, string>|null, array<int|string, string|null> given.

Check failure on line 245 in src/PhpFileCleaner.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.1)

Parameter &$match by-ref type of method Composer\ClassMapGenerator\PhpFileCleaner::match() expects array<int, string>|null, array<int|string, string|null> given.
}
}
Loading