Skip to content

Commit

Permalink
Merge branch '5.x' into update-master
Browse files Browse the repository at this point in the history
  • Loading branch information
weirdan committed Mar 21, 2024
2 parents ef3b018 + 63ea4de commit 2aed495
Show file tree
Hide file tree
Showing 74 changed files with 2,000 additions and 114 deletions.
1 change: 1 addition & 0 deletions config.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@
<xs:element name="MismatchingDocblockParamType" type="IssueHandlerType" minOccurs="0" />
<xs:element name="MismatchingDocblockPropertyType" type="IssueHandlerType" minOccurs="0" />
<xs:element name="MismatchingDocblockReturnType" type="IssueHandlerType" minOccurs="0" />
<xs:element name="MissingClassConstType" type="IssueHandlerType" minOccurs="0" />
<xs:element name="MissingClosureParamType" type="IssueHandlerType" minOccurs="0" />
<xs:element name="MissingClosureReturnType" type="IssueHandlerType" minOccurs="0" />
<xs:element name="MissingConstructor" type="IssueHandlerType" minOccurs="0" />
Expand Down
40 changes: 20 additions & 20 deletions dictionaries/CallMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -1142,17 +1142,17 @@
'crash' => [''],
'crc32' => ['int', 'string'=>'string'],
'crypt' => ['string', 'string'=>'string', 'salt'=>'string'],
'ctype_alnum' => ['bool', 'text'=>'string|int'],
'ctype_alpha' => ['bool', 'text'=>'string|int'],
'ctype_cntrl' => ['bool', 'text'=>'string|int'],
'ctype_digit' => ['bool', 'text'=>'string|int'],
'ctype_graph' => ['bool', 'text'=>'string|int'],
'ctype_lower' => ['bool', 'text'=>'string|int'],
'ctype_print' => ['bool', 'text'=>'string|int'],
'ctype_punct' => ['bool', 'text'=>'string|int'],
'ctype_space' => ['bool', 'text'=>'string|int'],
'ctype_upper' => ['bool', 'text'=>'string|int'],
'ctype_xdigit' => ['bool', 'text'=>'string|int'],
'ctype_alnum' => ['bool', 'text'=>'string'],
'ctype_alpha' => ['bool', 'text'=>'string'],
'ctype_cntrl' => ['bool', 'text'=>'string'],
'ctype_digit' => ['bool', 'text'=>'string'],
'ctype_graph' => ['bool', 'text'=>'string'],
'ctype_lower' => ['bool', 'text'=>'string'],
'ctype_print' => ['bool', 'text'=>'string'],
'ctype_punct' => ['bool', 'text'=>'string'],
'ctype_space' => ['bool', 'text'=>'string'],
'ctype_upper' => ['bool', 'text'=>'string'],
'ctype_xdigit' => ['bool', 'text'=>'string'],
'cubrid_affected_rows' => ['int', 'req_identifier='=>''],
'cubrid_bind' => ['bool', 'req_identifier'=>'resource', 'bind_param'=>'int', 'bind_value'=>'mixed', 'bind_value_type='=>'string'],
'cubrid_client_encoding' => ['string', 'conn_identifier='=>''],
Expand Down Expand Up @@ -1293,7 +1293,7 @@
'CURLFile::setMimeType' => ['void', 'mime_type'=>'string'],
'CURLFile::setPostFilename' => ['void', 'posted_filename'=>'string'],
'CURLStringFile::__construct' => ['void', 'data'=>'string', 'postname'=>'string', 'mime='=>'string'],
'current' => ['mixed|false', 'array'=>'array|object'],
'current' => ['mixed|false', 'array'=>'array'],
'cyrus_authenticate' => ['void', 'connection'=>'resource', 'mechlist='=>'string', 'service='=>'string', 'user='=>'string', 'minssf='=>'int', 'maxssf='=>'int', 'authname='=>'string', 'password='=>'string'],
'cyrus_bind' => ['bool', 'connection'=>'resource', 'callbacks'=>'array'],
'cyrus_close' => ['bool', 'connection'=>'resource'],
Expand Down Expand Up @@ -3269,7 +3269,7 @@
'get_call_stack' => [''],
'get_called_class' => ['class-string'],
'get_cfg_var' => ['string|false', 'option'=>'string'],
'get_class' => ['class-string', 'object='=>'object'],
'get_class' => ['class-string', 'object'=>'object'],
'get_class_methods' => ['list<non-falsy-string>', 'object_or_class'=>'object|class-string'],
'get_class_vars' => ['array<non-falsy-string,mixed>', 'class'=>'string'],
'get_current_user' => ['string'],
Expand All @@ -3290,7 +3290,7 @@
'get_magic_quotes_runtime' => ['int|false'],
'get_meta_tags' => ['array', 'filename'=>'string', 'use_include_path='=>'bool'],
'get_object_vars' => ['array<string,mixed>', 'object'=>'object'],
'get_parent_class' => ['class-string|false', 'object_or_class='=>'object|class-string'],
'get_parent_class' => ['class-string|false', 'object_or_class'=>'object|class-string'],
'get_required_files' => ['list<string>'],
'get_resource_id' => ['int', 'resource'=>'resource'],
'get_resource_type' => ['string', 'resource'=>'resource'],
Expand All @@ -3307,7 +3307,7 @@
'getimagesize' => ['array{0:int, 1: int, 2: int, 3: string, mime: string, channels?: 3|4, bits?: int}|false', 'filename'=>'string', '&w_image_info='=>'array'],
'getimagesizefromstring' => ['array{0:int, 1: int, 2: int, 3: string, mime: string, channels?: 3|4, bits?: int}|false', 'string'=>'string', '&w_image_info='=>'array'],
'getlastmod' => ['int|false'],
'getmxrr' => ['bool', 'hostname'=>'string', '&w_hosts'=>'array', '&w_weights='=>'array'],
'getmxrr' => ['bool', 'hostname'=>'string', '&w_hosts'=>'array<int, string>', '&w_weights='=>'array<int, int>'],
'getmygid' => ['int|false'],
'getmyinode' => ['int|false'],
'getmypid' => ['int|false'],
Expand Down Expand Up @@ -6198,7 +6198,7 @@
'kadm5_get_principals' => ['array', 'handle'=>'resource'],
'kadm5_init_with_password' => ['resource', 'admin_server'=>'string', 'realm'=>'string', 'principal'=>'string', 'password'=>'string'],
'kadm5_modify_principal' => ['bool', 'handle'=>'resource', 'principal'=>'string', 'options'=>'array'],
'key' => ['int|string|null', 'array'=>'array|object'],
'key' => ['int|string|null', 'array'=>'array'],
'key_exists' => ['bool', 'key'=>'string|int', 'array'=>'array'],
'krsort' => ['true', '&rw_array'=>'array', 'flags='=>'int'],
'ksort' => ['true', '&rw_array'=>'array', 'flags='=>'int'],
Expand Down Expand Up @@ -6598,7 +6598,7 @@
'mapObj::zoomScale' => ['int', 'nScaleDenom'=>'float', 'oPixelPos'=>'pointObj', 'nImageWidth'=>'int', 'nImageHeight'=>'int', 'oGeorefExt'=>'rectObj', 'oMaxGeorefExt'=>'rectObj'],
'max' => ['mixed', 'value'=>'non-empty-array'],
'max\'1' => ['mixed', 'value'=>'', 'values'=>'', '...args='=>''],
'mb_check_encoding' => ['bool', 'value='=>'array|string|null', 'encoding='=>'string|null'],
'mb_check_encoding' => ['bool', 'value'=>'array|string', 'encoding='=>'string|null'],
'mb_chr' => ['non-empty-string|false', 'codepoint'=>'int', 'encoding='=>'string|null'],
'mb_convert_case' => ['string', 'string'=>'string', 'mode'=>'int', 'encoding='=>'string|null'],
'mb_convert_encoding' => ['string|false', 'string'=>'string', 'to_encoding'=>'string', 'from_encoding='=>'array|string|null'],
Expand Down Expand Up @@ -8149,7 +8149,7 @@
'newrelic_set_appname' => ['bool', 'name'=>'string', 'license='=>'string', 'xmit='=>'bool'],
'newrelic_set_user_attributes' => ['bool', 'user'=>'string', 'account'=>'string', 'product'=>'string'],
'newrelic_start_transaction' => ['bool', 'appname'=>'string', 'license='=>'string'],
'next' => ['mixed', '&r_array'=>'array|object'],
'next' => ['mixed', '&r_array'=>'array'],
'ngettext' => ['string', 'singular'=>'string', 'plural'=>'string', 'count'=>'int'],
'nl2br' => ['string', 'string'=>'string', 'use_xhtml='=>'bool'],
'nl_langinfo' => ['string|false', 'item'=>'int'],
Expand Down Expand Up @@ -9429,7 +9429,7 @@
'preg_replace_callback_array\'1' => ['string[]|null', 'pattern'=>'array<string,callable(array):string>', 'subject'=>'string[]', 'limit='=>'int', '&w_count='=>'int', 'flags='=>'int'],
'preg_split' => ['list<string>|false', 'pattern'=>'string', 'subject'=>'string', 'limit'=>'int', 'flags='=>'null'],
'preg_split\'1' => ['list<string>|list<list<string|int>>|false', 'pattern'=>'string', 'subject'=>'string', 'limit='=>'int', 'flags='=>'int'],
'prev' => ['mixed', '&r_array'=>'array|object'],
'prev' => ['mixed', '&r_array'=>'array'],
'print' => ['int', 'arg'=>'string'],
'print_r' => ['string', 'value'=>'mixed'],
'print_r\'1' => ['true', 'value'=>'mixed', 'return='=>'bool'],
Expand Down Expand Up @@ -10699,7 +10699,7 @@
'register_tick_function' => ['bool', 'callback'=>'callable():void', '...args='=>'mixed'],
'rename' => ['bool', 'from'=>'string', 'to'=>'string', 'context='=>'resource'],
'rename_function' => ['bool', 'original_name'=>'string', 'new_name'=>'string'],
'reset' => ['mixed|false', '&r_array'=>'array|object'],
'reset' => ['mixed|false', '&r_array'=>'array'],
'ResourceBundle::__construct' => ['void', 'locale'=>'?string', 'bundle'=>'?string', 'fallback='=>'bool'],
'ResourceBundle::count' => ['int'],
'ResourceBundle::create' => ['?ResourceBundle', 'locale'=>'?string', 'bundle'=>'?string', 'fallback='=>'bool'],
Expand Down
68 changes: 68 additions & 0 deletions dictionaries/CallMap_81_delta.php
Original file line number Diff line number Diff line change
Expand Up @@ -1211,6 +1211,74 @@
'old' => ['int|false', '&rw_read'=>'?resource[]', '&rw_write'=>'?resource[]', '&rw_except'=>'?resource[]', 'seconds'=>'?int', 'microseconds='=>'int'],
'new' => ['int|false', '&rw_read'=>'?resource[]', '&rw_write'=>'?resource[]', '&rw_except'=>'?resource[]', 'seconds'=>'?int', 'microseconds='=>'?int'],
],
'mb_check_encoding' => [
'old' => ['bool', 'value='=>'array|string|null', 'encoding='=>'string|null'],
'new' => ['bool', 'value'=>'array|string', 'encoding='=>'string|null'],
],
'ctype_alnum' => [
'old' => ['bool', 'text'=>'string|int'],
'new' => ['bool', 'text'=>'string'],
],
'ctype_alpha' => [
'old' => ['bool', 'text'=>'string|int'],
'new' => ['bool', 'text'=>'string'],
],
'ctype_cntrl' => [
'old' => ['bool', 'text'=>'string|int'],
'new' => ['bool', 'text'=>'string'],
],
'ctype_digit' => [
'old' => ['bool', 'text'=>'string|int'],
'new' => ['bool', 'text'=>'string'],
],
'ctype_graph' => [
'old' => ['bool', 'text'=>'string|int'],
'new' => ['bool', 'text'=>'string'],
],
'ctype_lower' => [
'old' => ['bool', 'text'=>'string|int'],
'new' => ['bool', 'text'=>'string'],
],
'ctype_print' => [
'old' => ['bool', 'text'=>'string|int'],
'new' => ['bool', 'text'=>'string'],
],
'ctype_punct' => [
'old' => ['bool', 'text'=>'string|int'],
'new' => ['bool', 'text'=>'string'],
],
'ctype_space' => [
'old' => ['bool', 'text'=>'string|int'],
'new' => ['bool', 'text'=>'string'],
],
'ctype_upper' => [
'old' => ['bool', 'text'=>'string|int'],
'new' => ['bool', 'text'=>'string'],
],
'ctype_xdigit' => [
'old' => ['bool', 'text'=>'string|int'],
'new' => ['bool', 'text'=>'string'],
],
'key' => [
'old' => ['int|string|null', 'array'=>'array|object'],
'new' => ['int|string|null', 'array'=>'array'],
],
'current' => [
'old' => ['mixed|false', 'array'=>'array|object'],
'new' => ['mixed|false', 'array'=>'array'],
],
'next' => [
'old' => ['mixed', '&r_array'=>'array|object'],
'new' => ['mixed', '&r_array'=>'array'],
],
'prev' => [
'old' => ['mixed', '&r_array'=>'array|object'],
'new' => ['mixed', '&r_array'=>'array'],
],
'reset' => [
'old' => ['mixed|false', '&r_array'=>'array|object'],
'new' => ['mixed|false', '&r_array'=>'array'],
],
],

'removed' => [
Expand Down
8 changes: 8 additions & 0 deletions dictionaries/CallMap_83_delta.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,14 @@
'old' => ['string|false', 'haystack'=>'string', 'needle'=>'string'],
'new' => ['string|false', 'haystack'=>'string', 'needle'=>'string', 'before_needle='=>'bool'],
],
'get_class' => [
'old' => ['class-string', 'object='=>'object'],
'new' => ['class-string', 'object'=>'object'],
],
'get_parent_class' => [
'old' => ['class-string|false', 'object_or_class='=>'object|class-string'],
'new' => ['class-string|false', 'object_or_class'=>'object|class-string'],
],
],

'removed' => [
Expand Down
2 changes: 1 addition & 1 deletion dictionaries/CallMap_historical.php
Original file line number Diff line number Diff line change
Expand Up @@ -10671,7 +10671,7 @@
'getimagesize' => ['array{0:int, 1: int, 2: int, 3: string, mime: string, channels?: 3|4, bits?: int}|false', 'filename'=>'string', '&w_image_info='=>'array'],
'getimagesizefromstring' => ['array{0:int, 1: int, 2: int, 3: string, mime: string, channels?: 3|4, bits?: int}|false', 'string'=>'string', '&w_image_info='=>'array'],
'getlastmod' => ['int|false'],
'getmxrr' => ['bool', 'hostname'=>'string', '&w_hosts'=>'array', '&w_weights='=>'array'],
'getmxrr' => ['bool', 'hostname'=>'string', '&w_hosts'=>'array<int, string>', '&w_weights='=>'array<int, int>'],
'getmygid' => ['int|false'],
'getmyinode' => ['int|false'],
'getmypid' => ['int|false'],
Expand Down
1 change: 1 addition & 0 deletions docs/running_psalm/error_levels.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ Level 5 and above allows a more non-verifiable code, and higher levels are even
- [InvalidDocblockParamName](issues/InvalidDocblockParamName.md)
- [InvalidFalsableReturnType](issues/InvalidFalsableReturnType.md)
- [InvalidStringClass](issues/InvalidStringClass.md)
- [MissingClassConstType](issues/MissingClassConstType.md)
- [MissingClosureParamType](issues/MissingClosureParamType.md)
- [MissingClosureReturnType](issues/MissingClosureReturnType.md)
- [MissingConstructor](issues/MissingConstructor.md)
Expand Down
1 change: 1 addition & 0 deletions docs/running_psalm/issues.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
- [MismatchingDocblockParamType](issues/MismatchingDocblockParamType.md)
- [MismatchingDocblockPropertyType](issues/MismatchingDocblockPropertyType.md)
- [MismatchingDocblockReturnType](issues/MismatchingDocblockReturnType.md)
- [MissingClassConstType](issues/MissingClassConstType.md)
- [MissingClosureParamType](issues/MissingClosureParamType.md)
- [MissingClosureReturnType](issues/MissingClosureReturnType.md)
- [MissingConstructor](issues/MissingConstructor.md)
Expand Down
2 changes: 1 addition & 1 deletion docs/running_psalm/issues/ConstructorSignatureMismatch.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Emitted when a constructor parameter differs from a parent constructor parameter
* @psalm-consistent-constructor
*/
class A {
public function __construct(int $i) {}
public function __construct(int $s) {}
}
class B extends A {
public function __construct(string $s) {}
Expand Down
21 changes: 21 additions & 0 deletions docs/running_psalm/issues/MissingClassConstType.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# MissingClassConstType

Emitted when a class constant doesn't have a declared type.

```php
<?php

class A {
public const B = 0;
}
```

Correct with:

```php
<?php

class A {
public const int B = 0;
}
```
33 changes: 24 additions & 9 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="dev-master@c488d40e6243536a42608bbe37245f07ebebe1ad">
<files psalm-version="dev-master@c1ef723d2f810669d3caa99de4f65631ef4e3781">
<file src="examples/TemplateChecker.php">
<PossiblyUndefinedIntArrayOffset>
<code><![CDATA[$comment_block->tags['variablesfrom'][0]]]></code>
Expand Down Expand Up @@ -713,6 +713,7 @@
<code><![CDATA[$overridden_template_types]]></code>
<code><![CDATA[$static_class_storage->template_extended_params]]></code>
<code><![CDATA[$static_class_storage->template_types]]></code>
<code><![CDATA[empty($non_trait_class_storage->overridden_method_ids[$method_name])]]></code>
</RiskyTruthyFalsyComparison>
</file>
<file src="src/Psalm/Internal/Analyzer/Statements/Expression/Call/FunctionCallAnalyzer.php">
Expand Down Expand Up @@ -940,8 +941,6 @@
<code><![CDATA[$extended_var_id]]></code>
<code><![CDATA[$keyed_array_var_id]]></code>
<code><![CDATA[$keyed_array_var_id]]></code>
<code><![CDATA[$keyed_array_var_id]]></code>
<code><![CDATA[$keyed_array_var_id]]></code>
</RiskyTruthyFalsyComparison>
</file>
<file src="src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/AtomicPropertyFetchAnalyzer.php">
Expand Down Expand Up @@ -1190,6 +1189,7 @@
<code><![CDATA[$file_path]]></code>
<code><![CDATA[$migrated_source_fqcln]]></code>
<code><![CDATA[$migrated_source_fqcln]]></code>
<code><![CDATA[empty($classlike_storage->overridden_method_ids[$method_name])]]></code>
</RiskyTruthyFalsyComparison>
</file>
<file src="src/Psalm/Internal/Codebase/Functions.php">
Expand All @@ -1210,9 +1210,6 @@
</RiskyTruthyFalsyComparison>
</file>
<file src="src/Psalm/Internal/Codebase/Methods.php">
<InvalidArgument>
<code><![CDATA[$class_storage->methods[$declaring_method_name]->stubbed]]></code>
</InvalidArgument>
<RiskyTruthyFalsyComparison>
<code><![CDATA[!$calling_class_name]]></code>
<code><![CDATA[!$extends]]></code>
Expand All @@ -1238,9 +1235,6 @@
</RiskyTruthyFalsyComparison>
</file>
<file src="src/Psalm/Internal/Codebase/Populator.php">
<InvalidArgument>
<code><![CDATA[$storage->methods[$implementing_method_id->method_name]->abstract]]></code>
</InvalidArgument>
<RiskyTruthyFalsyComparison>
<code><![CDATA[!strpos($fq_classlike_name_lc, '\\')]]></code>
<code><![CDATA[$mapped_name]]></code>
Expand Down Expand Up @@ -1481,6 +1475,9 @@
<code><![CDATA[$var_comment->line_number]]></code>
<code><![CDATA[$var_comment->type_end]]></code>
<code><![CDATA[$var_comment->type_start]]></code>
<code><![CDATA[empty($imported_type_data[0])]]></code>
<code><![CDATA[empty($imported_type_data[2])]]></code>
<code><![CDATA[empty($imported_type_data[4])]]></code>
</RiskyTruthyFalsyComparison>
</file>
<file src="src/Psalm/Internal/PhpVisitor/Reflector/ExpressionResolver.php">
Expand Down Expand Up @@ -1514,6 +1511,9 @@
<code><![CDATA[$line_parts[0]]]></code>
<code><![CDATA[$line_parts[1]]]></code>
</PossiblyUndefinedIntArrayOffset>
<RiskyTruthyFalsyComparison>
<code><![CDATA[empty($since_match[4])]]></code>
</RiskyTruthyFalsyComparison>
</file>
<file src="src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeDocblockScanner.php">
<PossiblyUndefinedArrayOffset>
Expand Down Expand Up @@ -1620,6 +1620,13 @@
<file src="src/Psalm/Internal/Provider/FileReferenceProvider.php">
<RiskyTruthyFalsyComparison>
<code><![CDATA[$this->cache->getFileMapCache()]]></code>
<code><![CDATA[empty(self::$file_references_to_class_members[$method_id])]]></code>
<code><![CDATA[empty(self::$file_references_to_class_properties[$property_id])]]></code>
<code><![CDATA[empty(self::$file_references_to_method_returns[$method_id])]]></code>
<code><![CDATA[empty(self::$method_param_uses[$method_id][$offset])]]></code>
<code><![CDATA[empty(self::$method_references_to_class_members[$method_id])]]></code>
<code><![CDATA[empty(self::$method_references_to_class_properties[$property_id])]]></code>
<code><![CDATA[empty(self::$method_references_to_method_returns[$method_id])]]></code>
</RiskyTruthyFalsyComparison>
</file>
<file src="src/Psalm/Internal/Provider/FileStorageCacheProvider.php">
Expand Down Expand Up @@ -1714,6 +1721,7 @@
<file src="src/Psalm/Internal/Scanner/DocblockParser.php">
<RiskyTruthyFalsyComparison>
<code><![CDATA[$first_line_padding]]></code>
<code><![CDATA[empty($special[$type])]]></code>
</RiskyTruthyFalsyComparison>
</file>
<file src="src/Psalm/Internal/Scanner/PhpStormMetaScanner.php">
Expand Down Expand Up @@ -1865,6 +1873,7 @@
<file src="src/Psalm/Internal/Type/TemplateInferredTypeReplacer.php">
<RiskyTruthyFalsyComparison>
<code><![CDATA[$classlike_storage->template_extended_params]]></code>
<code><![CDATA[empty($inferred_lower_bounds[$atomic_type->offset_param_name])]]></code>
</RiskyTruthyFalsyComparison>
</file>
<file src="src/Psalm/Internal/Type/TemplateStandinTypeReplacer.php">
Expand All @@ -1878,6 +1887,7 @@
<code><![CDATA[empty($class_storage->template_extended_params[$container_class])]]></code>
<code><![CDATA[empty($classlike_storage->template_extended_params[$base_type->as_type->value])]]></code>
<code><![CDATA[empty($classlike_storage->template_extended_params[$base_type->value])]]></code>
<code><![CDATA[empty($template_result->lower_bounds[$atomic_type->offset_param_name])]]></code>
<code><![CDATA[strpos($key, '&')]]></code>
</RiskyTruthyFalsyComparison>
</file>
Expand Down Expand Up @@ -2318,6 +2328,11 @@
<code><![CDATA[public function getProjectDirectories(): array]]></code>
</MethodSignatureMismatch>
</file>
<file src="tests/Internal/Codebase/InternalCallMapHandlerTest.php">
<RiskyTruthyFalsyComparison>
<code><![CDATA[empty($normalizedEntry['type'])]]></code>
</RiskyTruthyFalsyComparison>
</file>
<file src="tests/TypeParseTest.php">
<RiskyTruthyFalsyComparison>
<code><![CDATA[$param_type_1]]></code>
Expand Down
Loading

0 comments on commit 2aed495

Please sign in to comment.