mirror of
https://github.com/danog/psalm.git
synced 2024-11-27 04:45:20 +01:00
Merge branch '4.x' into upstream-master
This commit is contained in:
commit
d7d846edc8
@ -108,6 +108,16 @@ The PHPDoc `@method` annotation normally only applies to classes with a `__call`
|
||||
```
|
||||
The PHPDoc `@property`, `@property-read` and `@property-write` annotations normally only apply to classes with `__get`/`__set` methods. Setting this to `true` allows you to use the `@property`, `@property-read` and `@property-write` annotations to override property existence checks and resulting property types. Defaults to `false`.
|
||||
|
||||
#### disableVarParsing
|
||||
|
||||
```xml
|
||||
<psalm
|
||||
disableVarParsing="[bool]"
|
||||
/>
|
||||
```
|
||||
|
||||
Disables parsing of `@var` PHPDocs everywhere except for properties. Setting this to `true` can remove many false positives due to outdated `@var` annotations, used before integrations of Psalm generics and proper typing, enforcing Single Source Of Truth principles. Defaults to `false`.
|
||||
|
||||
#### strictBinaryOperands
|
||||
|
||||
```xml
|
||||
|
@ -367,6 +367,11 @@ class Config
|
||||
*/
|
||||
public $add_param_default_to_docblock_type = false;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
public $disable_var_parsing = false;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
@ -954,6 +959,7 @@ class Config
|
||||
'allowFileIncludes' => 'allow_includes',
|
||||
'strictBinaryOperands' => 'strict_binary_operands',
|
||||
'rememberPropertyAssignmentsAfterCall' => 'remember_property_assignments_after_call',
|
||||
'disableVarParsing' => 'disable_var_parsing',
|
||||
'allowStringToStandInForClass' => 'allow_string_standin_for_class',
|
||||
'disableSuppressAll' => 'disable_suppress_all',
|
||||
'usePhpDocMethodsWithoutMagicCall' => 'use_phpdoc_method_without_magic_or_parent',
|
||||
|
@ -162,13 +162,15 @@ class AssignmentAnalyzer
|
||||
$template_type_map = $statements_analyzer->getTemplateTypeMap();
|
||||
|
||||
try {
|
||||
$var_comments = CommentAnalyzer::getTypeFromComment(
|
||||
$doc_comment,
|
||||
$statements_analyzer->getSource(),
|
||||
$statements_analyzer->getAliases(),
|
||||
$template_type_map,
|
||||
$file_storage->type_aliases
|
||||
);
|
||||
$var_comments = $codebase->config->disable_var_parsing
|
||||
? []
|
||||
: CommentAnalyzer::getTypeFromComment(
|
||||
$doc_comment,
|
||||
$statements_analyzer->getSource(),
|
||||
$statements_analyzer->getAliases(),
|
||||
$template_type_map,
|
||||
$file_storage->type_aliases
|
||||
);
|
||||
} catch (IncorrectDocblockException $e) {
|
||||
IssueBuffer::maybeAdd(
|
||||
new MissingDocblockType(
|
||||
|
@ -74,14 +74,16 @@ class ReturnAnalyzer
|
||||
$file_storage = $file_storage_provider->get($statements_analyzer->getFilePath());
|
||||
|
||||
try {
|
||||
$var_comments = CommentAnalyzer::arrayToDocblocks(
|
||||
$doc_comment,
|
||||
$parsed_docblock,
|
||||
$statements_analyzer->getSource(),
|
||||
$statements_analyzer->getAliases(),
|
||||
$statements_analyzer->getTemplateTypeMap(),
|
||||
$file_storage->type_aliases
|
||||
);
|
||||
$var_comments = $codebase->config->disable_var_parsing
|
||||
? []
|
||||
: CommentAnalyzer::arrayToDocblocks(
|
||||
$doc_comment,
|
||||
$parsed_docblock,
|
||||
$statements_analyzer->getSource(),
|
||||
$statements_analyzer->getAliases(),
|
||||
$statements_analyzer->getTemplateTypeMap(),
|
||||
$file_storage->type_aliases
|
||||
);
|
||||
} catch (DocblockParseException $e) {
|
||||
IssueBuffer::maybeAdd(
|
||||
new InvalidDocblock(
|
||||
|
@ -60,13 +60,15 @@ class StaticAnalyzer
|
||||
$var_comments = [];
|
||||
|
||||
try {
|
||||
$var_comments = CommentAnalyzer::arrayToDocblocks(
|
||||
$doc_comment,
|
||||
$parsed_docblock,
|
||||
$statements_analyzer->getSource(),
|
||||
$statements_analyzer->getSource()->getAliases(),
|
||||
$statements_analyzer->getSource()->getTemplateTypeMap()
|
||||
);
|
||||
$var_comments = $codebase->config->disable_var_parsing
|
||||
? []
|
||||
: CommentAnalyzer::arrayToDocblocks(
|
||||
$doc_comment,
|
||||
$parsed_docblock,
|
||||
$statements_analyzer->getSource(),
|
||||
$statements_analyzer->getSource()->getAliases(),
|
||||
$statements_analyzer->getSource()->getTemplateTypeMap()
|
||||
);
|
||||
} catch (IncorrectDocblockException $e) {
|
||||
IssueBuffer::maybeAdd(
|
||||
new MissingDocblockType(
|
||||
|
@ -459,14 +459,16 @@ class StatementsAnalyzer extends SourceAnalyzer
|
||||
$var_comments = [];
|
||||
|
||||
try {
|
||||
$var_comments = CommentAnalyzer::arrayToDocblocks(
|
||||
$docblock,
|
||||
$statements_analyzer->parsed_docblock,
|
||||
$statements_analyzer->getSource(),
|
||||
$statements_analyzer->getAliases(),
|
||||
$template_type_map,
|
||||
$file_storage->type_aliases
|
||||
);
|
||||
$var_comments = $codebase->config->disable_var_parsing
|
||||
? []
|
||||
: CommentAnalyzer::arrayToDocblocks(
|
||||
$docblock,
|
||||
$statements_analyzer->parsed_docblock,
|
||||
$statements_analyzer->getSource(),
|
||||
$statements_analyzer->getAliases(),
|
||||
$template_type_map,
|
||||
$file_storage->type_aliases
|
||||
);
|
||||
} catch (IncorrectDocblockException $e) {
|
||||
IssueBuffer::maybeAdd(
|
||||
new MissingDocblockType(
|
||||
|
@ -10,6 +10,7 @@ use RuntimeException;
|
||||
use function assert;
|
||||
use function file_get_contents;
|
||||
use function file_put_contents;
|
||||
use function sprintf;
|
||||
use function strpos;
|
||||
use function substr;
|
||||
|
||||
@ -146,6 +147,9 @@ class ConfigFile
|
||||
}
|
||||
}
|
||||
|
||||
file_put_contents($this->path, $new_file_contents);
|
||||
$result = file_put_contents($this->path, $new_file_contents);
|
||||
if ($result === false) {
|
||||
throw new RuntimeException(sprintf('Unable to save xml to %s', $this->path));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user