Skip to content

Commit

Permalink
Fix PHP 8.4 deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
TomA-R committed Dec 13, 2024
1 parent aaa144e commit 64e0544
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion PhpcsChanged/CacheManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class CacheManager {
*/
private $debug;

public function __construct(CacheInterface $cache, callable $debug = null) {
public function __construct(CacheInterface $cache, ?callable $debug = null) {
$this->cache = $cache;
$noopDebug =
/** @param string[] $output */
Expand Down
2 changes: 1 addition & 1 deletion PhpcsChanged/Cli.php
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ function fileHasValidExtension(\SplFileInfo $file, string $phpcsExtensions = '')
// phpcs:enable
}

function shouldIgnorePath(string $path, string $patternOption = null): bool {
function shouldIgnorePath(string $path, ?string $patternOption = null): bool {
if (null===$patternOption) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion PhpcsChanged/LintMessages.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static function merge(array $messages) {
/**
* @return static
*/
public static function fromLintMessages(array $messages, string $fileName = null) {
public static function fromLintMessages(array $messages, ?string $fileName = null) {
return new static(array_map(function(LintMessage $message) use ($fileName) {
if (is_string($fileName) && strlen($fileName) > 0) {
$message->setFile($fileName);
Expand Down
4 changes: 2 additions & 2 deletions PhpcsChanged/PhpcsMessages.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ public function toPhpcsJson(): string {
return PhpcsMessagesHelpers::toPhpcsJson($this);
}

public static function fromPhpcsJson(string $messages, string $forcedFileName = null): self {
public static function fromPhpcsJson(string $messages, ?string $forcedFileName = null): self {
return PhpcsMessagesHelpers::fromPhpcsJson($messages, $forcedFileName);
}

public static function fromArrays(array $messages, string $fileName = null): self {
public static function fromArrays(array $messages, ?string $fileName = null): self {
return PhpcsMessagesHelpers::fromArrays($messages, $fileName);
}
}
4 changes: 2 additions & 2 deletions PhpcsChanged/PhpcsMessagesHelpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use PhpcsChanged\JsonReporter;

class PhpcsMessagesHelpers {
public static function fromPhpcsJson(string $messages, string $forcedFileName = null): PhpcsMessages {
public static function fromPhpcsJson(string $messages, ?string $forcedFileName = null): PhpcsMessages {
if (! boolval($messages)) {
return self::fromArrays([], $forcedFileName ?? 'STDIN');
}
Expand Down Expand Up @@ -43,7 +43,7 @@ public static function toPhpcsJson(PhpcsMessages $messages): string {
return $reporter->getFormattedMessages($messages, []);
}

public static function fromArrays(array $messages, string $fileName = null): PhpcsMessages {
public static function fromArrays(array $messages, ?string $fileName = null): PhpcsMessages {
return new PhpcsMessages(array_map(function(array $messageArray) use ($fileName) {
return new LintMessage($messageArray['line'] ?? 0, $fileName, $messageArray['type'] ?? 'ERROR', $messageArray);
}, $messages));
Expand Down
2 changes: 1 addition & 1 deletion PhpcsChanged/UnixShell.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ private function getVendorPhpcsPath(): string {
return 'vendor/bin/phpcs';
}

protected function executeCommand(string $command, int &$return_val = null): string {
protected function executeCommand(string $command, ?int &$return_val = null): string {
$output = [];
exec($command, $output, $return_val);
return implode(PHP_EOL, $output) . PHP_EOL;
Expand Down
2 changes: 1 addition & 1 deletion tests/helpers/SvnFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function getNewFileDiff(string $filename): string {
EOF;
}

public function getSvnInfo(string $filename, string $revision = '188280', string $lastChangedRevision = null): string {
public function getSvnInfo(string $filename, string $revision = '188280', ?string $lastChangedRevision = null): string {
$lastChangedRevision = $lastChangedRevision ?? $revision;
return <<<EOF
Path: {$filename}
Expand Down
2 changes: 1 addition & 1 deletion tests/helpers/TestShell.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function getFileHash(string $fileName): string {
return $this->fileHashes[$fileName] ?? $fileName;
}

protected function executeCommand(string $command, int &$return_val = null): string {
protected function executeCommand(string $command, ?int &$return_val = null): string {
foreach ($this->commands as $registeredCommand => $return) {
if ($registeredCommand === substr($command, 0, strlen($registeredCommand)) ) {
$return_val = $return['return_val'];
Expand Down

0 comments on commit 64e0544

Please sign in to comment.