Skip to content

Commit

Permalink
phpstan fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
markhuot committed Feb 17, 2024
1 parent 77f7af7 commit 84e0132
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ jobs:

- name: Run pint
run: ./vendor/bin/pint --test -vvv src/
if: success() || failure()

- name: Run test suite
run: ./vendor/bin/pest --compact -vvv
if: success() || failure()
1 change: 1 addition & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ parameters:
excludePaths:
- src/craft/*
- src/illuminate/*
- src/actions/RenderCompiledClasses.php
4 changes: 2 additions & 2 deletions src/Pest.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ function (DefineBehaviorsEvent $event) {

Craft::$container->set(SectionsServiceInterface::class, function () {
return version_compare(Craft::$app->version, '5.0.0', '>=') ?
Craft::$app->getEntries() :
Craft::$app->getSections();
Craft::$app->getEntries() : // @phpstan-ignore-line
Craft::$app->getSections(); // @phpstan-ignore-line
});
}
}
16 changes: 11 additions & 5 deletions src/factories/Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace markhuot\craftpest\factories;

use Craft;
use craft\helpers\StringHelper;

/**
Expand All @@ -23,7 +24,7 @@ public function type(string $type)
public function group(string $groupName)
{
$this->attributes['groupId'] = function () use ($groupName) {
foreach (\Craft::$app->fields->getAllGroups() as $group) {
foreach (\Craft::$app->fields->getAllGroups() as $group) { //@phpstan-ignore-line
if ($group->name === $groupName) {
return $group->id;
}
Expand Down Expand Up @@ -55,12 +56,17 @@ public function newElement()
public function definition(int $index = 0)
{
$name = $this->faker->words(2, true);
// $firstFieldGroupId = \Craft::$app->fields->getAllGroups()[0]->id;

return [

$definition = [
'name' => $name,
// 'groupId' => $firstFieldGroupId,
];

if (version_compare(Craft::$app->version, '5.0.0', '<')) {
$firstFieldGroupId = \Craft::$app->fields->getAllGroups()[0]->id; // @phpstan-ignore-line
$definition['groupId'] = $firstFieldGroupId;
}

return $definition;
}

public function inferences(array $definition = [])
Expand Down

0 comments on commit 84e0132

Please sign in to comment.