Skip to content

Commit

Permalink
Precise count range
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentLanglet committed Dec 8, 2022
1 parent bce4b55 commit f6051bc
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion dictionaries/CallMap.php
Expand Up @@ -1543,7 +1543,7 @@
'Couchbase\WildcardSearchQuery::jsonSerialize' => ['array'],
'Couchbase\zlibCompress' => ['string', 'data'=>'string'],
'Couchbase\zlibDecompress' => ['string', 'data'=>'string'],
'count' => ['int', 'value'=>'Countable|array', 'mode='=>'int'],
'count' => ['int<0, max>', 'value'=>'Countable|array', 'mode='=>'int'],
'count_chars' => ['array<int,int>', 'input'=>'string', 'mode='=>'0|1|2'],
'count_chars\'1' => ['string', 'input'=>'string', 'mode='=>'3|4'],
'Countable::count' => ['int'],
Expand Down
4 changes: 2 additions & 2 deletions dictionaries/CallMap_80_delta.php
Expand Up @@ -290,8 +290,8 @@
'new' => ['bool', 'typelib_name'=>'string', 'case_insensitive='=>'true'],
],
'count' => [
'old' => ['int', 'value'=>'Countable|array|SimpleXMLElement', 'mode='=>'int'],
'new' => ['int', 'value'=>'Countable|array', 'mode='=>'int'],
'old' => ['int<0, max>', 'value'=>'Countable|array|SimpleXMLElement', 'mode='=>'int'],
'new' => ['int<0, max>', 'value'=>'Countable|array', 'mode='=>'int'],
],
'count_chars' => [
'old' => ['array<int,int>|false', 'input'=>'string', 'mode='=>'0|1|2'],
Expand Down
2 changes: 1 addition & 1 deletion dictionaries/CallMap_historical.php
Expand Up @@ -10084,7 +10084,7 @@
'copy' => ['bool', 'from'=>'string', 'to'=>'string', 'context='=>'resource'],
'cos' => ['float', 'num'=>'float'],
'cosh' => ['float', 'num'=>'float'],
'count' => ['int', 'value'=>'Countable|array|SimpleXMLElement', 'mode='=>'int'],
'count' => ['int<0, max>', 'value'=>'Countable|array|SimpleXMLElement', 'mode='=>'int'],
'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'],
Expand Down
15 changes: 7 additions & 8 deletions tests/FunctionCallTest.php
Expand Up @@ -1220,6 +1220,13 @@ function example(callable $x) : int {
return count($x);
}',
],
'countOnObjectShouldBePositive' => [
'code' => '<?php
/** @return positive-int|0 */
function example(\Countable $x) : int {
return count($x);
}',
],
'countOnPureObjectIsPure' => [
'code' => '<?php
class PureCountable implements \Countable {
Expand Down Expand Up @@ -2355,14 +2362,6 @@ function example($x) : void {
}',
'error_message' => 'TypeDoesNotContainType',
],
'countOnObjectCannotBePositive' => [
'code' => '<?php
/** @return positive-int|0 */
function example(\Countable $x) : int {
return count($x);
}',
'error_message' => 'LessSpecificReturnStatement',
],
'countOnUnknownObjectCannotBePure' => [
'code' => '<?php
/** @psalm-pure */
Expand Down

0 comments on commit f6051bc

Please sign in to comment.