Completed
Push — master ( 8400ab...233003 )
by
unknown
02:27
created

src/Pagerfanta/Adapter/DoctrineODMPhpcrAdapter.php (2 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
/*
4
 * This file is part of the Pagerfanta package.
5
 *
6
 * (c) Pablo Díez <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Pagerfanta\Adapter;
13
14
use Doctrine\ODM\PHPCR\Query\Builder\QueryBuilder;
15
use Doctrine\ODM\PHPCR\Query\Query;
16
17
/**
18
 * Pagerfanta adapter for Doctrine PHPCR-ODM.
19
 *
20
 * @author David Buchmann <[email protected]>
21
 */
22
class DoctrineODMPhpcrAdapter implements AdapterInterface
23
{
24
    private $queryBuilder;
25
26
    /**
27
     * Constructor.
28
     *
29
     * @param QueryBuilder $queryBuilder A Doctrine PHPCR-ODM query builder.
30
     */
31 3
    public function __construct(QueryBuilder $queryBuilder)
32
    {
33 3
        $this->queryBuilder = $queryBuilder;
34 3
    }
35
36
    /**
37
     * Returns the query builder.
38
     *
39
     * @return QueryBuilder The query builder.
40
     */
41 1
    public function getQueryBuilder()
42
    {
43 1
        return $this->queryBuilder;
44
    }
45
46
    /**
47
     * {@inheritdoc}
48
     */
49 1
    public function getNbResults()
50
    {
51 1
        return $this->queryBuilder->getQuery()->execute(null, Query::HYDRATE_PHPCR)->getRows()->count();
0 ignored issues
show
The call to QueryInterface::execute() has too many arguments starting with null.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
52
    }
53
54
    /**
55
     * {@inheritdoc}
56
     */
57 1
    public function getSlice($offset, $length)
58
    {
59 1
        return $this->queryBuilder
0 ignored issues
show
The method setMaxResults() does not seem to exist on object<PHPCR\Query\QueryInterface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
60 1
            ->getQuery()
61 1
            ->setMaxResults($length)
62 1
            ->setFirstResult($offset)
63 1
            ->execute();
64
    }
65
}
66