Passed
Push — dbal ( a4ab32...59fa40 )
by Greg
06:02
created

Connection::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 4
dl 0
loc 10
rs 10
1
<?php
2
3
/**
4
 * webtrees: online genealogy
5
 * Copyright (C) 2022 webtrees development team
6
 * This program is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
 * GNU General Public License for more details.
14
 * You should have received a copy of the GNU General Public License
15
 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16
 */
17
18
declare(strict_types=1);
19
20
namespace Fisharebest\Webtrees\DB;
21
22
use Doctrine\Common\EventManager;
0 ignored issues
show
Bug introduced by
The type Doctrine\Common\EventManager 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...
23
use Doctrine\DBAL\Configuration;
24
use Doctrine\DBAL\Connection as BaseConnection;
25
use Doctrine\DBAL\Driver;
26
use Doctrine\DBAL\Schema\AbstractSchemaManager;
27
28
/**
29
 * Extend the Doctrine/DBAL database connection.
30
 */
31
class Connection extends BaseConnection
32
{
33
    public readonly string $prefix;
34
35
    public function __construct(
36
        array $params,
37
        Driver $driver,
38
        ?Configuration $config = null,
39
        ?EventManager $eventManager = null,
40
    ) {
41
        $this->prefix = $params['prefix'] ?? '';
0 ignored issues
show
Bug introduced by
The property prefix is declared read-only in Fisharebest\Webtrees\DB\Connection.
Loading history...
42
        unset ($params['prefix']);
43
44
        parent::__construct($params, $driver, $config, $eventManager);
0 ignored issues
show
Unused Code introduced by
The call to Doctrine\DBAL\Connection::__construct() has too many arguments starting with $eventManager. ( Ignorable by Annotation )

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

44
        parent::/** @scrutinizer ignore-call */ 
45
                __construct($params, $driver, $config, $eventManager);

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. Please note the @ignore annotation hint above.

Loading history...
45
    }
46
47
    public function createQueryBuilder(): QueryBuilder
48
    {
49
        return new QueryBuilder($this, $this->prefix);
50
    }
51
52
    public function createSchemaManager(): AbstractSchemaManager
53
    {
54
        return $this->_driver->getSchemaManager(
0 ignored issues
show
Bug introduced by
The property _driver does not exist on Fisharebest\Webtrees\DB\Connection. Did you mean driver?
Loading history...
55
            $this,
56
            $this->getDatabasePlatform(),
57
        );
58
    }
59
}
60