PHP code example of oro / phpstan-rules

1. Go to this page and download the library: Download oro/phpstan-rules library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

oro / phpstan-rules example snippets


    $queryBuilder->andWhere($queryBuilder->expr()->eq($field, ':parameter'));
    

    QueryBuilderUtil::checkField($field);
    $queryBuilder->andWhere($queryBuilder->expr()->eq($field, ':parameter'));
    

    $queryBuilder->andWhere($queryBuilder->expr()->eq($alias . '.' . $field, ':parameter'));
    

    $queryBuilder->andWhere($queryBuilder->expr()->eq(sprintf('%s.%s', $alias, $field), ':parameter'));
    

    $queryBuilder->andWhere($queryBuilder->expr()->eq(QueryBuilderUtil::getField($alias, $field), ':parameter'));
    

    QueryBuilderUtil::checkIdentifier($alias);
    QueryBuilderUtil::checkIdentifier($field);
    $queryBuilder->andWhere($queryBuilder->expr()->eq($alias . '.' . $field, ':parameter'));
    

    $queryBuilder->andWhere($queryBuilder->expr()->eq(QueryBuilderUtil::sprintf('%s.%s', $alias, $field), ':parameter'));
    

    $queryBuilder->andWhere($queryBuilder->expr()->eq('table.id', $paramer));
    

    QueryBuilderUtil::checkParameter($paramer);
    $queryBuilder->andWhere($queryBuilder->expr()->eq('table.id', $paramer));
    

    $queryBuilder->orderBy('table.field', $sortOrder);
    

    $queryBuilder->orderBy('table.field', QueryBuilderUtil::getSortOrder($sortOrder));
    

    $queryBuilder->select(sprintf("'%s' as className", $className));
    

     $queryBuilder->select(
       sprintf((string)$queryBuilder->expr()->literal($className) . ' as className')
     );
     

protected function addWhereToQueryBuilder(QueryBuilder $qb, string $suffix, int $index)
{
    $rootAlias = $qb->getRootAlias();
    $fieldName = $rootAlias . '.field' . $idx . $suffix;

    $qb->andWhere($qb->expr()->gt($fieldName, 10);
}