1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00

Create test for count_chars

This commit is contained in:
Kamil Tekiela 2021-12-07 22:02:32 +00:00
parent 88ce10b1dc
commit 098238ff7f

View File

@ -1747,6 +1747,24 @@ class FunctionCallTest extends TestCase
[],
'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',
],
];
}
@ -2284,6 +2302,13 @@ class FunctionCallTest extends TestCase
echo get_class();',
'error_message' => 'TooFewArguments',
],
'count_charsWithInvalidMode' => [
'<?php
function scope(int $mode){
$a = count_chars("foo", $mode);
}',
'error_message' => 'ArgumentTypeCoercion',
],
];
}