1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 20:34:47 +01:00

Add documentation and schema entry for inferPropertyTypesFromConstructor

Fixes vimeo/psalm#5974
This commit is contained in:
Bruce Weirdan 2021-06-22 21:20:10 +03:00
parent 6d4d1668f6
commit f24f361a95
No known key found for this signature in database
GPG Key ID: CFC3AAB181751B0D
3 changed files with 19 additions and 0 deletions

View File

@ -59,6 +59,7 @@
<xs:attribute name="ignoreInternalFunctionFalseReturn" type="xs:boolean" default="true" />
<xs:attribute name="ignoreInternalFunctionNullReturn" type="xs:boolean" default="true" />
<xs:attribute name="includePhpVersionsInErrorBaseline" type="xs:boolean" default="false" />
<xs:attribute name="inferPropertyTypesFromConstructor" type="xs:boolean" default="true" />
<xs:attribute name="loadXdebugStub" type="xs:boolean">
<xs:annotation>
<xs:documentation xml:lang="en">

View File

@ -213,6 +213,15 @@ When `true`, Psalm ignores possibly-false issues stemming from return values of
```
When `true`, Psalm ignores possibly-null issues stemming from return values of internal array functions (like `current`) that may return null, but do so rarely. Defaults to `true`.
#### inferPropertyTypesFromConstructor
```xml
<psalm
inferPropertyTypesFromConstructor="[bool]"
>
```
When `true`, Psalm infers property types from assignments seen in straightforward constructors. Defaults to `true`.
#### findUnusedVariablesAndParams
```xml
<psalm

View File

@ -1341,6 +1341,15 @@ class ConfigTest extends \Psalm\Tests\TestCase
$this->assertContains('datetime', $this->project_analyzer->getConfig()->getUniversalObjectCrates());
}
public function testInferPropertyTypesFromConstructorIsRead(): void
{
$cfg = Config::loadFromXML(
dirname(__DIR__, 2),
'<?xml version="1.0"?><psalm inferPropertyTypesFromConstructor="false"></psalm>'
);
$this->assertFalse($cfg->infer_property_types_from_constructor);
}
/**
* @return array<string, array{0: int, 1: int|null}>
*/