Skip to content

Commit

Permalink
Support for PHPstan
Browse files Browse the repository at this point in the history
  • Loading branch information
Rob van Aarle committed May 13, 2024
1 parent fcec428 commit 4c79d44
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/CreatesObjectSeams.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@

trait CreatesObjectSeams
{
/**
* @template TSeamedObject
* @phpstan-param class-string<TSeamedObject> $class
* @phpstan-return ObjectSeam<TSeamedObject>
*/
public function createObjectSeam(string $class): ObjectSeam
{
$builder = new Builder($class);
Expand Down
4 changes: 4 additions & 0 deletions src/ObjectSeam.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

use PHPObjectSeam\ObjectSeam\Seam;

/**
* @template TSeamedObject of object
* @mixin TSeamedObject
*/
interface ObjectSeam
{
public function seam(): Seam;
Expand Down
15 changes: 15 additions & 0 deletions src/ObjectSeam/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,18 @@

class Builder
{
/**
* @template TSeamedObject
*
* @phpstan-var class-string<TSeamedObject> $class
*/
protected $class;

/**
* @template TSeamedObject
*
* @phpstan-param class-string<TSeamedObject> $class
*/
public function __construct(string $class)
{
$this->class = $class;
Expand All @@ -22,6 +32,11 @@ public function buildObjectSeamClass(): string
return $seamClass;
}

/**
* @template TSeamedObject
* @phpstan-param class-string<TSeamedObject> $class
* @phpstan-return ObjectSeam<TSeamedObject>
*/
public function build(): ObjectSeam
{
$seamClass = $this->buildObjectSeamClass();
Expand Down

0 comments on commit 4c79d44

Please sign in to comment.