Skip to content

Commit 27a5d0f

Browse files
committed
Rename cmp_function parameters to callback
1 parent 3a773ac commit 27a5d0f

3 files changed

Lines changed: 18 additions & 59 deletions

File tree

resources/functionMap.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,8 @@
346346
'ArrayIterator::seek' => ['void', 'position'=>'int'],
347347
'ArrayIterator::serialize' => ['string'],
348348
'ArrayIterator::setFlags' => ['void', 'flags'=>'string'],
349-
'ArrayIterator::uasort' => ['void', 'cmp_function'=>'callable(mixed,mixed):int'],
350-
'ArrayIterator::uksort' => ['void', 'cmp_function'=>'callable(array-key,array-key):int'],
349+
'ArrayIterator::uasort' => ['void', 'callback'=>'callable(mixed,mixed):int'],
350+
'ArrayIterator::uksort' => ['void', 'callback'=>'callable(array-key,array-key):int'],
351351
'ArrayIterator::unserialize' => ['void', 'serialized'=>'string'],
352352
'ArrayIterator::valid' => ['bool'],
353353
'ArrayObject::__construct' => ['void', 'input='=>'array|object', 'flags='=>'int', 'iterator_class='=>'string'],
@@ -369,8 +369,8 @@
369369
'ArrayObject::serialize' => ['string'],
370370
'ArrayObject::setFlags' => ['void', 'flags'=>'int'],
371371
'ArrayObject::setIteratorClass' => ['void', 'iterator_class'=>'string'],
372-
'ArrayObject::uasort' => ['void', 'cmp_function'=>'callable'],
373-
'ArrayObject::uksort' => ['void', 'cmp_function'=>'callable(array-key,array-key):int'],
372+
'ArrayObject::uasort' => ['void', 'callback'=>'callable'],
373+
'ArrayObject::uksort' => ['void', 'callback'=>'callable(array-key,array-key):int'],
374374
'ArrayObject::unserialize' => ['void', 'serialized'=>'string'],
375375
'arsort' => ['bool', '&rw_array_arg'=>'array', 'sort_flags='=>'int'],
376376
'asin' => ['float', 'number'=>'float'],
@@ -9174,8 +9174,8 @@
91749174
'RecursiveArrayIterator::seek' => ['void', 'position'=>'int'],
91759175
'RecursiveArrayIterator::serialize' => ['string'],
91769176
'RecursiveArrayIterator::setFlags' => ['void', 'flags'=>'string'],
9177-
'RecursiveArrayIterator::uasort' => ['void', 'cmp_function'=>'callable(mixed,mixed):int'],
9178-
'RecursiveArrayIterator::uksort' => ['void', 'cmp_function'=>'callable(array-key,array-key):int'],
9177+
'RecursiveArrayIterator::uasort' => ['void', 'callback'=>'callable(mixed,mixed):int'],
9178+
'RecursiveArrayIterator::uksort' => ['void', 'callback'=>'callable(array-key,array-key):int'],
91799179
'RecursiveArrayIterator::unserialize' => ['string', 'serialized'=>'string'],
91809180
'RecursiveArrayIterator::valid' => ['bool'],
91819181
'RecursiveCachingIterator::__construct' => ['void', 'iterator'=>'Iterator', 'flags'=>''],
@@ -12565,7 +12565,7 @@
1256512565
'TypeError::getPrevious' => ['Throwable|TypeError|null'],
1256612566
'TypeError::getTrace' => ['array'],
1256712567
'TypeError::getTraceAsString' => ['string'],
12568-
'uasort' => ['bool', '&rw_array_arg'=>'array', 'cmp_function'=>'callable(mixed,mixed):int'],
12568+
'uasort' => ['bool', '&rw_array_arg'=>'array', 'callback'=>'callable(mixed,mixed):int'],
1256912569
'ucfirst' => ['string', 'str'=>'string'],
1257012570
'UConverter::__construct' => ['void', 'destination_encoding'=>'string', 'source_encoding='=>'string'],
1257112571
'UConverter::convert' => ['string', 'str'=>'string', 'reverse='=>'bool'],
@@ -12614,7 +12614,7 @@
1261412614
'ui\draw\text\font\fontfamilies' => ['array'],
1261512615
'ui\quit' => ['void'],
1261612616
'ui\run' => ['void', 'flags='=>'int'],
12617-
'uksort' => ['bool', '&rw_array_arg'=>'array', 'cmp_function'=>'callable(array-key,array-key):int'],
12617+
'uksort' => ['bool', '&rw_array_arg'=>'array', 'callback'=>'callable(array-key,array-key):int'],
1261812618
'umask' => ['int', 'mask='=>'int'],
1261912619
'UnderflowException::__clone' => ['void'],
1262012620
'UnderflowException::__construct' => ['void', 'message='=>'string', 'code='=>'int', 'previous='=>'(?Throwable)|(?UnderflowException)'],
@@ -12694,7 +12694,7 @@
1269412694
'urlencode' => ['string', 'str'=>'string'],
1269512695
'use_soap_error_handler' => ['bool', 'handler='=>'bool'],
1269612696
'usleep' => ['void', 'micro_seconds'=>'int'],
12697-
'usort' => ['bool', '&rw_array_arg'=>'array', 'cmp_function'=>'callable(mixed,mixed):int'],
12697+
'usort' => ['bool', '&rw_array_arg'=>'array', 'callback'=>'callable(mixed,mixed):int'],
1269812698
'utf8_decode' => ['string', 'data'=>'string'],
1269912699
'utf8_encode' => ['string', 'data'=>'string'],
1270012700
'V8Js::__construct' => ['void', 'object_name='=>'string', 'variables='=>'array', 'extensions='=>'array', 'report_uncaught_exceptions='=>'bool', 'snapshot_blob='=>'string'],

tests/PHPStan/Reflection/SignatureMap/Php8SignatureMapProviderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ public function dataMethods(): array
220220
'uasort',
221221
[
222222
[
223-
'name' => 'cmp_function',
223+
'name' => 'callback',
224224
'optional' => false,
225225
'type' => new CallableType([
226226
new NativeParameterReflection('', false, new MixedType(true), PassedByReference::createNo(), false, null),

tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php

Lines changed: 8 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -630,16 +630,9 @@ public function testArrayWalkArrowFunctionCallback(): void
630630

631631
public function testUasortCallback(): void
632632
{
633-
$paramTwoName = PHP_VERSION_ID >= 80000
634-
? 'callback'
635-
: 'cmp_function';
636-
637633
$this->analyse([__DIR__ . '/data/uasort.php'], [
638634
[
639-
sprintf(
640-
'Parameter #2 $%s of function uasort expects callable(int, int): int, Closure(string, string): 1 given.',
641-
$paramTwoName
642-
),
635+
'Parameter #2 $callback of function uasort expects callable(int, int): int, Closure(string, string): 1 given.',
643636
7,
644637
],
645638
]);
@@ -650,33 +643,20 @@ public function testUasortArrowFunctionCallback(): void
650643
if (PHP_VERSION_ID < 70400 && !self::$useStaticReflectionProvider) {
651644
$this->markTestSkipped('Test requires PHP 7.4.');
652645
}
653-
$paramTwoName = PHP_VERSION_ID >= 80000
654-
? 'callback'
655-
: 'cmp_function';
656646

657647
$this->analyse([__DIR__ . '/data/uasort_arrow.php'], [
658648
[
659-
sprintf(
660-
'Parameter #2 $%s of function uasort expects callable(int, int): int, Closure(string, string): 1 given.',
661-
$paramTwoName
662-
),
649+
'Parameter #2 $callback of function uasort expects callable(int, int): int, Closure(string, string): 1 given.',
663650
7,
664651
],
665652
]);
666653
}
667654

668655
public function testUsortCallback(): void
669656
{
670-
$paramTwoName = PHP_VERSION_ID >= 80000
671-
? 'callback'
672-
: 'cmp_function';
673-
674657
$this->analyse([__DIR__ . '/data/usort.php'], [
675658
[
676-
sprintf(
677-
'Parameter #2 $%s of function usort expects callable(int, int): int, Closure(string, string): 1 given.',
678-
$paramTwoName
679-
),
659+
'Parameter #2 $callback of function usort expects callable(int, int): int, Closure(string, string): 1 given.',
680660
14,
681661
],
682662
]);
@@ -688,37 +668,23 @@ public function testUsortArrowFunctionCallback(): void
688668
$this->markTestSkipped('Test requires PHP 7.4.');
689669
}
690670

691-
$paramTwoName = PHP_VERSION_ID >= 80000
692-
? 'callback'
693-
: 'cmp_function';
694-
695671
$this->analyse([__DIR__ . '/data/usort_arrow.php'], [
696672
[
697-
sprintf(
698-
'Parameter #2 $%s of function usort expects callable(int, int): int, Closure(string, string): 1 given.',
699-
$paramTwoName
700-
),
673+
'Parameter #2 $callback of function usort expects callable(int, int): int, Closure(string, string): 1 given.',
701674
14,
702675
],
703676
]);
704677
}
705678

706679
public function testUksortCallback(): void
707680
{
708-
$paramTwoName = PHP_VERSION_ID >= 80000
709-
? 'callback'
710-
: 'cmp_function';
711-
712681
$this->analyse([__DIR__ . '/data/uksort.php'], [
713682
[
714-
sprintf(
715-
'Parameter #2 $%s of function uksort expects callable(string, string): int, Closure(stdClass, stdClass): 1 given.',
716-
$paramTwoName
717-
),
683+
'Parameter #2 $callback of function uksort expects callable(string, string): int, Closure(stdClass, stdClass): 1 given.',
718684
14,
719685
],
720686
[
721-
sprintf('Parameter #2 $%s of function uksort expects callable(int, int): int, Closure(string, string): 1 given.', $paramTwoName),
687+
'Parameter #2 $callback of function uksort expects callable(int, int): int, Closure(string, string): 1 given.',
722688
50,
723689
],
724690
]);
@@ -730,20 +696,13 @@ public function testUksortArrowFunctionCallback(): void
730696
$this->markTestSkipped('Test requires PHP 7.4.');
731697
}
732698

733-
$paramTwoName = PHP_VERSION_ID >= 80000
734-
? 'callback'
735-
: 'cmp_function';
736-
737699
$this->analyse([__DIR__ . '/data/uksort_arrow.php'], [
738700
[
739-
sprintf(
740-
'Parameter #2 $%s of function uksort expects callable(string, string): int, Closure(stdClass, stdClass): 1 given.',
741-
$paramTwoName
742-
),
701+
'Parameter #2 $callback of function uksort expects callable(string, string): int, Closure(stdClass, stdClass): 1 given.',
743702
14,
744703
],
745704
[
746-
sprintf('Parameter #2 $%s of function uksort expects callable(int, int): int, Closure(string, string): 1 given.', $paramTwoName),
705+
'Parameter #2 $callback of function uksort expects callable(int, int): int, Closure(string, string): 1 given.',
747706
44,
748707
],
749708
]);

0 commit comments

Comments
 (0)