1818
1919class Mysql extends AbstractPlatform
2020{
21+ public final const PLATFORM_NAME = 'MySQL ' ;
22+
2123 /**
2224 * {@inheritDoc}
2325 */
@@ -28,9 +30,6 @@ class Mysql extends AbstractPlatform
2830 */
2931 protected $ quoteIdentifierTo = '`` ' ;
3032
31- /** @var \mysqli|\PDO|Pdo\Pdo|Mysqli\Mysqli */
32- protected $ driver ;
33-
3433 /**
3534 * NOTE: Include dashes for MySQL only, need tests for others platforms
3635 *
@@ -42,42 +41,15 @@ class Mysql extends AbstractPlatform
4241 * todo: track down if this still needs to accept null
4342 */
4443 public function __construct (
45- DriverInterface |\mysqli |\PDO |null $ driver = null
46- ) {
47- if ($ driver ) {
48- $ this ->setDriver ($ driver );
49- }
50- }
51-
52- /**
53- * @param \Laminas\Db\Adapter\Driver\Mysqli\Mysqli|\Laminas\Db\Adapter\Driver\Pdo\Pdo|\mysqli|\PDO $driver
54- * @return $this Provides a fluent interface
55- * @throws InvalidArgumentException
56- */
57- public function setDriver ($ driver )
58- {
59- // handle Laminas\Db drivers
60- if (
61- $ driver instanceof Mysqli \Mysqli
62- || ($ driver instanceof Pdo \Pdo && $ driver ->getDatabasePlatformName () === 'Mysql ' )
63- || $ driver instanceof \mysqli
64- || ($ driver instanceof \PDO && $ driver ->getAttribute (\PDO ::ATTR_DRIVER_NAME ) === 'mysql ' )
65- ) {
66- $ this ->driver = $ driver ;
67- return $ this ;
68- }
69-
70- throw new Exception \InvalidArgumentException (
71- '$driver must be a Laminas\Db\Adapter\Mysql\Driver\*, Mysqli\Mysqli or Pdo\Pdo instance '
72- );
73- }
44+ protected readonly DriverInterface |\mysqli |\PDO $ driver
45+ ) {}
7446
7547 /**
7648 * {@inheritDoc}
7749 */
7850 public function getName ()
7951 {
80- return ' MySQL ' ;
52+ return self :: PLATFORM_NAME ;
8153 }
8254
8355 public function getSqlPlatformDecorator (): PlatformDecoratorInterface
@@ -113,11 +85,7 @@ public function quoteTrustedValue($value)
11385 return $ quotedViaDriverValue ?? parent ::quoteTrustedValue ($ value );
11486 }
11587
116- /**
117- * @param string $value
118- * @return string|null
119- */
120- protected function quoteViaDriver ($ value )
88+ protected function quoteViaDriver (string $ value ): ?string
12189 {
12290 if ($ this ->driver instanceof DriverInterface) {
12391 // todo: verify this can not return a PDOStatement instance
0 commit comments