Issues (43)

src/Driver/Pdo/AbstractPdoSchema.php (2 issues)

1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Db\Driver\Pdo;
6
7
use Yiisoft\Db\Exception\NotSupportedException;
8
use Yiisoft\Db\Schema\AbstractSchema;
9
10
/**
11
 * Represents a schema for a PDO (PHP Data Object) connection.
12
 */
13
abstract class AbstractPdoSchema extends AbstractSchema
14
{
15
    /**
16
     * Generates the cache key for the current connection.
17
     *
18
     * @throws NotSupportedException If the connection is not a PDO connection.
19
     *
20
     * @return array The cache key.
21
     */
22
    protected function generateCacheKey(): array
23
    {
24
        $cacheKey = [];
0 ignored issues
show
The assignment to $cacheKey is dead and can be removed.
Loading history...
25
26
        if ($this->db instanceof PdoConnectionInterface) {
27
            $cacheKey = [$this->db->getDriver()->getDsn(), $this->db->getDriver()->getUsername()];
0 ignored issues
show
The method getDriver() does not exist on Yiisoft\Db\Connection\ConnectionInterface. Did you maybe mean getDriverName()? ( Ignorable by Annotation )

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

27
            $cacheKey = [$this->db->/** @scrutinizer ignore-call */ getDriver()->getDsn(), $this->db->getDriver()->getUsername()];

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...
28
        } else {
29
            throw new NotSupportedException('Only PDO connections are supported.');
30
        }
31
32
        return $cacheKey;
33
    }
34
}
35