Skip to content

Commit 96a01ee

Browse files
committed
links.php: mark params as nullable
Implicitly marking parameter as nullable is deprecated
1 parent 96332d4 commit 96a01ee

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

tools/links/links.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ class UrlExtractor
495495
* @param bool|string $find If the URL target must be searched for instead of just being considered as a relative path; If a string is given, it will be used as search prefix
496496
* @see UrlExtractor::getDefaultPatterns For an example of pattern map.
497497
*/
498-
public function __construct(array $patterns = null, array $replacements = null, mixed $find = false)
498+
public function __construct(?array $patterns = null, ?array $replacements = null, mixed $find = false)
499499
{
500500
$this->patterns = null === $patterns ? self::getDefaultPatterns() : $patterns;
501501
$this->flattenPatterns();
@@ -580,7 +580,7 @@ private function extractFromArchive(string $archivePath): array
580580
return $urls;
581581
}
582582

583-
private function flattenPatterns(string $reRunExtension = null): self
583+
private function flattenPatterns(?string $reRunExtension = null): self
584584
{
585585
if (array_key_exists('*', $this->patterns)) {
586586
unset($this->patterns['*']);
@@ -825,10 +825,10 @@ class UrlTester
825825
* @param array[]|null $exclusionTests An associative array of arrays of functions testing if a URL should be excluded from test
826826
* @param array|null $replacements A replacement map to apply on each URL
827827
* @param bool|string $find If the URL target must be searched for instead of just being considered as a relative path; If a string is given, it will be used as search prefix
828-
* @param $output
829-
* @param $error
828+
* @param callable|null $output A callable to pass standard output message to
829+
* @param callable|null $error A callable to pass error message to
830830
*/
831-
public function __construct(array $usageFiles = [], array $resourceFiles = [], array $exclusionTests = null, array $replacements = null, mixed $find = false, $output = null, $error = null)
831+
public function __construct(array $usageFiles = [], array $resourceFiles = [], ?array $exclusionTests = null, ?array $replacements = null, mixed $find = false, ?callable $output = null, ?callable $error = null)
832832
{
833833
$this->setUsageFiles($usageFiles);
834834
$this->setResourceFiles($resourceFiles);
@@ -913,22 +913,22 @@ public static function getDefaultExclusionTests(): array
913913
{
914914
return [
915915
'url' => [
916-
function (string $url, string $file = null): bool {
916+
function (string $url, ?string $file = null): bool {
917917
return str_contains($url, 'example.com');
918918
},
919919
],
920920
'header' => [
921-
function (string $url, int $code, array $headers, string $file = null) {
921+
function (string $url, int $code, array $headers, ?string $file = null) {
922922
return 403 === $code && in_array('Server: cloudflare', $headers);
923923
},
924924
],
925925
'location' => [
926-
//function (string $url, string $location, string $file = null): bool {
926+
//function (string $url, string $location, ?string $file = null): bool {
927927
// return …;
928928
//},
929929
],
930930
'fragment' => [
931-
function (string $url, string $file = null): bool {
931+
function (string $url, ?string $file = null): bool {
932932
if (str_starts_with($url, 'https://github.com/')) {
933933
$fragment = TestableUrl::getUrlFragment($url);
934934
if (preg_match('@^L[0-9]+(-L[0-9]+)?$@', $fragment)) {
@@ -939,7 +939,7 @@ function (string $url, string $file = null): bool {
939939
}
940940
return false;
941941
},
942-
function (string $url, string $file = null): bool {
942+
function (string $url, ?string $file = null): bool {
943943
return preg_match('@\.eot\?#@', $url);
944944
},
945945
],
@@ -1168,7 +1168,7 @@ public static function formatUrl(string $url): string
11681168
return $url;
11691169
}
11701170

1171-
private function outputUrl(TestableUrl $testableUrl, TestableUrl $testedUrl = null, $withFile = false, $withLine = true, $withCode = true): self
1171+
private function outputUrl(TestableUrl $testableUrl, ?TestableUrl $testedUrl = null, $withFile = false, $withLine = true, $withCode = true): self
11721172
{
11731173
$file = $testableUrl->getFile();
11741174
$file = $withFile && $file !== null ? "{$file}@" : '';
@@ -1221,7 +1221,7 @@ class Finder
12211221
private $includedTypes = [];
12221222
private $excludedTypes = [];
12231223

1224-
public function __construct(string $where = '.', int $minDepth = null, int $maxDepth = null)
1224+
public function __construct(string $where = '.', ?int $minDepth = null, ?int $maxDepth = null)
12251225
{
12261226
$this->where = preg_replace('@/$@', '', $where);
12271227
$this->minDepth = $minDepth;
@@ -1384,7 +1384,7 @@ private static function buildFinder($where, $minDepth = null, $maxDepth = null,
13841384
return $finder;
13851385
}
13861386

1387-
static function newUrlTesterFromCommand(array $argv, array $exclusionTests = null, array $replacements = null, mixed $find = false): UrlTester
1387+
static function newUrlTesterFromCommand(array $argv, ?array $exclusionTests = null, ?array $replacements = null, mixed $find = false): UrlTester
13881388
{
13891389
$finders = [
13901390
'usage' => [],

0 commit comments

Comments
 (0)