# ReceiverPropertyReflection

> Wraps an inherited PHPStan\Reflection\PropertyReflection so that it's declared by the class it was resolved on.

[API reference](/docs/api/index.md) › [PHPStan](/docs/extensions/phpstan/reference/index.md) › [reflection](/docs/extensions/phpstan/reference/reflection/index.md) › ReceiverPropertyReflection

| final class | `yii2\extensions\phpstan\reflection\ReceiverPropertyReflection` |
| --- | --- |
| Implements | [`PropertyReflection`](https://apiref.phpstan.org/2.3.x/PHPStan.Reflection.PropertyReflection.html) |
| Source | [`src/reflection/ReceiverPropertyReflection.php`](https://github.com/yii2-extensions/phpstan/blob/main/src/reflection/ReceiverPropertyReflection.php#L21) |

Wraps an inherited [`PropertyReflection`](https://apiref.phpstan.org/2.3.x/PHPStan.Reflection.PropertyReflection.html) so that it's declared by the class it was resolved on.

PHPStan resolves a property again on the ancestor that declares it. An application class unrelated to the configured
application type inherits annotations from [`Application`](/docs/api/yii/base/application/index.md), which is refined to the configured type, so
declaring the property on the receiver keeps the configured components from replacing its own annotated type.
Delegates every other aspect of the property to the wrapped instance.

[`PropertyReflection`](https://apiref.phpstan.org/2.3.x/PHPStan.Reflection.PropertyReflection.html) for property reflection contract.

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`__construct()`](#method-__construct) | Creates a new instance of the [`ReceiverPropertyReflection`](/docs/extensions/phpstan/reference/reflection/receiverpropertyreflection/index.md) class. | `ReceiverPropertyReflection` |
| [`canChangeTypeAfterAssignment()`](#method-canChangeTypeAfterAssignment) | Determines whether the type of the property can change after assignment. | `ReceiverPropertyReflection` |
| [`getDeclaringClass()`](#method-getDeclaringClass) | Retrieves the receiver class reflection the property was resolved on. | `ReceiverPropertyReflection` |
| [`getDeprecatedDescription()`](#method-getDeprecatedDescription) | Retrieves the deprecation description of the property, if available. | `ReceiverPropertyReflection` |
| [`getDocComment()`](#method-getDocComment) | Retrieves the PHPDoc comment of the property, if available. | `ReceiverPropertyReflection` |
| [`getReadableType()`](#method-getReadableType) | Retrieves the type that can be read from the property. | `ReceiverPropertyReflection` |
| [`getWritableType()`](#method-getWritableType) | Retrieves the type that can be written to the property. | `ReceiverPropertyReflection` |
| [`isDeprecated()`](#method-isDeprecated) | Determines whether the property is deprecated. | `ReceiverPropertyReflection` |
| [`isInternal()`](#method-isInternal) | Determines whether the property is internal to the library or framework. | `ReceiverPropertyReflection` |
| [`isPrivate()`](#method-isPrivate) | Determines whether the property is private. | `ReceiverPropertyReflection` |
| [`isPublic()`](#method-isPublic) | Determines whether the property is public. | `ReceiverPropertyReflection` |
| [`isReadable()`](#method-isReadable) | Determines whether the property is readable. | `ReceiverPropertyReflection` |
| [`isStatic()`](#method-isStatic) | Determines whether the property is static. | `ReceiverPropertyReflection` |
| [`isWritable()`](#method-isWritable) | Determines whether the property is writable. | `ReceiverPropertyReflection` |

## Method details

### __construct() <span id="method-__construct"></span>

```php
public function __construct(PHPStan\Reflection\PropertyReflection $property, PHPStan\Reflection\ClassReflection $declaringClass)
```

Creates a new instance of the [`ReceiverPropertyReflection`](/docs/extensions/phpstan/reference/reflection/receiverpropertyreflection/index.md) class.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$property` | [`PropertyReflection`](https://apiref.phpstan.org/2.3.x/PHPStan.Reflection.PropertyReflection.html) | Inherited property reflection instance for delegation. |
| `$declaringClass` | `PHPStan\Reflection\ClassReflection` | Class reflection of the receiver the property was resolved on. |

### canChangeTypeAfterAssignment() <span id="method-canChangeTypeAfterAssignment"></span>

```php
public function canChangeTypeAfterAssignment(): bool
```

Determines whether the type of the property can change after assignment.

**Returns**

`bool`: `true` if the property type can change after assignment; `false` otherwise.

### getDeclaringClass() <span id="method-getDeclaringClass"></span>

```php
public function getDeclaringClass(): PHPStan\Reflection\ClassReflection
```

Retrieves the receiver class reflection the property was resolved on.

**Returns**

`PHPStan\Reflection\ClassReflection`: Declaring class reflection instance for the property.

### getDeprecatedDescription() <span id="method-getDeprecatedDescription"></span>

```php
public function getDeprecatedDescription(): string|null
```

Retrieves the deprecation description of the property, if available.

**Returns**

`string|null`: Deprecation description if available, or `null` if not deprecated or no description is set.

### getDocComment() <span id="method-getDocComment"></span>

```php
public function getDocComment(): string|null
```

Retrieves the PHPDoc comment of the property, if available.

**Returns**

`string|null`: PHPDoc comment string for the property, or `null` if no comment is set.

### getReadableType() <span id="method-getReadableType"></span>

```php
public function getReadableType(): PHPStan\Type\Type
```

Retrieves the type that can be read from the property.

**Returns**

`PHPStan\Type\Type`: Type that can be read from the property for static analysis.

### getWritableType() <span id="method-getWritableType"></span>

```php
public function getWritableType(): PHPStan\Type\Type
```

Retrieves the type that can be written to the property.

**Returns**

`PHPStan\Type\Type`: Type that can be written to the property for static analysis.

### isDeprecated() <span id="method-isDeprecated"></span>

```php
public function isDeprecated(): PHPStan\TrinaryLogic
```

Determines whether the property is deprecated.

**Returns**

[`TrinaryLogic`](https://apiref.phpstan.org/2.3.x/PHPStan.TrinaryLogic.html): Deprecation status of the property as a [`TrinaryLogic`](https://apiref.phpstan.org/2.3.x/PHPStan.TrinaryLogic.html) value.

### isInternal() <span id="method-isInternal"></span>

```php
public function isInternal(): PHPStan\TrinaryLogic
```

Determines whether the property is internal to the library or framework.

**Returns**

[`TrinaryLogic`](https://apiref.phpstan.org/2.3.x/PHPStan.TrinaryLogic.html): Internal status of the property as a [`TrinaryLogic`](https://apiref.phpstan.org/2.3.x/PHPStan.TrinaryLogic.html) value.

### isPrivate() <span id="method-isPrivate"></span>

```php
public function isPrivate(): bool
```

Determines whether the property is private.

**Returns**

`bool`: `true` if the property is private; `false` otherwise.

### isPublic() <span id="method-isPublic"></span>

```php
public function isPublic(): bool
```

Determines whether the property is public.

**Returns**

`bool`: `true` if the property is public; `false` otherwise.

### isReadable() <span id="method-isReadable"></span>

```php
public function isReadable(): bool
```

Determines whether the property is readable.

**Returns**

`bool`: `true` if the property is readable; `false` otherwise.

### isStatic() <span id="method-isStatic"></span>

```php
public function isStatic(): bool
```

Determines whether the property is static.

**Returns**

`bool`: `true` if the property is static; `false` otherwise.

### isWritable() <span id="method-isWritable"></span>

```php
public function isWritable(): bool
```

Determines whether the property is writable.

**Returns**

`bool`: `true` if the property is writable; `false` otherwise.