Skip to content

Commit

Permalink
Strict properties
Browse files Browse the repository at this point in the history
  • Loading branch information
danog committed Oct 19, 2023
1 parent 989d171 commit 7761939
Show file tree
Hide file tree
Showing 85 changed files with 627 additions and 1,643 deletions.
2 changes: 1 addition & 1 deletion UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

- [BC] The return type of `Psalm\Internal\LanguageServer\ProtocolWriter#write() changed from `Amp\Promise` to `void` due to the switch to Amp v3

- [BC] All parameters and return typehints are now strictly typed.
- [BC] All parameters, properties and return typehints are now strictly typed.

- [BC] `strict_types` is now applied to all files of the Psalm codebase.

Expand Down
4 changes: 0 additions & 4 deletions phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,6 @@
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.PropertyTypeHint">
<exclude name="SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingTraversableTypeHintSpecification"/>
<!-- TODO: Remove in Psalm 6 -->
<include-pattern>bin/*</include-pattern>
<include-pattern>src/Psalm/Internal/*</include-pattern>
<include-pattern>tests/*</include-pattern>
</rule>
<rule ref="SlevomatCodingStandard.Arrays.TrailingArrayComma"/>
<rule ref="SlevomatCodingStandard.Functions.RequireTrailingCommaInCall"/>
Expand Down
10 changes: 10 additions & 0 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,16 @@
<code>$stub</code>
</PossiblyUndefinedIntArrayOffset>
</file>
<file src="src/Psalm/Internal/Codebase/Methods.php">
<InvalidArgument>
<code><![CDATA[$class_storage->methods[$declaring_method_name]->stubbed]]></code>
</InvalidArgument>
</file>
<file src="src/Psalm/Internal/Codebase/Populator.php">
<InvalidArgument>
<code><![CDATA[$storage->methods[$implementing_method_id->method_name]->abstract]]></code>
</InvalidArgument>
</file>
<file src="src/Psalm/Internal/Codebase/Properties.php">
<PossiblyUndefinedIntArrayOffset>
<code>$property_name</code>
Expand Down
24 changes: 10 additions & 14 deletions src/Psalm/Aliases.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,44 +9,40 @@ final class Aliases
/**
* @var array<lowercase-string, string>
*/
public $uses;
public array $uses;

/**
* @var array<lowercase-string, string>
*/
public $uses_flipped;
public array $uses_flipped;

/**
* @var array<lowercase-string, non-empty-string>
*/
public $functions;
public array $functions;

/**
* @var array<lowercase-string, string>
*/
public $functions_flipped;
public array $functions_flipped;

/**
* @var array<string, string>
*/
public $constants;
public array $constants;

/**
* @var array<string, string>
*/
public $constants_flipped;
public array $constants_flipped;

/** @var string|null */
public $namespace;
public ?string $namespace = null;

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

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

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

/**
* @param array<lowercase-string, string> $uses
Expand Down
36 changes: 12 additions & 24 deletions src/Psalm/CodeLocation.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,34 +35,25 @@ class CodeLocation
{
use ImmutableNonCloneableTrait;

/** @var string */
public $file_path;
public string $file_path;

/** @var string */
public $file_name;
public string $file_name;

/** @var int */
public $raw_line_number;
public int $raw_line_number;

private int $end_line_number = -1;

/** @var int */
public $raw_file_start;
public int $raw_file_start;

/** @var int */
public $raw_file_end;
public int $raw_file_end;

/** @var int */
protected $file_start;
protected int $file_start;

/** @var int */
protected $file_end;
protected int $file_end;

/** @var bool */
protected $single_line;
protected bool $single_line;

/** @var int */
protected $preview_start;
protected int $preview_start;

private int $preview_end = -1;

Expand All @@ -78,20 +69,17 @@ class CodeLocation

private ?string $text = null;

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

private ?int $docblock_start_line_number = null;

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

private ?int $regex_type = null;

private bool $have_recalculated = false;

/** @var null|CodeLocation */
public $previous_location;
public ?CodeLocation $previous_location = null;

public const VAR_TYPE = 0;
public const FUNCTION_RETURN_TYPE = 1;
Expand Down
Loading

0 comments on commit 7761939

Please sign in to comment.