Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix count_chars stubs #7094

Merged
merged 2 commits into from Dec 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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