Skip to content

Commit 471d5c8

Browse files
author
Stephan Bröker
committed
Last
1 parent 2335f2a commit 471d5c8

File tree

8 files changed

+51
-40
lines changed

8 files changed

+51
-40
lines changed

.DS_Store

0 Bytes
Binary file not shown.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ composer.lock
44
.DS_Store
55
src/.DS_Store
66
tests/.DS_Store
7+
.DS_Store
8+
src/.DS_Store

src/.DS_Store

0 Bytes
Binary file not shown.

src/Dialect/FirebirdDialectTrait.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
1414
*
1515
*/
16-
1716
namespace CakephpFirebird\Dialect;
1817

1918
use Cake\Database\QueryCompiler;

src/Driver/Firebird.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@
1515
*/
1616
namespace CakephpFirebird\Driver;
1717

18+
use Cake\Database\Schema\SchemaDialect;
19+
use Cake\Database\StatementInterface;
1820
use PDO;
1921
use Cake\Database\Driver;
2022
use Cake\Database\Query;
21-
use Cake\Database\Driver\PDODriverTrait;
23+
// use Cake\Database\Driver\PDODriverTrait;
2224
use CakephpFirebird\Dialect\FirebirdDialectTrait;
2325
use CakephpFirebird\Schema\FirebirdSchema;
2426
use CakephpFirebird\Statement\FirebirdStatement;
25-
use Cake\Database\StatementInterface;
26-
use Cake\Database\Schema\SchemaDialect;
2727

2828
class Firebird extends Driver
2929
{
@@ -48,8 +48,6 @@ class Firebird extends Driver
4848
'init' => [],
4949
];
5050

51-
protected $_schemaDialect;
52-
5351
/**
5452
* Establishes a connection to the database server
5553
*
@@ -96,7 +94,7 @@ public function enabled(): bool
9694
*/
9795
public function schemaDialect(): SchemaDialect
9896
{
99-
if (!$this->_schemaDialect === null) {
97+
if (!$this->_schemaDialect) {
10098
$this->_schemaDialect = new FirebirdSchema($this);
10199
}
102100
return $this->_schemaDialect;

src/FirebirdCompiler.php

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
*/
1616
namespace CakephpFirebird;
1717

18+
use Cake\Database\Query;
1819
use Cake\Database\QueryCompiler;
20+
use Cake\Database\ValueBinder;
1921

2022
/**
2123
* Responsible for compiling a Query object into its SQL representation
@@ -50,11 +52,15 @@ class FirebirdCompiler extends QueryCompiler
5052

5153
/**
5254
* @param array $parts
53-
* @param \Cake\Database\Query $query
54-
* @param \Cake\Database\ValueBinder $generator
55+
* @param Query $query
56+
* @param ValueBinder $generator
5557
* @return string
5658
*/
57-
protected function _buildSelectPart($parts, $query, $generator)
59+
protected function _buildSelectPart(
60+
array $parts,
61+
Query $query,
62+
ValueBinder $generator
63+
): string
5864
{
5965
$driver = $query
6066
->getConnection()
@@ -100,11 +106,15 @@ protected function _buildSelectPart($parts, $query, $generator)
100106
* row's data back.
101107
*
102108
* @param array $parts The parts to build
103-
* @param \Cake\Database\Query $query The query that is being compiled
104-
* @param \Cake\Database\ValueBinder $generator the placeholder generator to be used in expressions
109+
* @param Query $query The query that is being compiled
110+
* @param ValueBinder $generator the placeholder generator to be used in expressions
105111
* @return string
106112
*/
107-
protected function _buildInsertPart($parts, $query, $generator)
113+
protected function _buildInsertPart(
114+
array $parts,
115+
Query $query,
116+
ValueBinder $generator
117+
): string
108118
{
109119
$table = $parts[0];
110120
$columns = $this->_stringifyExpressions($parts[1], $generator);
@@ -114,11 +124,11 @@ protected function _buildInsertPart($parts, $query, $generator)
114124

115125
/**
116126
* @param array $parts
117-
* @param \Cake\Database\Query $query
118-
* @param \Cake\Database\ValueBinder $generator
127+
* @param Query $query
128+
* @param ValueBinder $generator
119129
* @return string
120130
*/
121-
protected function _buildValuesPart($parts, $query, $generator)
131+
protected function _buildValuesPart(array $parts, Query $query, ValueBinder $generator): string
122132
{
123133
$values = $parts[0];
124134

@@ -134,10 +144,10 @@ protected function _buildValuesPart($parts, $query, $generator)
134144
* Generates the LIMIT part of a Firebird
135145
*
136146
* @param int $limit the limit clause
137-
* @param \Cake\Database\Query $query The query that is being compiled
147+
* @param Query $query The query that is being compiled
138148
* @return string
139149
*/
140-
protected function _buildLimitPart($limit, $query)
150+
protected function _buildLimitPart(int $limit, Query $query): string
141151
{
142152
return false;
143153
}

src/Schema/FirebirdSchema.php

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
use Cake\Database\Exception;
1919
use Cake\Database\Schema\BaseSchema;
2020
use Cake\Database\Schema\Table;
21+
use Cake\Database\Schema\TableSchema;
22+
2123
/**
2224
* Schema generation/reflection features for Firebird
2325
* Commands taken from http://www.alberton.info/firebird_sql_meta_info.html#.Vvv5wSbRJQt
@@ -28,7 +30,7 @@ class FirebirdSchema extends BaseSchema
2830
/**
2931
* {@inheritDoc}
3032
*/
31-
public function listTablesSql($config)
33+
public function listTablesSql(array $config): array
3234
{
3335
return [
3436
'SELECT RDB$RELATION_NAME
@@ -41,7 +43,7 @@ public function listTablesSql($config)
4143
/**
4244
* {@inheritDoc}
4345
*/
44-
public function describeColumnSql($tableName, $config)
46+
public function describeColumnSql(string $tableName, array $config): array
4547
{
4648
return ['SELECT trim(LOWER(r.RDB$FIELD_NAME)) AS FIELD_NAME,
4749
CASE f.RDB$FIELD_TYPE
@@ -85,7 +87,7 @@ public function describeColumnSql($tableName, $config)
8587
/**
8688
* {@inheritDoc}
8789
*/
88-
public function describeIndexSql($tableName, $config)
90+
public function describeIndexSql(string $tableName, array $config): array
8991
{
9092
return [
9193
'SELECT TRIM(i.RDB$INDEX_NAME) AS INDEX_NAME,
@@ -197,7 +199,7 @@ protected function _convertColumn($column)
197199
/**
198200
* {@inheritDoc}
199201
*/
200-
public function convertColumnDescription(Table $table, $row)
202+
public function convertColumnDescription(TableSchema $table, array $row): void
201203
{
202204
$field = $this->_convertColumn($row['FIELD_TYPE']);
203205
$field += [
@@ -215,18 +217,18 @@ public function convertColumnDescription(Table $table, $row)
215217
/**
216218
* {@inheritDoc}
217219
*/
218-
public function convertIndexDescription(Table $table, $row)
220+
public function convertIndexDescription(TableSchema $table, array $row): void
219221
{
220222
$type = null;
221223
$columns = $length = [];
222224

223225
if ($row['IS_PRIMARY_KEY'] == '1') {
224-
$name = $type = Table::CONSTRAINT_PRIMARY;
226+
$name = $type = TableSchema::CONSTRAINT_PRIMARY;
225227
}
226228

227229
$columns[] = trim($row['COLUMN_NAME']);
228230

229-
if ($type === Table::CONSTRAINT_PRIMARY || $type === Table::CONSTRAINT_UNIQUE) {
231+
if ($type === TableSchema::CONSTRAINT_PRIMARY || $type === TableSchema::CONSTRAINT_UNIQUE) {
230232
$table->addConstraint($name, [
231233
'type' => $type,
232234
'columns' => $columns
@@ -238,7 +240,7 @@ public function convertIndexDescription(Table $table, $row)
238240
/**
239241
* {@inheritDoc}
240242
*/
241-
public function describeForeignKeySql($tableName, $config)
243+
public function describeForeignKeySql(string $tableName, array $config): array
242244
{
243245
return ['SELECT DISTINCT
244246
LOWER(rc.RDB$CONSTRAINT_NAME) AS "CONSTRAINT_NAME",
@@ -263,10 +265,10 @@ public function describeForeignKeySql($tableName, $config)
263265
/**
264266
* {@inheritDoc}
265267
*/
266-
public function convertForeignKeyDescription(Table $table, $row)
268+
public function convertForeignKeyDescription(TableSchema $table, $row): void
267269
{
268270
$data = [
269-
'type' => Table::CONSTRAINT_FOREIGN,
271+
'type' => TableSchema::CONSTRAINT_FOREIGN,
270272
'columns' => [trim($row['COLUMN_NAME'])],
271273
'references' => [trim($row['REFERENCED_TABLE_NAME']), trim($row['REFERENCED_COLUMN_NAME'])],
272274
'update' => $this->_convertOnClause(trim($row['UPDATE_RULE'])),
@@ -279,7 +281,7 @@ public function convertForeignKeyDescription(Table $table, $row)
279281
/**
280282
* {@inheritDoc}
281283
*/
282-
public function truncateTableSql(Table $table)
284+
public function truncateTableSql(TableSchema $table): array
283285
{
284286
$sql = sprintf("DELETE FROM %s", strtoupper($table->name()));
285287
return [$sql];
@@ -288,7 +290,7 @@ public function truncateTableSql(Table $table)
288290
/**
289291
* {@inheritDoc}
290292
*/
291-
public function columnSql(Table $table, $name)
293+
public function columnSql(TableSchema $table, string $name): string
292294
{
293295
$data = $table->getColumn($name);
294296
$out = $this->_driver->quoteIdentifier($name);
@@ -367,7 +369,7 @@ public function columnSql(Table $table, $name)
367369

368370
/**
369371
*/
370-
public function createTableSql(Table $table, $columns, $constraints, $indexes)
372+
public function createTableSql(TableSchema $table, $columns, $constraints, $indexes): array
371373
{
372374
$content = array_merge($columns, $constraints);
373375
$content = implode(",\n", array_filter($content));
@@ -383,10 +385,10 @@ public function createTableSql(Table $table, $columns, $constraints, $indexes)
383385
/**
384386
* {@inheritDoc}
385387
*/
386-
public function constraintSql(Table $table, $name)
388+
public function constraintSql(TableSchema $table, string $name): string
387389
{
388390
$data = $table->getConstraint($name);
389-
if ($data['type'] === Table::CONSTRAINT_PRIMARY) {
391+
if ($data['type'] === TableSchema::CONSTRAINT_PRIMARY) {
390392
return sprintf('CONSTRAINT pk_%s_0 PRIMARY KEY ("%s")', $table->name(), implode(', ', $data['columns']));
391393
}
392394

@@ -397,7 +399,7 @@ public function constraintSql(Table $table, $name)
397399
* @param Table $table
398400
* @return array
399401
*/
400-
public function dropTableSql(Table $table)
402+
public function dropTableSql(TableSchema $table): array
401403
{
402404
$sql = sprintf(
403405
'DROP TABLE %s',
@@ -411,23 +413,23 @@ public function dropTableSql(Table $table)
411413
/**
412414
* {@inheritDoc}
413415
*/
414-
public function addConstraintSql(Table $table)
416+
public function addConstraintSql(TableSchema $table) : array
415417
{
416418
return false;
417419
}
418420

419421
/**
420422
* {@inheritDoc}
421423
*/
422-
public function dropConstraintSql(Table $table)
424+
public function dropConstraintSql(TableSchema $table): array
423425
{
424426
return false;
425427
}
426428

427429
/**
428430
* {@inheritDoc}
429431
*/
430-
public function indexSql(Table $table, $name)
432+
public function indexSql(TableSchema $table, string $name): string
431433
{
432434
return false;
433435
}
@@ -439,7 +441,7 @@ public function indexSql(Table $table, $name)
439441
* @param array $data Key data.
440442
* @return string
441443
*/
442-
protected function _keySql($prefix, $data)
444+
protected function _keySql($prefix, $data): string|false
443445
{
444446
return false;
445447
}

src/Statement/FirebirdStatement.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class FirebirdStatement extends PDOStatement
3333
* {@inheritDoc}
3434
*
3535
*/
36-
public function execute($params = null)
36+
public function execute(?array $params = null): bool
3737
{
3838
$result = $this->_statement->execute($params);
3939
return $result;
@@ -42,7 +42,7 @@ public function execute($params = null)
4242
/**
4343
* @return int
4444
*/
45-
public function rowCount()
45+
public function rowCount(): int
4646
{
4747
if (
4848
strpos($this->_statement->queryString, 'INSERT') === 0 ||

0 commit comments

Comments
 (0)