Skip to content

Commit

Permalink
Added SlevomatCodingStandard.TypeHints.PropertyTypeHint sniff
Browse files Browse the repository at this point in the history
  • Loading branch information
jack-worman committed Dec 15, 2022
1 parent 2b5407d commit 76a7c7d
Show file tree
Hide file tree
Showing 26 changed files with 7 additions and 105 deletions.
2 changes: 0 additions & 2 deletions composer.json
Expand Up @@ -123,8 +123,6 @@
"scripts-descriptions": {
"cs": "Checks that the code conforms to the coding standard.",
"cs-fix": "Automatically correct coding standard violations.",
"php-cs-fixer-dry-run": "Checks that the code conforms to the coding standard.",
"php-cs-fixer": "Automatically correct coding standard violations.",
"lint": "Runs unit tests.",
"phpunit": "Runs unit tests in parallel.",
"phpunit-std": "Runs unit tests.",
Expand Down
8 changes: 7 additions & 1 deletion phpcs.xml
Expand Up @@ -252,10 +252,16 @@
</properties>
</rule>

<!-- Disallows empty comments. -->
<rule ref="SlevomatCodingStandard.Commenting.EmptyComment"/>
<rule ref="SlevomatCodingStandard.Commenting.DocCommentSpacing"/>
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHint">
<exclude name="SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingTraversableTypeHintSpecification"/>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.PropertyTypeHint">
<exclude name="SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingTraversableTypeHintSpecification"/>
<!-- TODO: Go though these and fix all that can be fixed without breaking BC -->
<exclude-pattern>src/Psalm/Storage/Assertion/HasArrayKey\.php</exclude-pattern>
<exclude-pattern>src/Psalm/Storage/Assertion/IsNotCountable\.php</exclude-pattern>
<exclude-pattern>src/Psalm/Storage/Assertion/NonEmptyCountable\.php</exclude-pattern>
</rule>
</ruleset>
1 change: 0 additions & 1 deletion src/Psalm/Internal/Analyzer/IssueData.php
Expand Up @@ -88,7 +88,6 @@ class IssueData
public ?array $other_references = null;

/**
* @var ?string
* @readonly
*/
public ?string $dupe_key = null;
Expand Down
7 changes: 0 additions & 7 deletions src/Psalm/Internal/Analyzer/ProjectAnalyzer.php
Expand Up @@ -127,7 +127,6 @@ class ProjectAnalyzer

private ?ParserCacheProvider $parser_cache_provider = null;

/** @var ?ProjectCacheProvider */
public ?ProjectCacheProvider $project_cache_provider = null;

private FileReferenceProvider $file_reference_provider;
Expand All @@ -153,9 +152,6 @@ class ProjectAnalyzer

public bool $only_replace_php_types_with_non_docblock_types = false;

/**
* @var ?int
*/
public ?int $onchange_line_limit = null;

public bool $provide_completion = false;
Expand All @@ -180,9 +176,6 @@ class ProjectAnalyzer
*/
private array $to_refactor = [];

/**
* @var ?ReportOptions
*/
public ?ReportOptions $stdout_report_options = null;

/**
Expand Down
Expand Up @@ -12,14 +12,8 @@
*/
class FunctionCallInfo
{
/**
* @var ?string
*/
public ?string $function_id = null;

/**
* @var ?bool
*/
public ?bool $function_exists = null;

public bool $is_stubbed = false;
Expand All @@ -41,14 +35,8 @@ class FunctionCallInfo
*/
public ?array $function_params = null;

/**
* @var ?FunctionLikeStorage
*/
public ?FunctionLikeStorage $function_storage = null;

/**
* @var ?PhpParser\Node\Name
*/
public ?PhpParser\Node\Name $new_function_name = null;

public bool $allow_named_args = true;
Expand Down
Expand Up @@ -10,9 +10,6 @@
*/
class AtomicMethodCallAnalysisResult
{
/**
* @var ?Union
*/
public ?Union $return_type = null;

public bool $returns_by_ref = false;
Expand Down
3 changes: 0 additions & 3 deletions src/Psalm/Internal/DataFlow/DataFlowNode.php
Expand Up @@ -14,15 +14,12 @@ class DataFlowNode
{
public string $id;

/** @var ?string */
public ?string $unspecialized_id = null;

public string $label;

/** @var ?CodeLocation */
public ?CodeLocation $code_location = null;

/** @var ?string */
public ?string $specialization_key = null;

/** @var array<string> */
Expand Down
4 changes: 0 additions & 4 deletions src/Psalm/Internal/LanguageServer/LanguageServer.php
Expand Up @@ -62,15 +62,11 @@ class LanguageServer extends Dispatcher
{
/**
* Handles textDocument/* method calls
*
* @var ?ServerTextDocument
*/
public ?ServerTextDocument $textDocument = null;

/**
* Handles workspace/* method calls
*
* @var ?ServerWorkspace
*/
public ?ServerWorkspace $workspace = null;

Expand Down
3 changes: 0 additions & 3 deletions src/Psalm/Internal/LanguageServer/Message.php
Expand Up @@ -15,9 +15,6 @@
*/
class Message
{
/**
* @var ?MessageBody
*/
public ?MessageBody $body = null;

/**
Expand Down
Expand Up @@ -113,9 +113,6 @@ class ClassLikeNodeScanner

private Aliases $aliases;

/**
* @var ?ClassLikeStorage
*/
public ?ClassLikeStorage $storage = null;

/**
Expand Down
Expand Up @@ -92,9 +92,6 @@ class FunctionLikeNodeScanner
*/
private array $type_aliases;

/**
* @var ?FunctionLikeStorage
*/
public ?FunctionLikeStorage $storage = null;

/**
Expand Down
3 changes: 0 additions & 3 deletions src/Psalm/Internal/Provider/ClassLikeStorageProvider.php
Expand Up @@ -26,9 +26,6 @@ class ClassLikeStorageProvider
*/
private static array $new_storage = [];

/**
* @var ?ClassLikeStorageCacheProvider
*/
public ?ClassLikeStorageCacheProvider $cache = null;

public function __construct(?ClassLikeStorageCacheProvider $cache = null)
Expand Down
3 changes: 0 additions & 3 deletions src/Psalm/Internal/Provider/FileReferenceProvider.php
Expand Up @@ -164,9 +164,6 @@ class FileReferenceProvider
*/
private static array $method_param_uses = [];

/**
* @var ?FileReferenceCacheProvider
*/
public ?FileReferenceCacheProvider $cache = null;

public function __construct(?FileReferenceCacheProvider $cache = null)
Expand Down
3 changes: 0 additions & 3 deletions src/Psalm/Internal/Provider/FileStorageProvider.php
Expand Up @@ -29,9 +29,6 @@ class FileStorageProvider
*/
private static array $new_storage = [];

/**
* @var ?FileStorageCacheProvider
*/
public ?FileStorageCacheProvider $cache = null;

public function __construct(?FileStorageCacheProvider $cache = null)
Expand Down
6 changes: 0 additions & 6 deletions src/Psalm/Internal/Provider/Providers.php
Expand Up @@ -20,9 +20,6 @@ class Providers
{
public FileProvider $file_provider;

/**
* @var ?ParserCacheProvider
*/
public ?ParserCacheProvider $parser_cache_provider = null;

public FileStorageProvider $file_storage_provider;
Expand All @@ -33,9 +30,6 @@ class Providers

public FileReferenceProvider $file_reference_provider;

/**
* @var ?ProjectCacheProvider
*/
public ?ProjectCacheProvider $project_cache_provider = null;

public function __construct(
Expand Down
3 changes: 0 additions & 3 deletions src/Psalm/Internal/Provider/StatementsProvider.php
Expand Up @@ -43,9 +43,6 @@ class StatementsProvider
{
private FileProvider $file_provider;

/**
* @var ?ParserCacheProvider
*/
public ?ParserCacheProvider $parser_cache_provider = null;

/**
Expand Down
3 changes: 0 additions & 3 deletions src/Psalm/Internal/Provider/StatementsVolatileCache.php
Expand Up @@ -31,9 +31,6 @@ final class StatementsVolatileCache

protected int $max_size;

/**
* @var ?StatementsVolatileCache
*/
protected static ?StatementsVolatileCache $instance = null;

public function __construct(int $max_size = 4096)
Expand Down
6 changes: 0 additions & 6 deletions src/Psalm/Internal/Scanner/ClassLikeDocblockComment.php
Expand Up @@ -51,9 +51,6 @@ class ClassLikeDocblockComment
*/
public array $template_implements = [];

/**
* @var ?string
*/
public ?string $yield = null;

/**
Expand Down Expand Up @@ -103,8 +100,5 @@ class ClassLikeDocblockComment
*/
public array $implementation_requirements = [];

/**
* @var ?string
*/
public ?string $description = null;
}
3 changes: 0 additions & 3 deletions src/Psalm/Internal/Scanner/FunctionDocblockComment.php
Expand Up @@ -170,9 +170,6 @@ class FunctionDocblockComment

public int $since_php_minor_version = 0;

/**
* @var ?string
*/
public ?string $description = null;

/** @var array<string, array{lines:list<int>, suggested_replacement?:string}> */
Expand Down
Expand Up @@ -10,7 +10,6 @@
*/
class KeyValuePair extends UnresolvedConstantComponent
{
/** @var ?UnresolvedConstantComponent */
public ?UnresolvedConstantComponent $key = null;

public UnresolvedConstantComponent $value;
Expand Down
6 changes: 0 additions & 6 deletions src/Psalm/Internal/Scanner/VarDocblockComment.php
Expand Up @@ -9,9 +9,6 @@
*/
class VarDocblockComment
{
/**
* @var ?Union
*/
public ?Union $type = null;

public ?string $var_id = null;
Expand Down Expand Up @@ -59,8 +56,5 @@ class VarDocblockComment
*/
public array $suppressed_issues = [];

/**
* @var ?string
*/
public ?string $description = null;
}
3 changes: 0 additions & 3 deletions src/Psalm/Internal/Scope/IfScope.php
Expand Up @@ -86,8 +86,5 @@ class IfScope
*/
public array $final_actions = [];

/**
* @var ?Context
*/
public ?Context $post_leaving_if_context = null;
}
10 changes: 0 additions & 10 deletions src/Psalm/Internal/Type/Comparator/TypeComparisonResult.php
Expand Up @@ -13,21 +13,15 @@ class TypeComparisonResult
/**
* This is used to trigger `InvalidScalarArgument` in situations where we know PHP
* will try to coerce one scalar type to another.
*
* @var ?bool
*/
public ?bool $scalar_type_match_found = null;

/** @var ?bool */
public ?bool $type_coerced = null;

/** @var ?bool */
public ?bool $type_coerced_from_mixed = null;

/** @var ?bool */
public ?bool $type_coerced_from_as_mixed = null;

/** @var ?bool */
public ?bool $to_string_cast = null;

/**
Expand All @@ -38,15 +32,11 @@ class TypeComparisonResult
* function takesAnInt(int $i): string {
* return ["foo", "bar"][$i];
* }
*
* @var ?bool
*/
public ?bool $type_coerced_from_scalar = null;

/** @var ?Union */
public ?Union $replacement_union_type = null;

/** @var ?Atomic */
public ?Atomic $replacement_atomic_type = null;

/** @var ?non-empty-list<int|string> */
Expand Down
3 changes: 0 additions & 3 deletions src/Psalm/Internal/Type/ParseTree/Value.php
Expand Up @@ -15,9 +15,6 @@ class Value extends ParseTree

public int $offset_end;

/**
* @var ?string
*/
public ?string $text = null;

public function __construct(
Expand Down
4 changes: 0 additions & 4 deletions src/Psalm/Internal/Type/TemplateBound.php
Expand Up @@ -24,15 +24,11 @@ class TemplateBound
* The argument offset where this template was set
*
* In the type Foo<T, string, T> the type appears at argument offsets 0 and 2
*
* @var ?int
*/
public ?int $arg_offset = null;

/**
* When non-null, indicates an equality template bound (vs a lower or upper bound)
*
* @var ?string
*/
public ?string $equality_bound_classlike = null;

Expand Down
6 changes: 0 additions & 6 deletions src/Psalm/Internal/Type/TypeCombination.php
Expand Up @@ -50,17 +50,14 @@ class TypeCombination

public bool $objectlike_sealed = true;

/** @var ?Union */
public ?Union $objectlike_key_type = null;

/** @var ?Union */
public ?Union $objectlike_value_type = null;

public bool $empty_mixed = false;

public bool $non_empty_mixed = false;

/** @var ?bool */
public ?bool $mixed_from_loop_isset = null;

/** @var array<string, TLiteralString>|null */
Expand All @@ -80,13 +77,10 @@ class TypeCombination
*/
public array $extra_types = [];

/** @var ?bool */
public ?bool $all_arrays_lists = null;

/** @var ?bool */
public ?bool $all_arrays_callable = null;

/** @var ?bool */
public ?bool $all_arrays_class_string_maps = null;

/** @var array<string, bool> */
Expand Down

0 comments on commit 76a7c7d

Please sign in to comment.