Skip to content

Commit

Permalink
Merge pull request #10684 from weirdan/update-master
Browse files Browse the repository at this point in the history
  • Loading branch information
weirdan committed Feb 9, 2024
2 parents 4b2c698 + 83f04c5 commit c03a8a0
Show file tree
Hide file tree
Showing 62 changed files with 1,053 additions and 314 deletions.
2 changes: 2 additions & 0 deletions config.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
<xs:attribute name="checkForThrowsInGlobalScope" type="xs:boolean" default="false" />
<xs:attribute name="ensureArrayIntOffsetsExist" type="xs:boolean" default="false" />
<xs:attribute name="ensureArrayStringOffsetsExist" type="xs:boolean" default="false" />
<xs:attribute name="ensureOverrideAttribute" type="xs:boolean" default="false" />
<xs:attribute name="findUnusedCode" type="xs:boolean" default="false" />
<xs:attribute name="findUnusedVariablesAndParams" type="xs:boolean" default="false" />
<xs:attribute name="findUnusedPsalmSuppress" type="xs:boolean" default="false" />
Expand Down Expand Up @@ -321,6 +322,7 @@
<xs:element name="MissingDocblockType" type="IssueHandlerType" minOccurs="0" />
<xs:element name="MissingFile" type="IssueHandlerType" minOccurs="0" />
<xs:element name="MissingImmutableAnnotation" type="IssueHandlerType" minOccurs="0" />
<xs:element name="MissingOverrideAttribute" type="IssueHandlerType" minOccurs="0" />
<xs:element name="MissingParamType" type="IssueHandlerType" minOccurs="0" />
<xs:element name="MissingPropertyType" type="PropertyIssueHandlerType" minOccurs="0" />
<xs:element name="MissingReturnType" type="IssueHandlerType" minOccurs="0" />
Expand Down
30 changes: 15 additions & 15 deletions dictionaries/CallMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -1590,7 +1590,7 @@
'DirectoryIterator::getPathInfo' => ['?SplFileInfo', 'class='=>'?class-string'],
'DirectoryIterator::getPathname' => ['string'],
'DirectoryIterator::getPerms' => ['int'],
'DirectoryIterator::getRealPath' => ['string'],
'DirectoryIterator::getRealPath' => ['non-falsy-string'],
'DirectoryIterator::getSize' => ['int'],
'DirectoryIterator::getType' => ['string'],
'DirectoryIterator::isDir' => ['bool'],
Expand Down Expand Up @@ -2792,7 +2792,7 @@
'file' => ['list<string>|false', 'filename'=>'string', 'flags='=>'int', 'context='=>'resource'],
'file_exists' => ['bool', 'filename'=>'string'],
'file_get_contents' => ['string|false', 'filename'=>'string', 'use_include_path='=>'bool', 'context='=>'?resource', 'offset='=>'int', 'length='=>'?int'],
'file_put_contents' => ['int|false', 'filename'=>'string', 'data'=>'string|resource|array<string>', 'flags='=>'int', 'context='=>'resource'],
'file_put_contents' => ['int<0, max>|false', 'filename'=>'string', 'data'=>'string|resource|array<string>', 'flags='=>'int', 'context='=>'resource'],
'fileatime' => ['int|false', 'filename'=>'string'],
'filectime' => ['int|false', 'filename'=>'string'],
'filegroup' => ['int|false', 'filename'=>'string'],
Expand Down Expand Up @@ -2827,7 +2827,7 @@
'FilesystemIterator::getPathInfo' => ['?SplFileInfo', 'class='=>'?class-string'],
'FilesystemIterator::getPathname' => ['string'],
'FilesystemIterator::getPerms' => ['int'],
'FilesystemIterator::getRealPath' => ['string'],
'FilesystemIterator::getRealPath' => ['non-falsy-string'],
'FilesystemIterator::getSize' => ['int'],
'FilesystemIterator::getType' => ['string'],
'FilesystemIterator::isDir' => ['bool'],
Expand Down Expand Up @@ -3296,7 +3296,7 @@
'get_resource_type' => ['string', 'resource'=>'resource'],
'get_resources' => ['array<int,resource>', 'type='=>'?string'],
'getallheaders' => ['array|false'],
'getcwd' => ['string|false'],
'getcwd' => ['non-falsy-string|false'],
'getdate' => ['array{seconds: int<0, 59>, minutes: int<0, 59>, hours: int<0, 23>, mday: int<1, 31>, wday: int<0, 6>, mon: int<1, 12>, year: int, yday: int<0, 365>, weekday: "Monday"|"Tuesday"|"Wednesday"|"Thursday"|"Friday"|"Saturday"|"Sunday", month: "January"|"February"|"March"|"April"|"May"|"June"|"July"|"August"|"September"|"October"|"November"|"December", 0: int}', 'timestamp='=>'?int'],
'getenv' => ['string|false', 'name'=>'string', 'local_only='=>'bool'],
'getenv\'1' => ['array<string,string>'],
Expand Down Expand Up @@ -3343,7 +3343,7 @@
'GlobIterator::getPathInfo' => ['?SplFileInfo', 'class='=>'?class-string'],
'GlobIterator::getPathname' => ['string'],
'GlobIterator::getPerms' => ['int'],
'GlobIterator::getRealPath' => ['string|false'],
'GlobIterator::getRealPath' => ['non-falsy-string|false'],
'GlobIterator::getSize' => ['int'],
'GlobIterator::getType' => ['string|false'],
'GlobIterator::isDir' => ['bool'],
Expand Down Expand Up @@ -8529,7 +8529,7 @@
'openssl_x509_parse' => ['array|false', 'certificate'=>'OpenSSLCertificate|string', 'short_names='=>'bool'],
'openssl_x509_read' => ['OpenSSLCertificate|false', 'certificate'=>'OpenSSLCertificate|string'],
'openssl_x509_verify' => ['int', 'certificate'=>'string|OpenSSLCertificate', 'public_key'=>'string|OpenSSLCertificate|OpenSSLAsymmetricKey|array'],
'ord' => ['int', 'character'=>'string'],
'ord' => ['int<0,255>', 'character'=>'string'],
'OuterIterator::current' => ['mixed'],
'OuterIterator::getInnerIterator' => ['Iterator'],
'OuterIterator::key' => ['int|string'],
Expand Down Expand Up @@ -9722,8 +9722,8 @@
'readline_read_history' => ['bool', 'filename='=>'?string'],
'readline_redisplay' => ['void'],
'readline_write_history' => ['bool', 'filename='=>'?string'],
'readlink' => ['string|false', 'path'=>'string'],
'realpath' => ['string|false', 'path'=>'string'],
'readlink' => ['non-falsy-string|false', 'path'=>'string'],
'realpath' => ['non-falsy-string|false', 'path'=>'string'],
'realpath_cache_get' => ['array'],
'realpath_cache_size' => ['int'],
'recode' => ['string', 'request'=>'string', 'string'=>'string'],
Expand Down Expand Up @@ -9811,7 +9811,7 @@
'RecursiveDirectoryIterator::getPathInfo' => ['?SplFileInfo', 'class='=>'?class-string'],
'RecursiveDirectoryIterator::getPathname' => ['string'],
'RecursiveDirectoryIterator::getPerms' => ['int'],
'RecursiveDirectoryIterator::getRealPath' => ['string'],
'RecursiveDirectoryIterator::getRealPath' => ['non-falsy-string'],
'RecursiveDirectoryIterator::getSize' => ['int'],
'RecursiveDirectoryIterator::getSubPath' => ['string'],
'RecursiveDirectoryIterator::getSubPathname' => ['string'],
Expand Down Expand Up @@ -10631,7 +10631,7 @@
'ReflectionParameter::getDefaultValue' => ['mixed'],
'ReflectionParameter::getDefaultValueConstantName' => ['?string'],
'ReflectionParameter::getName' => ['string'],
'ReflectionParameter::getPosition' => ['int'],
'ReflectionParameter::getPosition' => ['int<0, max>'],
'ReflectionParameter::getType' => ['?ReflectionType'],
'ReflectionParameter::hasType' => ['bool'],
'ReflectionParameter::isArray' => ['bool'],
Expand Down Expand Up @@ -12238,7 +12238,7 @@
'SplFileInfo::getPathInfo' => ['SplFileInfo|null', 'class='=>'?class-string'],
'SplFileInfo::getPathname' => ['string'],
'SplFileInfo::getPerms' => ['int|false'],
'SplFileInfo::getRealPath' => ['string|false'],
'SplFileInfo::getRealPath' => ['non-falsy-string|false'],
'SplFileInfo::getSize' => ['int|false'],
'SplFileInfo::getType' => ['string|false'],
'SplFileInfo::isDir' => ['bool'],
Expand Down Expand Up @@ -12288,7 +12288,7 @@
'SplFileObject::getPathInfo' => ['SplFileInfo|null', 'class='=>'?class-string'],
'SplFileObject::getPathname' => ['string'],
'SplFileObject::getPerms' => ['int|false'],
'SplFileObject::getRealPath' => ['false|string'],
'SplFileObject::getRealPath' => ['false|non-falsy-string'],
'SplFileObject::getSize' => ['int|false'],
'SplFileObject::getType' => ['string|false'],
'SplFileObject::hasChildren' => ['false'],
Expand Down Expand Up @@ -12475,7 +12475,7 @@
'SplTempFileObject::getPathInfo' => ['SplFileInfo|null', 'class='=>'?class-string'],
'SplTempFileObject::getPathname' => ['string'],
'SplTempFileObject::getPerms' => ['int|false'],
'SplTempFileObject::getRealPath' => ['false|string'],
'SplTempFileObject::getRealPath' => ['false|non-falsy-string'],
'SplTempFileObject::getSize' => ['int|false'],
'SplTempFileObject::getType' => ['string|false'],
'SplTempFileObject::hasChildren' => ['false'],
Expand Down Expand Up @@ -12690,8 +12690,8 @@
'ssh2_sftp_chmod' => ['bool', 'sftp'=>'resource', 'filename'=>'string', 'mode'=>'int'],
'ssh2_sftp_lstat' => ['array{0: int, 1: int, 2: int, 3: int, 4: int, 5: int, 6: int, 7: int, 8: int, 9: int, 10: int, 11: int, 12: int, dev: int, ino: int, mode: int, nlink: int, uid: int, gid: int, rdev: int, size: int, atime: int, mtime: int, ctime: int, blksize: int, blocks: int}|false', 'sftp'=>'resource', 'path'=>'string'],
'ssh2_sftp_mkdir' => ['bool', 'sftp'=>'resource', 'dirname'=>'string', 'mode='=>'int', 'recursive='=>'bool'],
'ssh2_sftp_readlink' => ['string|false', 'sftp'=>'resource', 'link'=>'string'],
'ssh2_sftp_realpath' => ['string|false', 'sftp'=>'resource', 'filename'=>'string'],
'ssh2_sftp_readlink' => ['non-falsy-string|false', 'sftp'=>'resource', 'link'=>'string'],
'ssh2_sftp_realpath' => ['non-falsy-string|false', 'sftp'=>'resource', 'filename'=>'string'],
'ssh2_sftp_rename' => ['bool', 'sftp'=>'resource', 'from'=>'string', 'to'=>'string'],
'ssh2_sftp_rmdir' => ['bool', 'sftp'=>'resource', 'dirname'=>'string'],
'ssh2_sftp_stat' => ['array{0: int, 1: int, 2: int, 3: int, 4: int, 5: int, 6: int, 7: int, 8: int, 9: int, 10: int, 11: int, 12: int, dev: int, ino: int, mode: int, nlink: int, uid: int, gid: int, rdev: int, size: int, atime: int, mtime: int, ctime: int, blksize: int, blocks: int}|false', 'sftp'=>'resource', 'path'=>'string'],
Expand Down
30 changes: 15 additions & 15 deletions dictionaries/CallMap_historical.php
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,7 @@
'DirectoryIterator::getPathInfo' => ['?SplFileInfo', 'class='=>'class-string'],
'DirectoryIterator::getPathname' => ['string'],
'DirectoryIterator::getPerms' => ['int'],
'DirectoryIterator::getRealPath' => ['string'],
'DirectoryIterator::getRealPath' => ['non-falsy-string'],
'DirectoryIterator::getSize' => ['int'],
'DirectoryIterator::getType' => ['string'],
'DirectoryIterator::isDir' => ['bool'],
Expand Down Expand Up @@ -1507,7 +1507,7 @@
'FilesystemIterator::getPathInfo' => ['?SplFileInfo', 'class='=>'class-string'],
'FilesystemIterator::getPathname' => ['string'],
'FilesystemIterator::getPerms' => ['int'],
'FilesystemIterator::getRealPath' => ['string'],
'FilesystemIterator::getRealPath' => ['non-falsy-string'],
'FilesystemIterator::getSize' => ['int'],
'FilesystemIterator::getType' => ['string'],
'FilesystemIterator::isDir' => ['bool'],
Expand Down Expand Up @@ -1762,7 +1762,7 @@
'GlobIterator::getPathInfo' => ['?SplFileInfo', 'class='=>'class-string'],
'GlobIterator::getPathname' => ['string'],
'GlobIterator::getPerms' => ['int'],
'GlobIterator::getRealPath' => ['string|false'],
'GlobIterator::getRealPath' => ['non-falsy-string|false'],
'GlobIterator::getSize' => ['int'],
'GlobIterator::getType' => ['string|false'],
'GlobIterator::isDir' => ['bool'],
Expand Down Expand Up @@ -5155,7 +5155,7 @@
'RecursiveDirectoryIterator::getPathInfo' => ['?SplFileInfo', 'class='=>'class-string'],
'RecursiveDirectoryIterator::getPathname' => ['string'],
'RecursiveDirectoryIterator::getPerms' => ['int'],
'RecursiveDirectoryIterator::getRealPath' => ['string'],
'RecursiveDirectoryIterator::getRealPath' => ['non-falsy-string'],
'RecursiveDirectoryIterator::getSize' => ['int'],
'RecursiveDirectoryIterator::getSubPath' => ['string'],
'RecursiveDirectoryIterator::getSubPathname' => ['string'],
Expand Down Expand Up @@ -5969,7 +5969,7 @@
'ReflectionParameter::getDefaultValue' => ['mixed'],
'ReflectionParameter::getDefaultValueConstantName' => ['?string'],
'ReflectionParameter::getName' => ['string'],
'ReflectionParameter::getPosition' => ['int'],
'ReflectionParameter::getPosition' => ['int<0, max>'],
'ReflectionParameter::getType' => ['?ReflectionType'],
'ReflectionParameter::hasType' => ['bool'],
'ReflectionParameter::isArray' => ['bool'],
Expand Down Expand Up @@ -7481,7 +7481,7 @@
'SplFileInfo::getPathInfo' => ['SplFileInfo|null', 'class='=>'class-string'],
'SplFileInfo::getPathname' => ['string'],
'SplFileInfo::getPerms' => ['int|false'],
'SplFileInfo::getRealPath' => ['string|false'],
'SplFileInfo::getRealPath' => ['non-falsy-string|false'],
'SplFileInfo::getSize' => ['int|false'],
'SplFileInfo::getType' => ['string|false'],
'SplFileInfo::isDir' => ['bool'],
Expand Down Expand Up @@ -7532,7 +7532,7 @@
'SplFileObject::getPathInfo' => ['SplFileInfo|null', 'class='=>'class-string'],
'SplFileObject::getPathname' => ['string'],
'SplFileObject::getPerms' => ['int|false'],
'SplFileObject::getRealPath' => ['false|string'],
'SplFileObject::getRealPath' => ['false|non-falsy-string'],
'SplFileObject::getSize' => ['int|false'],
'SplFileObject::getType' => ['string|false'],
'SplFileObject::hasChildren' => ['false'],
Expand Down Expand Up @@ -7723,7 +7723,7 @@
'SplTempFileObject::getPathInfo' => ['SplFileInfo|null', 'class='=>'class-string'],
'SplTempFileObject::getPathname' => ['string'],
'SplTempFileObject::getPerms' => ['int|false'],
'SplTempFileObject::getRealPath' => ['false|string'],
'SplTempFileObject::getRealPath' => ['false|non-falsy-string'],
'SplTempFileObject::getSize' => ['int|false'],
'SplTempFileObject::getType' => ['string|false'],
'SplTempFileObject::hasChildren' => ['false'],
Expand Down Expand Up @@ -10417,7 +10417,7 @@
'file' => ['list<string>|false', 'filename'=>'string', 'flags='=>'int', 'context='=>'resource'],
'file_exists' => ['bool', 'filename'=>'string'],
'file_get_contents' => ['string|false', 'filename'=>'string', 'use_include_path='=>'bool', 'context='=>'?resource', 'offset='=>'int', 'length='=>'int'],
'file_put_contents' => ['int|false', 'filename'=>'string', 'data'=>'string|resource|array<string>', 'flags='=>'int', 'context='=>'resource'],
'file_put_contents' => ['int<0, max>|false', 'filename'=>'string', 'data'=>'string|resource|array<string>', 'flags='=>'int', 'context='=>'resource'],
'fileatime' => ['int|false', 'filename'=>'string'],
'filectime' => ['int|false', 'filename'=>'string'],
'filegroup' => ['int|false', 'filename'=>'string'],
Expand Down Expand Up @@ -10661,7 +10661,7 @@
'get_resource_type' => ['string', 'resource'=>'resource'],
'get_resources' => ['array<int,resource>', 'type='=>'string'],
'getallheaders' => ['array|false'],
'getcwd' => ['string|false'],
'getcwd' => ['non-falsy-string|false'],
'getdate' => ['array{seconds: int<0, 59>, minutes: int<0, 59>, hours: int<0, 23>, mday: int<1, 31>, wday: int<0, 6>, mon: int<1, 12>, year: int, yday: int<0, 365>, weekday: "Monday"|"Tuesday"|"Wednesday"|"Thursday"|"Friday"|"Saturday"|"Sunday", month: "January"|"February"|"March"|"April"|"May"|"June"|"July"|"August"|"September"|"October"|"November"|"December", 0: int}', 'timestamp='=>'int'],
'getenv' => ['string|false', 'name'=>'string', 'local_only='=>'bool'],
'gethostbyaddr' => ['string|false', 'ip'=>'string'],
Expand Down Expand Up @@ -13190,7 +13190,7 @@
'openssl_x509_free' => ['void', 'certificate'=>'resource'],
'openssl_x509_parse' => ['array|false', 'certificate'=>'string|resource', 'short_names='=>'bool'],
'openssl_x509_read' => ['resource|false', 'certificate'=>'string|resource'],
'ord' => ['int', 'character'=>'string'],
'ord' => ['int<0,255>', 'character'=>'string'],
'output_add_rewrite_var' => ['bool', 'name'=>'string', 'value'=>'string'],
'output_cache_disable' => ['void'],
'output_cache_disable_compression' => ['void'],
Expand Down Expand Up @@ -13718,8 +13718,8 @@
'readline_read_history' => ['bool', 'filename='=>'string'],
'readline_redisplay' => ['void'],
'readline_write_history' => ['bool', 'filename='=>'string'],
'readlink' => ['string|false', 'path'=>'string'],
'realpath' => ['string|false', 'path'=>'string'],
'readlink' => ['non-falsy-string|false', 'path'=>'string'],
'realpath' => ['non-falsy-string|false', 'path'=>'string'],
'realpath_cache_get' => ['array'],
'realpath_cache_size' => ['int'],
'recode' => ['string', 'request'=>'string', 'string'=>'string'],
Expand Down Expand Up @@ -14120,8 +14120,8 @@
'ssh2_sftp_chmod' => ['bool', 'sftp'=>'resource', 'filename'=>'string', 'mode'=>'int'],
'ssh2_sftp_lstat' => ['array{0: int, 1: int, 2: int, 3: int, 4: int, 5: int, 6: int, 7: int, 8: int, 9: int, 10: int, 11: int, 12: int, dev: int, ino: int, mode: int, nlink: int, uid: int, gid: int, rdev: int, size: int, atime: int, mtime: int, ctime: int, blksize: int, blocks: int}|false', 'sftp'=>'resource', 'path'=>'string'],
'ssh2_sftp_mkdir' => ['bool', 'sftp'=>'resource', 'dirname'=>'string', 'mode='=>'int', 'recursive='=>'bool'],
'ssh2_sftp_readlink' => ['string|false', 'sftp'=>'resource', 'link'=>'string'],
'ssh2_sftp_realpath' => ['string|false', 'sftp'=>'resource', 'filename'=>'string'],
'ssh2_sftp_readlink' => ['non-falsy-string|false', 'sftp'=>'resource', 'link'=>'string'],
'ssh2_sftp_realpath' => ['non-falsy-string|false', 'sftp'=>'resource', 'filename'=>'string'],
'ssh2_sftp_rename' => ['bool', 'sftp'=>'resource', 'from'=>'string', 'to'=>'string'],
'ssh2_sftp_rmdir' => ['bool', 'sftp'=>'resource', 'dirname'=>'string'],
'ssh2_sftp_stat' => ['array{0: int, 1: int, 2: int, 3: int, 4: int, 5: int, 6: int, 7: int, 8: int, 9: int, 10: int, 11: int, 12: int, dev: int, ino: int, mode: int, nlink: int, uid: int, gid: int, rdev: int, size: int, atime: int, mtime: int, ctime: int, blksize: int, blocks: int}|false', 'sftp'=>'resource', 'path'=>'string'],
Expand Down
8 changes: 8 additions & 0 deletions docs/running_psalm/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,14 @@ When `true`, Psalm will complain when referencing an explicit string offset on a
```
When `true`, Psalm will complain when referencing an explicit integer offset on an array e.g. `$arr[7]` without a user first asserting that it exists (either via an `isset` check or via an object-like array). Defaults to `false`.

#### ensureOverrideAttribute
```xml
<psalm
ensureOverrideAttribute="[bool]"
>
```
When `true`, Psalm will report class and interface methods that override a method on a parent, but do not have an `Override` attribute. Defaults to `false`.

#### phpVersion
```xml
<psalm
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 @@ -279,6 +279,7 @@ Level 5 and above allows a more non-verifiable code, and higher levels are even

## Feature-specific errors

- [MissingOverrideAttribute](issues/MissingOverrideAttribute.md)
- [PossiblyUndefinedIntArrayOffset](issues/PossiblyUndefinedIntArrayOffset.md)
- [PossiblyUndefinedStringArrayOffset](issues/PossiblyUndefinedStringArrayOffset.md)
- [PossiblyUnusedMethod](issues/PossiblyUnusedMethod.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 @@ -121,6 +121,7 @@
- [MissingDocblockType](issues/MissingDocblockType.md)
- [MissingFile](issues/MissingFile.md)
- [MissingImmutableAnnotation](issues/MissingImmutableAnnotation.md)
- [MissingOverrideAttribute](issues/MissingOverrideAttribute.md)
- [MissingParamType](issues/MissingParamType.md)
- [MissingPropertyType](issues/MissingPropertyType.md)
- [MissingReturnType](issues/MissingReturnType.md)
Expand Down
23 changes: 23 additions & 0 deletions docs/running_psalm/issues/MissingOverrideAttribute.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# MissingOverrideAttribute

Emitted when the config flag `ensureOverrideAttribute` is set to `true` and a method on a child class or interface overrides a method on a parent, but no `Override` attribute is present.

```php
<?php

class A {
function receive(): void
{
}
}

class B extends A {
function receive(): void
{
}
}
```

## Why this is bad

Having an `Override` attribute on overridden methods makes intentions clear. Read the [PHP RFC](https://wiki.php.net/rfc/marking_overriden_methods) for more details.
Loading

0 comments on commit c03a8a0

Please sign in to comment.