Search code examples
typo3phpstorm

TYPO3 queryBuilder, how to let PhpStorm recognise methods?


For example

        $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
        $queryBuilder = $connectionPool->getQueryBuilderForTable($table);

        $statement = $queryBuilder
            ->select('uid')
            ->from($table)
            ->orderBy('start_date', 'DESC')
            ->where(
                $queryBuilder->expr()->lte('start_date', $queryBuilder->createNamedParameter($startDate, \PDO::PARAM_INT)),
                $queryBuilder->expr()->neq('uid', $queryBuilder->createNamedParameter($currentUid, \PDO::PARAM_INT))
            )
            ->setMaxResults(1)
            ->execute();
        while ($row = $statement->fetch()) {
            $prevs[] = $row;
        }

How can one let PhpStorm recognise the methods select, expr, createNamedParameter, fetch etc.


Solution

  • PhpStorm doesn't automatically know what class $connectionPool is and so can't know what class everything derived from that is. You can tell PhpStorm what class $connectionPool is by adding an annotation:

    /** @var ConnectionPool $connectionPool */
    $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);