1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-22 22:01:48 +01:00

Merge pull request #9568 from iFixit/sealed-properties--add-config-for-assumption

@property annotations: allow *not* implying @psalm-seal-properties
This commit is contained in:
orklah 2023-03-27 20:33:21 +02:00 committed by GitHub
commit 49cf5d07cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 1 deletions

View File

@ -62,6 +62,7 @@
<xs:attribute name="reportMixedIssues" type="xs:boolean" default="true" />
<xs:attribute name="useDocblockTypes" type="xs:boolean" default="true" />
<xs:attribute name="useDocblockPropertyTypes" type="xs:boolean" default="false" />
<xs:attribute name="docblockPropertyTypesSealProperties" type="xs:boolean" default="true" />
<xs:attribute name="usePhpDocMethodsWithoutMagicCall" type="xs:boolean" default="false" />
<xs:attribute name="usePhpDocPropertiesWithoutMagicCall" type="xs:boolean" default="false" />
<xs:attribute name="skipChecksOnUnresolvableIncludes" type="xs:boolean" default="false" />

View File

@ -90,6 +90,15 @@ Whether or not to use types as defined in docblocks. Defaults to `true`.
```
If not using all docblock types, you can still use docblock property types. Defaults to `false` (though only relevant if `useDocblockTypes` is `false`).
#### docblockPropertyTypesSealProperties
```xml
<psalm
docblockPropertyTypesSealProperties="[bool]"
>
```
Whether using @property in class docblocks should imply @psalm-seal-properties. Defaults to `true`.
#### usePhpDocMethodsWithoutMagicCall
```xml

View File

@ -194,6 +194,13 @@ class Config
*/
public $use_docblock_property_types = false;
/**
* Whether using property annotations in docblocks should implicitly seal properties
*
* @var bool
*/
public $docblock_property_types_seal_properties = true;
/**
* Whether or not to throw an exception on first error
*
@ -1049,6 +1056,7 @@ class Config
$booleanAttributes = [
'useDocblockTypes' => 'use_docblock_types',
'useDocblockPropertyTypes' => 'use_docblock_property_types',
'docblockPropertyTypesSealProperties' => 'docblock_property_types_seal_properties',
'throwExceptionOnError' => 'throw_exception',
'hideExternalErrors' => 'hide_external_errors',
'hideAllErrorsExceptPassedFiles' => 'hide_all_errors_except_passed_files',

View File

@ -568,7 +568,9 @@ class ClassLikeNodeScanner
}
}
$storage->sealed_properties = true;
if ($this->config->docblock_property_types_seal_properties) {
$storage->sealed_properties = true;
}
}
foreach ($docblock_info->methods as $method) {