From e0b8e58c60c201aa4538dad171e54a22c36bd09c Mon Sep 17 00:00:00 2001 From: Ayesh Karunaratne Date: Fri, 15 Mar 2024 03:06:27 +0700 Subject: [PATCH] [PHP 8.4] Fixes for implicit nullability deprecation Fixes all issues that emits a deprecation notice on PHP 8.4. See: - [RFC](https://wiki.php.net/rfc/deprecate-implicitly-nullable-types) - [PHP 8.4: Implicitly nullable parameter declarations deprecated](https://php.watch/versions/8.4/implicitly-marking-parameter-type-nullable-deprecated) --- src/ClassMapGenerator.php | 4 ++-- src/PhpFileCleaner.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ClassMapGenerator.php b/src/ClassMapGenerator.php index fd905c3..53f9a42 100644 --- a/src/ClassMapGenerator.php +++ b/src/ClassMapGenerator.php @@ -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; @@ -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"'); diff --git a/src/PhpFileCleaner.php b/src/PhpFileCleaner.php index 3a74478..7c0f72a 100644 --- a/src/PhpFileCleaner.php +++ b/src/PhpFileCleaner.php @@ -240,7 +240,7 @@ private function peek(string $char): bool * @param non-empty-string $regex * @param null|array $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); }