Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Last property typehints #8910

Merged
merged 2 commits into from Dec 17, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
57 changes: 23 additions & 34 deletions phpcs.xml
Expand Up @@ -10,7 +10,7 @@
* Configuration *
************************************************************************************************************** -->

<config name="php_version" value="70100"/>
<config name="php_version" value="70400"/>
<config name="installed_paths" value="../../slevomat/coding-standard"/>

<arg name="basepath" value="."/>
Expand Down Expand Up @@ -86,10 +86,10 @@
-->
<rule ref="SlevomatCodingStandard.TypeHints.DeclareStrictTypes">
<properties>
<property name="declareOnFirstLine" type="bool" value="false"/>
<property name="linesCountBeforeDeclare" type="int" value="1"/>
<property name="linesCountAfterDeclare" type="int" value="1"/>
<property name="spacesCountAroundEqualsSign" type="int" value="0"/>
<property name="declareOnFirstLine" value="false"/>
<property name="linesCountBeforeDeclare" value="1"/>
<property name="linesCountAfterDeclare" value="1"/>
<property name="spacesCountAroundEqualsSign" value="0"/>
</properties>

<exclude name="SlevomatCodingStandard.TypeHints.DeclareStrictTypes.DeclareStrictTypesMissing"/>
Expand All @@ -113,8 +113,8 @@
-->
<rule ref="SlevomatCodingStandard.Namespaces.NamespaceSpacing">
<properties>
<property name="linesCountBeforeNamespace" type="int" value="1"/>
<property name="linesCountAfterNamespace" type="int" value="1"/>
<property name="linesCountBeforeNamespace" value="1"/>
<property name="linesCountAfterNamespace" value="1"/>
</properties>
</rule>

Expand All @@ -128,21 +128,21 @@
-->
<rule ref="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly">
<properties>
<property name="allowFullyQualifiedExceptions" type="bool" value="false"/>
<property name="allowFullyQualifiedGlobalFunctions" type="bool" value="false"/>
<property name="allowFullyQualifiedGlobalConstants" type="bool" value="false"/>
<property name="allowFullyQualifiedGlobalClasses" type="bool" value="false"/>
<property name="allowFullyQualifiedExceptions" value="false"/>
<property name="allowFullyQualifiedGlobalFunctions" value="false"/>
<property name="allowFullyQualifiedGlobalConstants" value="false"/>
<property name="allowFullyQualifiedGlobalClasses" 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" value="false"/>
<property name="allowFullyQualifiedNameForCollidingFunctions" value="false"/>
<property name="allowFullyQualifiedNameForCollidingConstants" value="false"/>

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

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

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

Expand All @@ -162,7 +162,7 @@
-->
<rule ref="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses">
<properties>
<property name="psr12Compatible" type="bool" value="true"/>
<property name="psr12Compatible" value="true"/>
<property name="caseSensitive" value="true"/>
</properties>
</rule>
Expand Down Expand Up @@ -228,17 +228,6 @@
-->
<rule ref="SlevomatCodingStandard.PHP.ShortList"/>

<!--
Requires arrow functions.
https://github.com/slevomat/coding-standard/#slevomatcodingstandardfunctionsrequirearrowfunction-
-->
<rule ref="SlevomatCodingStandard.Functions.RequireArrowFunction">
jack-worman marked this conversation as resolved.
Show resolved Hide resolved
<properties>
<property name="enabled" value="true"/>
<property name="allowNested" value="true"/>
</properties>
</rule>

<!--
Forces uniform arrow function style
https://github.com/slevomat/coding-standard/blob/master/doc/functions.md#slevomatcodingstandardfunctionsarrowfunctiondeclaration-
Expand All @@ -259,9 +248,9 @@
</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>
<!-- TODO: Remove these include-patterns in Psalm v6.0.0 -->
<include-pattern>bin/*</include-pattern>
<include-pattern>src/Psalm/Internal/*</include-pattern>
<include-pattern>tests/*</include-pattern>
</rule>
</ruleset>
9 changes: 3 additions & 6 deletions src/Psalm/CodeLocation.php
Expand Up @@ -74,20 +74,17 @@ class CodeLocation

private string $snippet = '';

/** @var null|string */
private $text;
private ?string $text = null;

/** @var int|null */
public $docblock_start;

/** @var int|null */
private $docblock_start_line_number;
private ?int $docblock_start_line_number = null;

/** @var int|null */
protected $docblock_line_number;

/** @var null|int */
private $regex_type;
private ?int $regex_type = null;

private bool $have_recalculated = false;

Expand Down
5 changes: 1 addition & 4 deletions src/Psalm/Config.php
Expand Up @@ -559,10 +559,7 @@ class Config
*/
public $debug_emitted_issues = false;

/**
* @var bool
*/
private $report_info = true;
private bool $report_info = true;
weirdan marked this conversation as resolved.
Show resolved Hide resolved

/**
* @var EventDispatcher
Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Internal/Fork/ForkProcessErrorMessage.php
Expand Up @@ -11,7 +11,7 @@
class ForkProcessErrorMessage implements ForkMessage
{
use ImmutableNonCloneableTrait;

public string $message;

public function __construct(string $message)
Expand Down
3 changes: 1 addition & 2 deletions src/Psalm/Report/ByIssueLevelAndTypeReport.php
Expand Up @@ -17,8 +17,7 @@

final class ByIssueLevelAndTypeReport extends Report
{
/** @var string|null */
private $link_format;
private ?string $link_format = null;

public function create(): string
{
Expand Down
3 changes: 1 addition & 2 deletions src/Psalm/Report/ConsoleReport.php
Expand Up @@ -16,8 +16,7 @@

final class ConsoleReport extends Report
{
/** @var string|null */
private $link_format;
private ?string $link_format = null;

public function create(): string
{
Expand Down
18 changes: 7 additions & 11 deletions src/Psalm/Type/MutableUnion.php
Expand Up @@ -36,7 +36,7 @@ final class MutableUnion implements TypeNode, Stringable
/**
* @var non-empty-array<string, Atomic>
*/
private $types;
private array $types;

/**
* Whether the type originated in a docblock
Expand Down Expand Up @@ -158,22 +158,22 @@ final class MutableUnion implements TypeNode, Stringable
/**
* @var array<string, TLiteralString>
*/
private $literal_string_types = [];
private array $literal_string_types = [];

/**
* @var array<string, TClassString>
*/
private $typed_class_strings = [];
private array $typed_class_strings = [];

/**
* @var array<string, TLiteralInt>
*/
private $literal_int_types = [];
private array $literal_int_types = [];

/**
* @var array<string, TLiteralFloat>
*/
private $literal_float_types = [];
private array $literal_float_types = [];

/**
* True if the type was passed or returned by reference, or if the type refers to an object's
Expand Down Expand Up @@ -201,17 +201,13 @@ final class MutableUnion implements TypeNode, Stringable

/**
* This is a cache of getId on non-exact mode
*
* @var null|string
*/
private $id;
private ?string $id = null;

/**
* This is a cache of getId on exact mode
*
* @var null|string
*/
private $exact_id;
private ?string $exact_id = null;


/**
Expand Down
18 changes: 7 additions & 11 deletions src/Psalm/Type/Union.php
Expand Up @@ -49,7 +49,7 @@ final class Union implements TypeNode, Stringable
* @psalm-readonly
* @var non-empty-array<string, Atomic>
*/
private $types;
private array $types;

/**
* Whether the type originated in a docblock
Expand Down Expand Up @@ -170,22 +170,22 @@ final class Union implements TypeNode, Stringable
/**
* @var array<string, TLiteralString>
*/
private $literal_string_types = [];
private array $literal_string_types = [];

/**
* @var array<string, TClassString>
*/
private $typed_class_strings = [];
private array $typed_class_strings = [];

/**
* @var array<string, TLiteralInt>
*/
private $literal_int_types = [];
private array $literal_int_types = [];

/**
* @var array<string, TLiteralFloat>
*/
private $literal_float_types = [];
private array $literal_float_types = [];

/**
* True if the type was passed or returned by reference, or if the type refers to an object's
Expand Down Expand Up @@ -213,17 +213,13 @@ final class Union implements TypeNode, Stringable

/**
* This is a cache of getId on non-exact mode
*
* @var null|string
*/
private $id;
private ?string $id = null;

/**
* This is a cache of getId on exact mode
*
* @var null|string
*/
private $exact_id;
private ?string $exact_id;


/**
Expand Down
3 changes: 1 addition & 2 deletions tests/CodebaseTest.php
Expand Up @@ -24,8 +24,7 @@

class CodebaseTest extends TestCase
{
/** @var Codebase */
private $codebase;
private Codebase $codebase;

public function setUp(): void
{
Expand Down
3 changes: 1 addition & 2 deletions tests/Config/ConfigFileTest.php
Expand Up @@ -21,8 +21,7 @@
/** @group PluginManager */
class ConfigFileTest extends TestCase
{
/** @var string */
private $file_path;
private string $file_path;

public function setUp(): void
{
Expand Down
6 changes: 2 additions & 4 deletions tests/Config/ConfigTest.php
Expand Up @@ -43,11 +43,9 @@

class ConfigTest extends TestCase
{
/** @var TestConfig */
protected static $config;
protected static TestConfig $config;

/** @var ProjectAnalyzer */
protected $project_analyzer;
protected ProjectAnalyzer $project_analyzer;

/** @var callable(int, string, string=, int=, array=):bool|null */
protected $original_error_handler = null;
Expand Down
7 changes: 2 additions & 5 deletions tests/Config/Plugin/FileTypeSelfRegisteringPlugin.php
Expand Up @@ -18,12 +18,9 @@ class FileTypeSelfRegisteringPlugin implements PluginFileExtensionsInterface
/**
* @var array<string, string>
*/
public static $names = [];
public static array $names = [];

/**
* @var int
*/
public static $flags = 0;
public static int $flags = 0;

public function processFileExtensions(FileExtensionsInterface $fileExtensions, ?SimpleXMLElement $config = null): void
{
Expand Down
6 changes: 2 additions & 4 deletions tests/Config/PluginTest.php
Expand Up @@ -39,8 +39,7 @@

class PluginTest extends TestCase
{
/** @var TestConfig */
protected static $config;
protected static TestConfig $config;

public static function setUpBeforeClass(): void
{
Expand Down Expand Up @@ -873,8 +872,7 @@ public function testAfterEveryFunctionPluginIsCalledInAllCases(): void
[$this->equalTo('a')]
);
$plugin = new class($mock) implements AfterEveryFunctionCallAnalysisInterface {
/** @var MockObject */
private static $m;
private static MockObject $m;

public function __construct(MockObject $m)
{
Expand Down
9 changes: 3 additions & 6 deletions tests/DocumentationTest.php
Expand Up @@ -83,11 +83,9 @@ class DocumentationTest extends TestCase
'@psalm-stub-override',
];

/** @var ProjectAnalyzer */
protected $project_analyzer;
protected ProjectAnalyzer $project_analyzer;

/** @var string */
private static $docContents = '';
private static string $docContents = '';

/**
* @return array<string, array<int, string>>
Expand Down Expand Up @@ -389,8 +387,7 @@ public function conciseExpected(Constraint $inner): Constraint
{
return new class ($inner) extends Constraint
{
/** @var Constraint */
private $inner;
private Constraint $inner;

public function __construct(Constraint $inner)
{
Expand Down
3 changes: 1 addition & 2 deletions tests/EndToEnd/PsalmEndToEndTest.php
Expand Up @@ -35,8 +35,7 @@ class PsalmEndToEndTest extends TestCase
{
use PsalmRunnerTrait;

/** @var string */
private static $tmpDir;
private static string $tmpDir;

public static function setUpBeforeClass(): void
{
Expand Down