Skip to content

Commit

Permalink
Update phpstan.neon and FinderRepository.
Browse files Browse the repository at this point in the history
  • Loading branch information
terabytesoftw committed Dec 8, 2023
1 parent d1d9b65 commit c8c7ee4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
5 changes: 1 addition & 4 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
includes:
- vendor/yii2-extensions/phpstan/extension.neon

parameters:
dynamicConstantNames:
- YII_DEBUG
- YII_ENV
- YII_ENV_DEV
- YII_ENV_PROD
- YII_ENV_TEST

level: 5

Expand Down
4 changes: 2 additions & 2 deletions src/Repository/FinderRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ public function findAll(ActiveRecordInterface $ar): array
return $ar->find()->all();
}

public function findById(ActiveRecordInterface $ar, int $id, string $key = 'id'): ActiveRecordInterface|array|null
public function findById(ActiveRecordInterface $ar, int $id, string $key = 'id'): ActiveRecordInterface|null
{
return $this->findByOneCondition($ar, [$key => $id]);
}

public function findByOneCondition(ActiveRecordInterface $ar, array $condition): ActiveRecordInterface|array|null
public function findByOneCondition(ActiveRecordInterface $ar, array $condition): ActiveRecordInterface|null
{
return $ar->findOne($condition);
}
Expand Down
8 changes: 4 additions & 4 deletions src/Repository/FinderRepositoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,19 @@ public function findAll(ActiveRecordInterface $ar): array;
* @param int $id The primary key value.
* @param string $key The name of the primary key attribute (default is 'id').
*
* @return ActiveRecordInterface|array|null The found record, or null if not found.
* @return ActiveRecordInterface|null The found record, or null if not found.
*/
public function findById(ActiveRecordInterface $ar, int $id, string $key = 'id'): ActiveRecordInterface|array|null;
public function findById(ActiveRecordInterface $ar, int $id, string $key = 'id'): ActiveRecordInterface|null;

/**
* Find a single record by a specific condition.
*
* @param ActiveRecordInterface $ar The ActiveRecord model class.
* @param array $condition The condition to search by.
*
* @return ActiveRecordInterface|array|null The found record, or null if not found.
* @return ActiveRecordInterface|null The found record, or null if not found.
*/
public function findByOneCondition(ActiveRecordInterface $ar, array $condition): ActiveRecordInterface|array|null;
public function findByOneCondition(ActiveRecordInterface $ar, array $condition): ActiveRecordInterface|null;

/**
* Find records that match a set of conditions.
Expand Down

0 comments on commit c8c7ee4

Please sign in to comment.