Skip to content

Commit

Permalink
DEBUG stan
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed Feb 12, 2024
1 parent 711477d commit 9e8a301
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 1 deletion.
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,10 @@
"autoload": {
"psr-4": {
"Atk4\\Ui\\": "src/"
}
},
"files": [
"demos/EntityFieldPair.php"
]
},
"autoload-dev": {
"psr-4": {
Expand Down
87 changes: 87 additions & 0 deletions demos/EntityFieldPair.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<?php

declare(strict_types=1);

namespace Atk4\Data\Model;

use Atk4\Core\WarnDynamicPropertyTrait;
use Atk4\Data\Field;
use Atk4\Data\Model;
use Atk4\Ui\Demos\WrappedId;

/**
* @template-covariant TModel of Model
* @template-covariant TField of Field
*/
class EntityFieldPair
{
use WarnDynamicPropertyTrait;

/** @var TModel */
private $entity;
/** @var string */
private $fieldName;

/**
* @param ModelWithPrefixedFields $entity
*/
public function __construct(Model $entity, string $fieldName)

Check failure on line 28 in demos/EntityFieldPair.php

View workflow job for this annotation

GitHub Actions / Smoke (latest, StaticAnalysis)

PHPDoc tag @param for parameter $entity with type Atk4\Data\Model\ModelWithPrefixedFields is not subtype of native type Atk4\Data\Model.

Check failure on line 28 in demos/EntityFieldPair.php

View workflow job for this annotation

GitHub Actions / Smoke (latest, StaticAnalysis)

Parameter $entity of method Atk4\Data\Model\EntityFieldPair::__construct() has invalid type Atk4\Data\Model\ModelWithPrefixedFields.

Check failure on line 28 in demos/EntityFieldPair.php

View workflow job for this annotation

GitHub Actions / Smoke (latest, StaticAnalysis)

PHPDoc tag @param for parameter $entity with type Atk4\Data\Model\ModelWithPrefixedFields is not subtype of native type Atk4\Data\Model.

Check failure on line 28 in demos/EntityFieldPair.php

View workflow job for this annotation

GitHub Actions / Smoke (latest, StaticAnalysis)

Parameter $entity of method Atk4\Data\Model\EntityFieldPair::__construct() has invalid type Atk4\Data\Model\ModelWithPrefixedFields.
{
$entity->assertIsEntity();

$this->entity = $entity;
$this->fieldName = $fieldName;
}

/**
* @return ModelWithPrefixedFields
*/
public function getModel(): Model

Check failure on line 39 in demos/EntityFieldPair.php

View workflow job for this annotation

GitHub Actions / Smoke (latest, StaticAnalysis)

Method Atk4\Data\Model\EntityFieldPair::getModel() has invalid return type Atk4\Data\Model\ModelWithPrefixedFields.

Check failure on line 39 in demos/EntityFieldPair.php

View workflow job for this annotation

GitHub Actions / Smoke (latest, StaticAnalysis)

PHPDoc tag @return with type Atk4\Data\Model\ModelWithPrefixedFields is not subtype of native type Atk4\Data\Model.

Check failure on line 39 in demos/EntityFieldPair.php

View workflow job for this annotation

GitHub Actions / Smoke (latest, StaticAnalysis)

Method Atk4\Data\Model\EntityFieldPair::getModel() has invalid return type Atk4\Data\Model\ModelWithPrefixedFields.

Check failure on line 39 in demos/EntityFieldPair.php

View workflow job for this annotation

GitHub Actions / Smoke (latest, StaticAnalysis)

PHPDoc tag @return with type Atk4\Data\Model\ModelWithPrefixedFields is not subtype of native type Atk4\Data\Model.
{
return $this->entity->getModel();
}

/**
* @return ModelWithPrefixedFields
*/
public function getEntity(): Model

Check failure on line 47 in demos/EntityFieldPair.php

View workflow job for this annotation

GitHub Actions / Smoke (latest, StaticAnalysis)

Method Atk4\Data\Model\EntityFieldPair::getEntity() has invalid return type Atk4\Data\Model\ModelWithPrefixedFields.

Check failure on line 47 in demos/EntityFieldPair.php

View workflow job for this annotation

GitHub Actions / Smoke (latest, StaticAnalysis)

PHPDoc tag @return with type Atk4\Data\Model\ModelWithPrefixedFields is not subtype of native type Atk4\Data\Model.

Check failure on line 47 in demos/EntityFieldPair.php

View workflow job for this annotation

GitHub Actions / Smoke (latest, StaticAnalysis)

Method Atk4\Data\Model\EntityFieldPair::getEntity() has invalid return type Atk4\Data\Model\ModelWithPrefixedFields.

Check failure on line 47 in demos/EntityFieldPair.php

View workflow job for this annotation

GitHub Actions / Smoke (latest, StaticAnalysis)

PHPDoc tag @return with type Atk4\Data\Model\ModelWithPrefixedFields is not subtype of native type Atk4\Data\Model.
{
return $this->entity;
}

public function getFieldName(): string
{
return $this->fieldName;
}

/**
* @phpstan-return TField
*/
public function getField(): Field
{
$field = $this->getModel()->getField($this->getFieldName());

return $field;
}

/**
* @return WrappedId|null
*/
public function get()
{
return $this->getEntity()->get($this->getFieldName());
}

/**
* @param WrappedId $value
*/
public function set($value): void
{
$this->getEntity()->set($this->getFieldName(), $value);
}

public function setNull(): void
{
$this->getEntity()->setNull($this->getFieldName());
}
}

0 comments on commit 9e8a301

Please sign in to comment.