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

Improve names of things

This commit is contained in:
Matthew Brown 2020-08-14 00:27:33 -04:00
parent 057d2cc678
commit 72ecb57def
8 changed files with 20 additions and 20 deletions

View File

@ -73,8 +73,8 @@
<xs:attribute name="sealAllMethods" type="xs:boolean" default="false" />
<xs:attribute name="runTaintAnalysis" type="xs:boolean" default="false" />
<xs:attribute name="usePhpStormMetaPath" type="xs:boolean" default="true" />
<xs:attribute name="allowInternalNamedParamCalls" type="xs:boolean" default="true" />
<xs:attribute name="allowNamedParamCalls" type="xs:boolean" default="true" />
<xs:attribute name="allowInternalNamedArgumentCalls" type="xs:boolean" default="true" />
<xs:attribute name="allowNamedArgumentCalls" type="xs:boolean" default="true" />
</xs:complexType>
<xs:complexType name="ProjectFilesType">

View File

@ -46,9 +46,9 @@ class AChild extends A {
## Workarounds
### @no-named-params
### @no-named-arguments
Alternatively you can ignore this issue by adding a `@no-named-params` annotation to the parent method:
Alternatively you can ignore this issue by adding a `@no-named-arguments` annotation to the parent method:
```php
<?php
@ -65,13 +65,13 @@ class AChild extends A {
Any method with this annotation will be prevented (by Psalm) from being called with named parameters, so the original issue does not matter.
### Config allowNamedParamCalls="false"
### Config allowNamedArgumentCalls="false"
This prevents any use of named params in your codebase. Ideal for self-contained projects, but less ideal for libraries.
It means the original code above will not emit any errors as long as the class `A` is defined in a directory that Psalm can scan.
### Config allowInternalNamedParamCalls="false"
### Config allowInternalNamedArgumentCalls="false"
For library authors Psalm supports a more nuanced flag that tells Psalm to prohibit any named parameter calls on `@internal` classes or methods.

View File

@ -529,12 +529,12 @@ class Config
/**
* @var bool
*/
public $allow_internal_named_param_calls = true;
public $allow_internal_named_arg_calls = true;
/**
* @var bool
*/
public $allow_named_param_calls = true;
public $allow_named_arg_calls = true;
/**
* Static methods to be called after functionlike checks have completed
@ -834,8 +834,8 @@ class Config
'sealAllMethods' => 'seal_all_methods',
'runTaintAnalysis' => 'run_taint_analysis',
'usePhpStormMetaPath' => 'use_phpstorm_meta_path',
'allowInternalNamedParamCalls' => 'allow_internal_named_param_calls',
'allowNamedParamCalls' => 'allow_named_param_calls',
'allowInternalNamedArgumentsCalls' => 'allow_internal_named_arg_calls',
'allowNamedArgumentCalls' => 'allow_named_arg_calls',
];
foreach ($booleanAttributes as $xmlName => $internalName) {

View File

@ -756,8 +756,8 @@ class CommentAnalyzer
$info->external_mutation_free = true;
}
if (isset($parsed_docblock->tags['no-named-params'])) {
$info->no_named_params = true;
if (isset($parsed_docblock->tags['no-named-arguments'])) {
$info->no_named_args = true;
}
$info->ignore_nullable_return = isset($parsed_docblock->tags['psalm-ignore-nullable-return']);

View File

@ -383,14 +383,14 @@ class MethodComparator
}
if ($guide_param->name !== $implementer_param->name
&& $guide_method_storage->allow_named_param_calls
&& $guide_method_storage->allow_named_arg_calls
&& count($implementer_method_storage->params) > 1
&& $guide_classlike_storage->user_defined
&& $implementer_classlike_storage->user_defined
) {
$config = \Psalm\Config::getInstance();
if ($config->allow_named_param_calls
if ($config->allow_named_arg_calls
|| ($guide_classlike_storage->location
&& !$config->isInProjectDirs($guide_classlike_storage->location->file_path)
)

View File

@ -2286,11 +2286,11 @@ class ReflectorVisitor extends PhpParser\NodeVisitorAbstract implements PhpParse
}
if (($storage->internal || ($class_storage && $class_storage->internal))
&& !$this->config->allow_internal_named_param_calls
&& !$this->config->allow_internal_named_arg_calls
) {
$storage->allow_named_param_calls = false;
} elseif ($docblock_info->no_named_params) {
$storage->allow_named_param_calls = false;
$storage->allow_named_arg_calls = false;
} elseif ($docblock_info->no_named_args) {
$storage->allow_named_arg_calls = false;
}
if ($docblock_info->variadic) {

View File

@ -192,5 +192,5 @@ class FunctionDocblockComment
/**
* @var bool
*/
public $no_named_params = false;
public $no_named_args = false;
}

View File

@ -202,7 +202,7 @@ abstract class FunctionLikeStorage
/**
* @var bool
*/
public $allow_named_param_calls = true;
public $allow_named_arg_calls = true;
public function __toString()
{