Skip to content

Commit

Permalink
Merge pull request #7094 from kamil-tekiela/count_chars-fix
Browse files Browse the repository at this point in the history
Fix count_chars stubs
  • Loading branch information
orklah committed Dec 8, 2021
2 parents eefdb95 + 098238f commit 761d5f3
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 26 deletions.
7 changes: 2 additions & 5 deletions dictionaries/CallMap.php
Expand Up @@ -1542,11 +1542,8 @@
'Couchbase\zlibCompress' => ['string', 'data'=>'string'],
'Couchbase\zlibDecompress' => ['string', 'data'=>'string'],
'count' => ['int', 'value'=>'Countable|array|SimpleXMLElement|ResourceBundle', 'mode='=>'int'],
'count_chars' => ['array<int,int>', 'input'=>'string', 'mode='=>'0'],
'count_chars\'1' => ['array<int,int>', 'input'=>'string', 'mode='=>'1'],
'count_chars\'2' => ['array<int,int>', 'input'=>'string', 'mode='=>'2'],
'count_chars\'3' => ['string', 'input'=>'string', 'mode='=>'3'],
'count_chars\'4' => ['string', 'input'=>'string', 'mode='=>'4'],
'count_chars' => ['array<int,int>', 'input'=>'string', 'mode='=>'0|1|2'],
'count_chars\'1' => ['string', 'input'=>'string', 'mode='=>'3|4'],
'Countable::count' => ['int'],
'crack_check' => ['bool', 'dictionary'=>'', 'password'=>'string'],
'crack_closedict' => ['bool', 'dictionary='=>'resource'],
Expand Down
20 changes: 4 additions & 16 deletions dictionaries/CallMap_80_delta.php
Expand Up @@ -174,24 +174,12 @@
'new' => ['bool', 'typelib_name'=>'string', 'case_insensitive='=>'true'],
],
'count_chars' => [
'old' => ['array<int,int>|false', 'input'=>'string', 'mode='=>'0'],
'new' => ['array<int,int>', 'input'=>'string', 'mode='=>'0'],
'old' => ['array<int,int>|false', 'input'=>'string', 'mode='=>'0|1|2'],
'new' => ['array<int,int>', 'input'=>'string', 'mode='=>'0|1|2'],
],
'count_chars\'1' => [
'old' => ['array<int,int>|false', 'input'=>'string', 'mode='=>'1'],
'new' => ['array<int,int>', 'input'=>'string', 'mode='=>'1'],
],
'count_chars\'2' => [
'old' => ['array<int,int>|false', 'input'=>'string', 'mode='=>'2'],
'new' => ['array<int,int>', 'input'=>'string', 'mode='=>'2'],
],
'count_chars\'3' => [
'old' => ['string|false', 'input'=>'string', 'mode='=>'3'],
'new' => ['string', 'input'=>'string', 'mode='=>'3'],
],
'count_chars\'4' => [
'old' => ['string|false', 'input'=>'string', 'mode='=>'4'],
'new' => ['string', 'input'=>'string', 'mode='=>'4'],
'old' => ['string|false', 'input'=>'string', 'mode='=>'3|4'],
'new' => ['string', 'input'=>'string', 'mode='=>'3|4'],
],
'curl_close' => [
'old' => ['void', 'ch'=>'resource'],
Expand Down
7 changes: 2 additions & 5 deletions dictionaries/CallMap_historical.php
Expand Up @@ -10000,11 +10000,8 @@
'cos' => ['float', 'num'=>'float'],
'cosh' => ['float', 'num'=>'float'],
'count' => ['int', 'value'=>'Countable|array|SimpleXMLElement|ResourceBundle', 'mode='=>'int'],
'count_chars' => ['array<int,int>|false', 'input'=>'string', 'mode='=>'0'],
'count_chars\'1' => ['array<int,int>|false', 'input'=>'string', 'mode='=>'1'],
'count_chars\'2' => ['array<int,int>|false', 'input'=>'string', 'mode='=>'2'],
'count_chars\'3' => ['string|false', 'input'=>'string', 'mode='=>'3'],
'count_chars\'4' => ['string|false', 'input'=>'string', 'mode='=>'4'],
'count_chars' => ['array<int,int>|false', 'input'=>'string', 'mode='=>'0|1|2'],
'count_chars\'1' => ['string|false', 'input'=>'string', 'mode='=>'3|4'],
'crack_check' => ['bool', 'dictionary'=>'', 'password'=>'string'],
'crack_closedict' => ['bool', 'dictionary='=>'resource'],
'crack_getlastmessage' => ['string'],
Expand Down
25 changes: 25 additions & 0 deletions tests/FunctionCallTest.php
Expand Up @@ -1747,6 +1747,24 @@ function sayHello(string $needle): void {
[],
'8.1',
],
'count_charsProducesArrayOrString' => [
'<?php
$a = count_chars("foo");
$b = count_chars("foo", 1);
$c = count_chars("foo", 2);
$d = count_chars("foo", 3);
$e = count_chars("foo", 4);
',
'assertions' => [
'$a===' => 'array<int, int>',
'$b===' => 'array<int, int>',
'$c===' => 'array<int, int>',
'$d===' => 'string',
'$e===' => 'string',
],
[],
'8.1',
],
];
}

Expand Down Expand Up @@ -2284,6 +2302,13 @@ function takesAString(string $s): void{
echo get_class();',
'error_message' => 'TooFewArguments',
],
'count_charsWithInvalidMode' => [
'<?php
function scope(int $mode){
$a = count_chars("foo", $mode);
}',
'error_message' => 'ArgumentTypeCoercion',
],
];
}

Expand Down

0 comments on commit 761d5f3

Please sign in to comment.