Skip to content

Commit

Permalink
Merge pull request #8897 from jack-worman/Add_some_more_property_type…
Browse files Browse the repository at this point in the history
…hints

Add property typehints in Internal directory
  • Loading branch information
orklah committed Dec 15, 2022
2 parents 398a1c6 + e7a4fd9 commit e69f88a
Show file tree
Hide file tree
Showing 429 changed files with 763 additions and 2,400 deletions.
4 changes: 2 additions & 2 deletions composer.json
Expand Up @@ -106,8 +106,8 @@
"psalter"
],
"scripts": {
"cs": "phpcs -p",
"cs-fix": "phpcbf -p",
"cs": "phpcs -ps",
"cs-fix": "phpcbf -ps",
"lint": "parallel-lint ./src ./tests",
"phpunit": "paratest --runner=WrapperRunner",
"phpunit-std": "phpunit",
Expand Down
36 changes: 21 additions & 15 deletions phpcs.xml
Expand Up @@ -133,16 +133,16 @@
<property name="allowFullyQualifiedGlobalConstants" type="bool" value="false"/>
<property name="allowFullyQualifiedGlobalClasses" type="bool" value="false"/>

<property name="allowFullyQualifiedNameForCollidingClasses" type="bool" value="false"/>
<property name="allowFullyQualifiedNameForCollidingFunctions" type="bool" value="false"/>
<property name="allowFullyQualifiedNameForCollidingConstants" type="bool" value="false"/>
<property name="allowFullyQualifiedNameForCollidingClasses" type="bool" value="false"/>
<property name="allowFullyQualifiedNameForCollidingFunctions" type="bool" value="false"/>
<property name="allowFullyQualifiedNameForCollidingConstants" type="bool" value="false"/>

<property name="allowFallbackGlobalFunctions" type="bool" value="false"/>
<property name="allowFallbackGlobalConstants" type="bool" value="false"/>
<property name="allowFallbackGlobalFunctions" type="bool" value="false"/>
<property name="allowFallbackGlobalConstants" type="bool" value="false"/>

<property name="allowPartialUses" type="bool" value="true"/>

<property name="searchAnnotations" type="bool" value="true"/>
<property name="searchAnnotations" type="bool" value="true"/>
</properties>
</rule>

Expand Down Expand Up @@ -182,13 +182,6 @@
https://github.com/slevomat/coding-standard#slevomatcodingstandardtypehintsreturntypehint-
-->
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint">
<properties>
<property name="enableObjectTypeHint" type="bool" value="false"/>
<property name="enableStaticTypeHint" type="bool" value="false"/>
<property name="enableMixedTypeHint" type="bool" value="false"/>
<property name="enableUnionTypeHint" type="bool" value="false"/>
</properties>

<exclude name="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification"/>
</rule>

Expand Down Expand Up @@ -235,7 +228,7 @@
-->
<rule ref="SlevomatCodingStandard.PHP.ShortList"/>

<!--
<!--
Requires arrow functions.
https://github.com/slevomat/coding-standard/#slevomatcodingstandardfunctionsrequirearrowfunction-
-->
Expand All @@ -246,7 +239,7 @@
</properties>
</rule>

<!--
<!--
Forces uniform arrow function style
https://github.com/slevomat/coding-standard/blob/master/doc/functions.md#slevomatcodingstandardfunctionsarrowfunctiondeclaration-
-->
Expand All @@ -258,4 +251,17 @@
<property name="allowMultiLine" value="true"/>
</properties>
</rule>

<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/Aliases.php
Expand Up @@ -54,7 +54,6 @@ final class Aliases
* @param array<lowercase-string, string> $functions_flipped
* @param array<string, string> $constants_flipped
* @internal
*
* @psalm-mutation-free
*/
public function __construct(
Expand Down
20 changes: 0 additions & 20 deletions src/Psalm/Codebase.php
Expand Up @@ -389,7 +389,6 @@ private function loadAnalyzer(): void

/**
* @param array<string> $candidate_files
*
*/
public function reloadFiles(ProjectAnalyzer $project_analyzer, array $candidate_files): void
{
Expand Down Expand Up @@ -465,7 +464,6 @@ public function collectLocations(): void

/**
* @param 'always'|'auto' $find_unused_code
*
*/
public function reportUnusedCode(string $find_unused_code = 'auto'): void
{
Expand All @@ -483,7 +481,6 @@ public function reportUnusedVariables(): void

/**
* @param array<string, string> $files_to_analyze
*
*/
public function addFilesToAnalyze(array $files_to_analyze): void
{
Expand All @@ -493,7 +490,6 @@ public function addFilesToAnalyze(array $files_to_analyze): void

/**
* Scans all files their related files
*
*/
public function scanFiles(int $threads = 1): void
{
Expand Down Expand Up @@ -606,7 +602,6 @@ public function findReferencesToProperty(string $property_id): array

/**
* @return CodeLocation[]
*
* @psalm-return array<int, CodeLocation>
*/
public function findReferencesToClassLike(string $fq_class_name): array
Expand Down Expand Up @@ -786,7 +781,6 @@ public function traitHasCorrectCasing(string $fq_trait_name): bool
* a method, closure, or function.
*
* @param non-empty-string $function_id
*
* @return FunctionStorage|MethodStorage
*/
public function getFunctionLikeStorage(
Expand Down Expand Up @@ -838,7 +832,6 @@ public function methodExists(

/**
* @param string|MethodIdentifier $method_id
*
* @return array<int, FunctionLikeParameter>
*/
public function getMethodParams($method_id): array
Expand All @@ -848,7 +841,6 @@ public function getMethodParams($method_id): array

/**
* @param string|MethodIdentifier $method_id
*
*/
public function isVariadic($method_id): bool
{
Expand All @@ -858,7 +850,6 @@ public function isVariadic($method_id): bool
/**
* @param string|MethodIdentifier $method_id
* @param list<Arg> $call_args
*
*/
public function getMethodReturnType($method_id, ?string &$self_class, array $call_args = []): ?Union
{
Expand All @@ -872,7 +863,6 @@ public function getMethodReturnType($method_id, ?string &$self_class, array $cal

/**
* @param string|MethodIdentifier $method_id
*
*/
public function getMethodReturnsByRef($method_id): bool
{
Expand All @@ -881,8 +871,6 @@ public function getMethodReturnsByRef($method_id): bool

/**
* @param string|MethodIdentifier $method_id
* @param CodeLocation|null $defined_location
*
*/
public function getMethodReturnTypeLocation(
$method_id,
Expand All @@ -896,7 +884,6 @@ public function getMethodReturnTypeLocation(

/**
* @param string|MethodIdentifier $method_id
*
*/
public function getDeclaringMethodId($method_id): ?string
{
Expand All @@ -909,7 +896,6 @@ public function getDeclaringMethodId($method_id): ?string
* Get the class this method appears in (vs is declared in, which could give a trait)
*
* @param string|MethodIdentifier $method_id
*
*/
public function getAppearingMethodId($method_id): ?string
{
Expand All @@ -920,7 +906,6 @@ public function getAppearingMethodId($method_id): ?string

/**
* @param string|MethodIdentifier $method_id
*
* @return array<string, MethodIdentifier>
*/
public function getOverriddenMethodIds($method_id): array
Expand All @@ -930,7 +915,6 @@ public function getOverriddenMethodIds($method_id): array

/**
* @param string|MethodIdentifier $method_id
*
*/
public function getCasedMethodId($method_id): string
{
Expand Down Expand Up @@ -986,8 +970,6 @@ public function getFunctionStorageForSymbol(string $file_path, string $symbol):
}

/**
* @param string $file_path
* @param string $symbol
* @return array{ type: string, description?: string|null}|null
*/
public function getSymbolInformation(string $file_path, string $symbol): ?array
Expand Down Expand Up @@ -1941,7 +1923,6 @@ public function queueClassLikeForScanning(

/**
* @param array<string> $taints
*
* @psalm-suppress PossiblyUnusedMethod
*/
public function addTaintSource(
Expand Down Expand Up @@ -1969,7 +1950,6 @@ public function addTaintSource(

/**
* @param array<string> $taints
*
* @psalm-suppress PossiblyUnusedMethod
*/
public function addTaintSink(
Expand Down
12 changes: 2 additions & 10 deletions src/Psalm/Config.php
Expand Up @@ -169,6 +169,7 @@ class Config

/**
* These are special object classes that allow any and all properties to be get/set on them
*
* @var array<int, lowercase-string>
*/
protected $universal_object_crates;
Expand Down Expand Up @@ -205,7 +206,6 @@ class Config
* The directory to store PHP Parser (and other) caches
*
* @internal
*
* @var string|null
*/
public $cache_directory;
Expand Down Expand Up @@ -647,7 +647,6 @@ protected function __construct()
* Searches up a folder hierarchy for the most immediate config.
*
* @throws ConfigException if a config path is not found
*
*/
public static function getConfigForPath(string $path, string $current_dir): Config
{
Expand All @@ -664,7 +663,6 @@ public static function getConfigForPath(string $path, string $current_dir): Conf
* Searches up a folder hierarchy for the most immediate config.
*
* @throws ConfigException
*
*/
public static function locateConfigFile(string $path): ?string
{
Expand Down Expand Up @@ -730,9 +728,9 @@ public function computeHash(): string

/**
* Creates a new config object from an XML string
*
* @param string|null $current_dir Current working directory, if different to $base_dir
* @param non-empty-string $file_contents
*
* @throws ConfigException
*/
public static function loadFromXML(
Expand Down Expand Up @@ -771,7 +769,6 @@ private static function loadDomDocument(string $base_dir, string $file_contents)

/**
* @param non-empty-string $file_contents
*
* @throws ConfigException
*/
private static function validateXmlConfig(string $base_dir, string $file_contents): void
Expand Down Expand Up @@ -941,12 +938,10 @@ private static function processConfigDeprecations(

/**
* @param non-empty-string $file_contents
*
* @psalm-suppress MixedMethodCall
* @psalm-suppress MixedAssignment
* @psalm-suppress MixedArgument
* @psalm-suppress MixedPropertyFetch
*
* @throws ConfigException
*/
private static function fromXmlAndPaths(
Expand Down Expand Up @@ -1361,7 +1356,6 @@ public function setCustomErrorLevel(string $issue_key, string $error_level): voi

/**
* @throws ConfigException if a Config file could not be found
*
*/
private function loadFileExtensions(SimpleXMLElement $extensions): void
{
Expand Down Expand Up @@ -1559,9 +1553,7 @@ private static function requirePath(string $path): void

/**
* @template T
*
* @param T::class $must_extend
*
* @return class-string<T>
*/
private function getPluginClassForPath(Codebase $codebase, string $path, string $must_extend): string
Expand Down
5 changes: 0 additions & 5 deletions src/Psalm/Context.php
Expand Up @@ -439,7 +439,6 @@ public function __destruct()
* @param bool $has_leaving_statements whether or not the parent scope is abandoned between
* $start_context and $end_context
* @param array<string, bool> $updated_vars
*
*/
public function update(
Context $start_context,
Expand Down Expand Up @@ -513,7 +512,6 @@ public function updateReferencesPossiblyFromConfusingScope(

/**
* @param array<string, Union> $new_vars_in_scope
*
* @return array<string, Union>
*/
public function getRedefinedVars(array $new_vars_in_scope, bool $include_new_vars = false): array
Expand Down Expand Up @@ -636,9 +634,7 @@ public function decrementReferenceCount(string $ref_id): void
/**
* @param Clause[] $clauses
* @param array<string, bool> $changed_var_ids
*
* @return array{list<Clause>, list<Clause>}
*
* @psalm-pure
*/
public static function removeReconciledClauses(array $clauses, array $changed_var_ids): array
Expand Down Expand Up @@ -667,7 +663,6 @@ public static function removeReconciledClauses(array $clauses, array $changed_va

/**
* @param Clause[] $clauses
*
* @return list<Clause>
*/
public static function filterClauses(
Expand Down

0 comments on commit e69f88a

Please sign in to comment.