Skip to content

Commit

Permalink
Fix type doc blocks in annotation classes
Browse files Browse the repository at this point in the history
  • Loading branch information
derrabus committed Oct 17, 2022
1 parent 7e75807 commit fb96b36
Show file tree
Hide file tree
Showing 30 changed files with 395 additions and 217 deletions.
18 changes: 13 additions & 5 deletions lib/Doctrine/ORM/Mapping/AssociationOverride.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,48 +17,56 @@ final class AssociationOverride implements Annotation
* The name of the relationship property whose mapping is being overridden.
*
* @var string
* @readonly
*/
public $name;

/**
* The join column that is being mapped to the persistent attribute.
*
* @var array<\Doctrine\ORM\Mapping\JoinColumn>|null
* @var array<JoinColumn>|null
* @readonly
*/
public $joinColumns;

/**
* The join column that is being mapped to the persistent attribute.
*
* @var array<\Doctrine\ORM\Mapping\JoinColumn>|null
* @var array<JoinColumn>|null
* @readonly
*/
public $inverseJoinColumns;

/**
* The join table that maps the relationship.
*
* @var \Doctrine\ORM\Mapping\JoinTable|null
* @var JoinTable|null
* @readonly
*/
public $joinTable;

/**
* The name of the association-field on the inverse-side.
*
* @var ?string
* @var string|null
* @readonly
*/
public $inversedBy;

/**
* The fetching strategy to use for the association.
*
* @var ?string
* @var string|null
* @psalm-var 'LAZY'|'EAGER'|'EXTRA_LAZY'|null
* @readonly
* @Enum({"LAZY", "EAGER", "EXTRA_LAZY"})
*/
public $fetch;

/**
* @param JoinColumn|array<JoinColumn> $joinColumns
* @param JoinColumn|array<JoinColumn> $inverseJoinColumns
* @psalm-param 'LAZY'|'EAGER'|'EXTRA_LAZY'|null $fetch
*/
public function __construct(
string $name,
Expand Down
8 changes: 5 additions & 3 deletions lib/Doctrine/ORM/Mapping/AssociationOverrides.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Attribute;

use function array_values;
use function is_array;

/**
Expand All @@ -21,7 +22,8 @@ final class AssociationOverrides implements Annotation
/**
* Mapping overrides of relationship properties.
*
* @var array<AssociationOverride>
* @var list<AssociationOverride>
* @readonly
*/
public $overrides = [];

Expand All @@ -36,8 +38,8 @@ public function __construct($overrides)
if (! ($override instanceof AssociationOverride)) {
throw MappingException::invalidOverrideType('AssociationOverride', $override);
}

$this->overrides[] = $override;
}

$this->overrides = array_values($overrides);
}
}
4 changes: 3 additions & 1 deletion lib/Doctrine/ORM/Mapping/AttributeOverride.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ final class AttributeOverride implements Annotation
* The name of the property whose mapping is being overridden.
*
* @var string
* @readonly
*/
public $name;

/**
* The column definition.
*
* @var \Doctrine\ORM\Mapping\Column
* @var Column
* @readonly
*/
public $column;

Expand Down
8 changes: 5 additions & 3 deletions lib/Doctrine/ORM/Mapping/AttributeOverrides.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Attribute;

use function array_values;
use function is_array;

/**
Expand All @@ -21,7 +22,8 @@ final class AttributeOverrides implements Annotation
/**
* One or more field or property mapping overrides.
*
* @var array<AttributeOverride>
* @var list<AttributeOverride>
* @readonly
*/
public $overrides = [];

Expand All @@ -36,8 +38,8 @@ public function __construct($overrides)
if (! ($override instanceof AttributeOverride)) {
throw MappingException::invalidOverrideType('AttributeOverride', $override);
}

$this->overrides[] = $override;
}

$this->overrides = array_values($overrides);
}
}
6 changes: 5 additions & 1 deletion lib/Doctrine/ORM/Mapping/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,18 @@
final class Cache implements Annotation
{
/**
* The concurrency strategy.
*
* @Enum({"READ_ONLY", "NONSTRICT_READ_WRITE", "READ_WRITE"})
* @var string The concurrency strategy.
* @var string
* @psalm-var 'READ_ONLY'|'NONSTRICT_READ_WRITE'|'READ_WRITE'
*/
public $usage = 'READ_ONLY';

/** @var string|null Cache region name. */
public $region;

/** @psalm-param 'READ_ONLY'|'NONSTRICT_READ_WRITE'|'READ_WRITE' $usage */
public function __construct(string $usage = 'READ_ONLY', ?string $region = null)
{
$this->usage = $usage;
Expand Down
3 changes: 3 additions & 0 deletions lib/Doctrine/ORM/Mapping/ChangeTrackingPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@ final class ChangeTrackingPolicy implements Annotation
* The change tracking policy.
*
* @var string
* @psalm-var 'DEFERRED_IMPLICIT'|'DEFERRED_EXPLICIT'|'NOTIFY'
* @readonly
* @Enum({"DEFERRED_IMPLICIT", "DEFERRED_EXPLICIT", "NOTIFY"})
*/
public $value;

/** @psalm-param 'DEFERRED_IMPLICIT'|'DEFERRED_EXPLICIT'|'NOTIFY' $value */
public function __construct(string $value)
{
$this->value = $value;
Expand Down
60 changes: 47 additions & 13 deletions lib/Doctrine/ORM/Mapping/Column.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,70 +5,104 @@
namespace Doctrine\ORM\Mapping;

use Attribute;
use BackedEnum;
use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;

/**
* @Annotation
* @NamedArgumentConstructor()
* @NamedArgumentConstructor
* @Target({"PROPERTY","ANNOTATION"})
*/
#[Attribute(Attribute::TARGET_PROPERTY)]
final class Column implements Annotation
{
/** @var string|null */
/**
* @var string|null
* @readonly
*/
public $name;

/** @var mixed */
/**
* @var mixed
* @readonly
*/
public $type;

/** @var int|null */
/**
* @var int|null
* @readonly
*/
public $length;

/**
* The precision for a decimal (exact numeric) column (Applies only for decimal column).
*
* @var int|null
* @readonly
*/
public $precision = 0;

/**
* The scale for a decimal (exact numeric) column (Applies only for decimal column).
*
* @var int|null
* @readonly
*/
public $scale = 0;

/** @var bool */
/**
* @var bool
* @readonly
*/
public $unique = false;

/** @var bool */
/**
* @var bool
* @readonly
*/
public $nullable = false;

/** @var bool */
/**
* @var bool
* @readonly
*/
public $insertable = true;

/** @var bool */
/**
* @var bool
* @readonly
*/
public $updatable = true;

/** @var class-string<\BackedEnum>|null */
/**
* @var class-string<BackedEnum>|null
* @readonly
*/
public $enumType = null;

/** @var array<string,mixed> */
/**
* @var array<string,mixed>
* @readonly
*/
public $options = [];

/** @var string|null */
/**
* @var string|null
* @readonly
*/
public $columnDefinition;

/**
* @var string|null
* @readonly
* @psalm-var 'NEVER'|'INSERT'|'ALWAYS'|null
* @Enum({"NEVER", "INSERT", "ALWAYS"})
*/
public $generated;

/**
* @param class-string<\BackedEnum>|null $enumType
* @param array<string,mixed> $options
* @param class-string<BackedEnum>|null $enumType
* @param array<string,mixed> $options
* @psalm-param 'NEVER'|'INSERT'|'ALWAYS'|null $generated
*/
public function __construct(
Expand Down
5 changes: 4 additions & 1 deletion lib/Doctrine/ORM/Mapping/CustomIdGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
#[Attribute(Attribute::TARGET_PROPERTY)]
final class CustomIdGenerator implements Annotation
{
/** @var string|null */
/**
* @var string|null
* @readonly
*/
public $class;

public function __construct(?string $class = null)
Expand Down
23 changes: 14 additions & 9 deletions lib/Doctrine/ORM/Mapping/DiscriminatorColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,28 @@
#[Attribute(Attribute::TARGET_CLASS)]
final class DiscriminatorColumn implements Annotation
{
/** @var string|null */
/**
* @var string|null
* @readonly
*/
public $name;

/** @var string|null */
/**
* @var string|null
* @readonly
*/
public $type;

/** @var int|null */
/**
* @var int|null
* @readonly
*/
public $length;

/**
* Field name used in non-object hydration (array/scalar).
*
* @var mixed
* @var string|null
* @readonly
*/
public $fieldName;

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

public function __construct(
Expand Down
5 changes: 4 additions & 1 deletion lib/Doctrine/ORM/Mapping/DiscriminatorMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
#[Attribute(Attribute::TARGET_CLASS)]
final class DiscriminatorMap implements Annotation
{
/** @var array<int|string, string> */
/**
* @var array<int|string, string>
* @readonly
*/
public $value;

/** @param array<int|string, string> $value */
Expand Down
10 changes: 8 additions & 2 deletions lib/Doctrine/ORM/Mapping/Embedded.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,16 @@
#[Attribute(Attribute::TARGET_PROPERTY)]
final class Embedded implements Annotation
{
/** @var string|null */
/**
* @var string|null
* @readonly
*/
public $class;

/** @var string|bool|null */
/**
* @var string|bool|null
* @readonly
*/
public $columnPrefix;

public function __construct(?string $class = null, $columnPrefix = null)
Expand Down
6 changes: 5 additions & 1 deletion lib/Doctrine/ORM/Mapping/Entity.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,14 @@ final class Entity implements Annotation
/**
* @var string|null
* @psalm-var class-string<EntityRepository<T>>|null
* @readonly
*/
public $repositoryClass;

/** @var bool */
/**
* @var bool
* @readonly
*/
public $readOnly = false;

/** @psalm-param class-string<EntityRepository<T>>|null $repositoryClass */
Expand Down
1 change: 1 addition & 0 deletions lib/Doctrine/ORM/Mapping/EntityListeners.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ final class EntityListeners implements Annotation
* Specifies the names of the entity listeners.
*
* @var array<string>
* @readonly
*/
public $value = [];

Expand Down
Loading

0 comments on commit fb96b36

Please sign in to comment.