Issues (590)

bench/Query/QueryWrapAsBench.php (4 issues)

Labels
1
<?php
2
3
namespace Bdf\Prime\Query;
4
5
require_once __DIR__ . '/../_files/BenchData.php';
6
7
use Bdf\Prime\Bench\BenchData;
8
use Bdf\Prime\Bench\User;
9
use Bdf\Prime\Cache\ArrayCache;
10
use Bdf\Prime\Connection\ConnectionConfig;
0 ignored issues
show
The type Bdf\Prime\Connection\ConnectionConfig was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
use Bdf\Prime\ConnectionManager;
12
use Bdf\Prime\Locatorizable;
13
use Bdf\Prime\Repository\EntityRepository;
14
use Bdf\Prime\ServiceLocator;
15
use Bdf\Prime\Types\ArrayType;
16
use BenchCaseAdapter;
17
18
/**
19
 * Bench wrap as results
20
 *
21
 * @Revs(10)
22
 * @Iterations(5)
23
 */
24
class QueryWrapAsBench extends BenchCaseAdapter
25
{
26
    /**
27
     * @var ServiceLocator
28
     */
29
    protected $prime;
30
31
    /**
32
     * @var BenchData
33
     */
34
    protected $data;
35
36
    /**
37
     * @var ArrayCache
38
     */
39
    protected $cache;
40
41
    /**
42
     * @var EntityRepository
43
     */
44
    protected $repository;
45
46
47
48
    public function setUp()
49
    {
50
        $this->cache = new ArrayCache();
51
        $this->prime = new ServiceLocator();
52
        $this->prime->connections()->declareConnection('test', BENCH_CONNECTION);
53
        $this->prime->connection('test')->getConfiguration()->getTypes()->register(ArrayType::class, 'array');
0 ignored issues
show
The method getConfiguration() does not exist on Bdf\Prime\Connection\ConnectionInterface. Since it exists in all sub-types, consider adding an abstract or default implementation to Bdf\Prime\Connection\ConnectionInterface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

53
        $this->prime->connection('test')->/** @scrutinizer ignore-call */ getConfiguration()->getTypes()->register(ArrayType::class, 'array');
Loading history...
54
        Locatorizable::configure($this->prime);
0 ignored issues
show
$this->prime of type Bdf\Prime\ServiceLocator is incompatible with the type Closure expected by parameter $locator of Bdf\Prime\Locatorizable::configure(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

54
        Locatorizable::configure(/** @scrutinizer ignore-type */ $this->prime);
Loading history...
55
56
        $this->data = new BenchData($this->prime);
57
        $this->data->addAllData();
58
59
        $this->repository = $this->prime->repository(User::class);
60
    }
61
62
    /**
63
     * {@inheritdoc}
64
     */
65
    public function tearDown()
66
    {
67
        $this->data->clear();
68
    }
69
70
71
    /**
72
     *
73
     */
74
    public function bench_no_wrap()
75
    {
76
        $this->repository->all();
0 ignored issues
show
The method all() does not exist on Bdf\Prime\Repository\EntityRepository. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

76
        $this->repository->/** @scrutinizer ignore-call */ 
77
                           all();
Loading history...
77
    }
78
79
    /**
80
     *
81
     */
82
    public function bench_wrapAs_collection()
83
    {
84
        $this->repository->wrapAs('collection')->all();
85
    }
86
87
    /**
88
     *
89
     */
90
    public function bench_wrapAs_array()
91
    {
92
        $this->repository->wrapAs('array')->all();
93
    }
94
}
95