Skip to content

Commit

Permalink
Make more properties readonly
Browse files Browse the repository at this point in the history
  • Loading branch information
danog committed Oct 21, 2023
1 parent 4a433d3 commit f1d7843
Show file tree
Hide file tree
Showing 29 changed files with 68 additions and 68 deletions.
2 changes: 1 addition & 1 deletion src/Psalm/Internal/Analyzer/AttributesAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ private static function getAttributeClassFlags(
return self::TARGET_ALL; // Defaults to TARGET_ALL
}

$first_arg = reset($attribute_attribute->args);
$first_arg = $attribute_attribute->args[array_key_first($attribute_attribute->args)];

$first_arg_type = $first_arg->type;

Expand Down
22 changes: 11 additions & 11 deletions src/Psalm/Internal/Analyzer/DataFlowNodeData.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ final class DataFlowNodeData
use ImmutableNonCloneableTrait;

public function __construct(
public string $label,
public int $line_from,
public int $line_to,
public string $file_name,
public string $file_path,
public string $snippet,
public int $from,
public int $to,
public int $snippet_from,
public int $column_from,
public int $column_to,
public readonly string $label,
public readonly int $line_from,
public readonly int $line_to,
public readonly string $file_name,
public readonly string $file_path,
public readonly string $snippet,
public readonly int $from,
public readonly int $to,
public readonly int $snippet_from,
public readonly int $column_from,
public readonly int $column_to,
) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ final class HighOrderFunctionArgInfo
*/
public function __construct(
private readonly string $type,
private readonly FunctionLikeStorage $function_storage,
private functionLikeStorage $function_storage,
private readonly ?ClassLikeStorage $class_storage = null,
) {
}
Expand Down
8 changes: 4 additions & 4 deletions src/Psalm/Internal/DataFlow/Path.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ final class Path
* @param ?array<string> $escaped_taints
*/
public function __construct(
public string $type,
public int $length,
public ?array $unescaped_taints = null,
public ?array $escaped_taints = null,
public readonly string $type,
public readonly int $length,
public readonly ?array $unescaped_taints = null,
public readonly ?array $escaped_taints = null,
) {
}
}
6 changes: 3 additions & 3 deletions src/Psalm/Internal/Diff/DiffElem.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ final class DiffElem

public function __construct(
/** @var int One of the TYPE_* constants */
public int $type,
public readonly int $type,
/** @var mixed Is null for add operations */
public mixed $old,
public readonly mixed $old,
/** @var mixed Is null for remove operations */
public mixed $new,
public readonly mixed $new,
) {
}
}
10 changes: 5 additions & 5 deletions src/Psalm/Internal/FileManipulation/CodeMigration.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ final class CodeMigration
use ImmutableNonCloneableTrait;

public function __construct(
public string $source_file_path,
public int $source_start,
public int $source_end,
public string $destination_file_path,
public int $destination_start,
public readonly string $source_file_path,
public readonly int $source_start,
public readonly int $source_end,
public readonly string $destination_file_path,
public readonly int $destination_start,
) {
}
}
2 changes: 1 addition & 1 deletion src/Psalm/Internal/Fork/ForkProcessDoneMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ final class ForkProcessDoneMessage implements ForkMessage
{
use ImmutableNonCloneableTrait;

public function __construct(public mixed $data)
public function __construct(public readonly mixed $data)
{
}
}
2 changes: 1 addition & 1 deletion src/Psalm/Internal/Fork/ForkProcessErrorMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ final class ForkProcessErrorMessage implements ForkMessage
{
use ImmutableNonCloneableTrait;

public function __construct(public string $message)
public function __construct(public readonly string $message)
{
}
}
2 changes: 1 addition & 1 deletion src/Psalm/Internal/Fork/ForkTaskDoneMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ final class ForkTaskDoneMessage implements ForkMessage
{
use ImmutableNonCloneableTrait;

public function __construct(public mixed $data)
public function __construct(public readonly mixed $data)
{
}
}
2 changes: 1 addition & 1 deletion src/Psalm/Internal/MethodIdentifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ final class MethodIdentifier implements Stringable
/**
* @param lowercase-string $method_name
*/
public function __construct(public string $fq_class_name, public string $method_name)
public function __construct(public readonly string $fq_class_name, public readonly string $method_name)
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
final class ArrayOffsetFetch extends UnresolvedConstantComponent
{
public function __construct(public UnresolvedConstantComponent $array, public UnresolvedConstantComponent $offset)
public function __construct(public readonly UnresolvedConstantComponent $array, public readonly UnresolvedConstantComponent $offset)
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
final class ArraySpread extends UnresolvedConstantComponent
{
public function __construct(public UnresolvedConstantComponent $array)
public function __construct(public readonly UnresolvedConstantComponent $array)
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
final class ArrayValue extends UnresolvedConstantComponent
{
/** @param list<KeyValuePair|ArraySpread> $entries */
public function __construct(public array $entries)
public function __construct(public readonly array $entries)
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
final class ClassConstant extends UnresolvedConstantComponent
{
public function __construct(public string $fqcln, public string $name)
public function __construct(public readonly string $fqcln, public readonly string $name)
{
}
}
2 changes: 1 addition & 1 deletion src/Psalm/Internal/Scanner/UnresolvedConstant/Constant.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
final class Constant extends UnresolvedConstantComponent
{
public function __construct(public string $name, public bool $is_fully_qualified)
public function __construct(public readonly string $name, public readonly bool $is_fully_qualified)
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
abstract class EnumPropertyFetch extends UnresolvedConstantComponent
{
public function __construct(public string $fqcln, public string $case)
public function __construct(public readonly string $fqcln, public readonly string $case)
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
final class KeyValuePair extends UnresolvedConstantComponent
{
public function __construct(public ?UnresolvedConstantComponent $key, public UnresolvedConstantComponent $value)
public function __construct(public readonly ?UnresolvedConstantComponent $key, public readonly UnresolvedConstantComponent $value)
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
final class ScalarValue extends UnresolvedConstantComponent
{
public function __construct(public string|int|float|bool|null $value)
public function __construct(public readonly string|int|float|bool|null $value)
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ abstract class UnresolvedBinaryOp extends UnresolvedConstantComponent
{
use ImmutableNonCloneableTrait;

public function __construct(public UnresolvedConstantComponent $left, public UnresolvedConstantComponent $right)
public function __construct(public readonly UnresolvedConstantComponent $left, public readonly UnresolvedConstantComponent $right)
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ final class UnresolvedTernary extends UnresolvedConstantComponent
use ImmutableNonCloneableTrait;

public function __construct(
public UnresolvedConstantComponent $cond,
public ?UnresolvedConstantComponent $if,
public UnresolvedConstantComponent $else,
public readonly UnresolvedConstantComponent $cond,
public readonly ?UnresolvedConstantComponent $if,
public readonly UnresolvedConstantComponent $else,
) {
}
}
2 changes: 1 addition & 1 deletion src/Psalm/Internal/Type/TypeAlias/InlineTypeAlias.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ final class InlineTypeAlias implements TypeAlias
/**
* @param list<array{0: string, 1: int, 2?: string}> $replacement_tokens
*/
public function __construct(public array $replacement_tokens)
public function __construct(public readonly array $replacement_tokens)
{
}
}
10 changes: 5 additions & 5 deletions src/Psalm/Internal/Type/TypeAlias/LinkableTypeAlias.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ final class LinkableTypeAlias implements TypeAlias
use ImmutableNonCloneableTrait;

public function __construct(
public string $declaring_fq_classlike_name,
public string $alias_name,
public int $line_number,
public int $start_offset,
public int $end_offset,
public readonly string $declaring_fq_classlike_name,
public readonly string $alias_name,
public readonly int $line_number,
public readonly int $start_offset,
public readonly int $end_offset,
) {
}
}
2 changes: 1 addition & 1 deletion src/Psalm/Storage/Assertion/HasArrayKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
final class HasArrayKey extends Assertion
{
public function __construct(public readonly readonly string $key)
public function __construct(public readonly string $key)
{
}

Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Storage/Assertion/IsNotCountable.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
final class IsNotCountable extends Assertion
{
public function __construct(public readonly readonly bool $is_negatable)
public function __construct(public readonly bool $is_negatable)
{
}

Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Storage/Assertion/NonEmptyCountable.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
final class NonEmptyCountable extends Assertion
{
public function __construct(public readonly readonly bool $is_negatable)
public function __construct(public readonly bool $is_negatable)
{
}

Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Storage/Assertion/NotInArray.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
final class NotInArray extends Assertion
{
public function __construct(
public readonly readonly Union $type,
public readonly Union $type,
) {
}

Expand Down
6 changes: 3 additions & 3 deletions src/Psalm/Storage/AttributeArg.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ final class AttributeArg
use ImmutableNonCloneableTrait;

public function __construct(
public ?string $name,
public Union|UnresolvedConstantComponent $type,
public CodeLocation $location,
public readonly ?string $name,
public readonly Union|UnresolvedConstantComponent $type,
public readonly CodeLocation $location,
) {
}
}
8 changes: 4 additions & 4 deletions src/Psalm/Storage/AttributeStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ final class AttributeStorage
* @param list<AttributeArg> $args
*/
public function __construct(
public string $fq_class_name,
public array $args,
public CodeLocation $location,
public CodeLocation $name_location,
public readonly string $fq_class_name,
public readonly array $args,
public readonly CodeLocation $location,
public readonly CodeLocation $name_location,
) {
}
}
20 changes: 10 additions & 10 deletions src/Psalm/Storage/ClassConstantStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,16 @@ public function __construct(
* The type inferred from the value.
*/
public ?Union $inferred_type,
public int $visibility,
public ?CodeLocation $location,
public ?CodeLocation $type_location = null,
public ?CodeLocation $stmt_location = null,
public bool $deprecated = false,
public bool $final = false,
public ?UnresolvedConstantComponent $unresolved_node = null,
public array $attributes = [],
public array $suppressed_issues = [],
public ?string $description = null,
public readonly int $visibility,
public readonly ?CodeLocation $location,
public readonly ?CodeLocation $type_location = null,
public readonly ?CodeLocation $stmt_location = null,
public readonly bool $deprecated = false,
public readonly bool $final = false,
public readonly ?UnresolvedConstantComponent $unresolved_node = null,
public readonly array $attributes = [],
public readonly array $suppressed_issues = [],
public readonly ?string $description = null,
) {
}

Expand Down

0 comments on commit f1d7843

Please sign in to comment.