Skip to content

Commit

Permalink
[TASK] Fix a last phpstan error on this level
Browse files Browse the repository at this point in the history
This is actually most likely a phpstan bug.
We add an @var hint to circumvent.
  • Loading branch information
lolli42 committed Oct 30, 2023
1 parent 982f6c0 commit e8e8cac
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 19 deletions.
7 changes: 1 addition & 6 deletions Build/phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -1,7 +1,2 @@
parameters:
ignoreErrors:
-
message: "#^Offset 0 does not exist on array\\{\\}\\.$#"
count: 1
path: ../Classes/TcaDataGenerator/Generator.php

ignoreErrors: []
2 changes: 1 addition & 1 deletion Build/testing-docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ services:
fi
mkdir -p .Build/.cache
php -v | grep '^PHP';
php -dxdebug.mode=off .Build/bin/phpstan analyze -c Build/phpstan.neon --no-progress --no-interaction --generate-baseline=Build/phpstan-baseline.neon
php -dxdebug.mode=off .Build/bin/phpstan analyze -c Build/phpstan.neon --no-progress --no-interaction --allow-empty-baseline --generate-baseline=Build/phpstan-baseline.neon
"
unit:
Expand Down
5 changes: 4 additions & 1 deletion Classes/TcaDataGenerator/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,10 @@ public function create(): void
$this->executeDataHandler($data);

// Create a site configuration on root page
$topPageUid = $recordFinder->findUidsOfStyleguideEntryPages()[0];
/** @var non-empty-array $topPageUidList */
$topPageUidList = $recordFinder->findUidsOfStyleguideEntryPages();
$topPageUid = $topPageUidList[0];

$this->createSiteConfiguration($topPageUid);

// Create data for each main table
Expand Down
17 changes: 6 additions & 11 deletions Classes/TcaDataGenerator/RecordFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,12 @@ class RecordFinder
* Returns a uid list of existing styleguide demo top level pages.
* These are pages with pid=0 and tx_styleguide_containsdemo set to 'tx_styleguide'.
* This can be multiple pages if "create" button was clicked multiple times without "delete" in between.
*
* @return array
*/
public function findUidsOfStyleguideEntryPages(): array
{
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages');
$queryBuilder->getRestrictions()->removeAll()->add(GeneralUtility::makeInstance(DeletedRestriction::class));
$rows = $queryBuilder->select('uid')
$result = $queryBuilder->select('uid')
->from('pages')
->where(
$queryBuilder->expr()->eq(
Expand All @@ -56,15 +54,12 @@ public function findUidsOfStyleguideEntryPages(): array
$queryBuilder->createNamedParameter('tx_styleguide', \PDO::PARAM_STR)
)
)
->executeQuery()
->fetchAllAssociative();
$uids = [];
if (is_array($rows)) {
foreach ($rows as $row) {
$uids[] = (int)$row['uid'];
}
->executeQuery();
$uidList = [];
while ($row = $result->fetchAssociative()) {
$uidList[] = (int)$row['uid'];
}
return $uids;
return $uidList;
}

/**
Expand Down

0 comments on commit e8e8cac

Please sign in to comment.