Skip to content

Commit 1038d06

Browse files
committed
Chore: Switch linter/formatter to PHP Coding Standards Fixer
It also has a ruleset to order `use` statements. - https://github.com/PHP-CS-Fixer/PHP-CS-Fixer - https://cs.symfony.com/doc/rules/import/ordered_imports.html Before: PHP_CodeSniffer - https://github.com/PHPCSStandards/PHP_CodeSniffer
1 parent 40283de commit 1038d06

20 files changed

+87
-48
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
.project
44
.vagrant
55
.phpunit.result.cache
6+
*.cache
67
*-console.log
78
.crate-docs
89
/composer.lock

.php-cs-fixer.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
// PHP Coding Standards Fixer
3+
// https://cs.symfony.com/
4+
// https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/master/doc/config.rst
5+
6+
$finder = (new PhpCsFixer\Finder())
7+
->in(__DIR__)
8+
;
9+
10+
return (new PhpCsFixer\Config())
11+
->setUnsupportedPhpVersionAllowed(true)
12+
->setRules([
13+
// '@auto' => true,
14+
// '@PHP7x3Migration' => true,
15+
// '@PSR1' => true,
16+
// '@PSR2' => true,
17+
// '@PSR12' => true,
18+
// '@Symfony' => true,
19+
// 'array_syntax' => ['syntax' => 'short'],
20+
'ordered_imports' => true,
21+
// 'strict_param' => true,
22+
])
23+
->setFinder($finder)
24+
;
25+
26+
?>

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
},
2828
"require-dev": {
2929
"phpunit/phpunit": "^9.0",
30-
"squizlabs/php_codesniffer": "^3.5"
30+
"friendsofphp/php-cs-fixer": "^3.89"
3131
},
3232
"autoload-dev": {
3333
"psr-0": {
@@ -44,7 +44,7 @@
4444
},
4545
"scripts": {
4646
"test": "XDEBUG_MODE=coverage phpunit --coverage-clover build/logs/clover.xml",
47-
"check-style": "phpcs -s",
48-
"fix-style": "phpcbf"
47+
"check-style": "php-cs-fixer check",
48+
"fix-style": "php-cs-fixer fix"
4949
}
5050
}

examples/objects.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
*/
77
require __DIR__ . '/../vendor/autoload.php';
88

9+
use Crate\DBAL\Platforms\CratePlatform4;
10+
use Crate\DBAL\Types\MapType;
11+
use Doctrine\DBAL\DriverManager;
912
use Doctrine\DBAL\Exception\TableNotFoundException;
1013
use Doctrine\DBAL\Schema\Column;
1114
use Doctrine\DBAL\Schema\Table;
15+
1216
use Doctrine\DBAL\Tools\DsnParser;
1317
use Doctrine\DBAL\Types\Type;
14-
use Doctrine\DBAL\DriverManager;
15-
16-
use Crate\DBAL\Platforms\CratePlatform4;
17-
use Crate\DBAL\Types\MapType;
1818

1919
// Initialize machinery.
2020
// This ensures that the 'map' type is registered in the type system from the beginning.

src/Crate/DBAL/Driver/PDOCrate/CrateStatement.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* Licensed to CRATE Technology GmbH("Crate") under one or more contributor
45
* license agreements. See the NOTICE file distributed with this work for
@@ -22,12 +23,12 @@
2223

2324
namespace Crate\DBAL\Driver\PDOCrate;
2425

25-
use Crate\PDO\PDOStatement;
2626
use Crate\PDO\PDOInterface;
27+
use Crate\PDO\PDOStatement;
2728
use Doctrine\DBAL\Driver\PDO\Exception;
2829
use Doctrine\DBAL\Driver\PDOStatementImplementations;
29-
use Doctrine\DBAL\Driver\Statement as StatementInterface;
3030
use Doctrine\DBAL\Driver\Result as ResultInterface;
31+
use Doctrine\DBAL\Driver\Statement as StatementInterface;
3132
use Doctrine\DBAL\ParameterType;
3233
use Doctrine\Deprecations\Deprecation;
3334
use PDO;

src/Crate/DBAL/Driver/PDOCrate/Driver.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* Licensed to CRATE Technology GmbH("Crate") under one or more contributor
45
* license agreements. See the NOTICE file distributed with this work for
@@ -19,10 +20,11 @@
1920
* with Crate these terms will supersede the license and you may use the
2021
* software solely pursuant to the terms of the relevant commercial agreement.
2122
*/
23+
2224
namespace Crate\DBAL\Driver\PDOCrate;
2325

24-
use Crate\DBAL\Platforms\CratePlatform1;
2526
use Crate\DBAL\Platforms\CratePlatform;
27+
use Crate\DBAL\Platforms\CratePlatform1;
2628
use Crate\DBAL\Platforms\CratePlatform4;
2729
use Crate\DBAL\Schema\CrateSchemaManager;
2830
use Doctrine\DBAL\Connection;
@@ -32,8 +34,8 @@
3234

3335
class Driver implements \Doctrine\DBAL\Driver
3436
{
35-
const VERSION = '4.0.3';
36-
const NAME = 'crate';
37+
public const VERSION = '4.0.3';
38+
public const NAME = 'crate';
3739

3840
private const VERSION_057 = '0.57.0';
3941
private const VERSION_4 = '4.0.0';

src/Crate/DBAL/Driver/PDOCrate/ExceptionConverter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
use Doctrine\DBAL\Exception\TableNotFoundException;
1616
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
1717
use Doctrine\DBAL\Query;
18-
1918
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
19+
2020
use function strpos;
2121

2222
/** @internal */

src/Crate/DBAL/Driver/PDOCrate/PDOConnection.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* Licensed to CRATE Technology GmbH("Crate") under one or more contributor
45
* license agreements. See the NOTICE file distributed with this work for
@@ -24,16 +25,15 @@
2425

2526
use Crate\PDO\PDOCrateDB;
2627
use Crate\PDO\PDOStatement;
28+
use Doctrine\DBAL\Driver\Connection as ConnectionInterface;
2729
use Doctrine\DBAL\Driver\PDO\Exception;
2830
use Doctrine\DBAL\Driver\Result as ResultInterface;
29-
use Doctrine\DBAL\Driver\Connection as ConnectionInterface;
3031
use Doctrine\DBAL\ParameterType;
3132
use PDO;
3233
use PDOException;
3334

3435
class PDOConnection implements ConnectionInterface
3536
{
36-
3737
private PDOCrateDB $connection;
3838

3939
/**

src/Crate/DBAL/Platforms/CratePlatform.php

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* Licensed to CRATE Technology GmbH("Crate") under one or more contributor
45
* license agreements. See the NOTICE file distributed with this work for
@@ -19,6 +20,7 @@
1920
* with Crate these terms will supersede the license and you may use the
2021
* software solely pursuant to the terms of the relevant commercial agreement.
2122
*/
23+
2224
namespace Crate\DBAL\Platforms;
2325

2426
use Crate\DBAL\Types\MapType;
@@ -28,20 +30,19 @@
2830
use Doctrine\DBAL\Events;
2931
use Doctrine\DBAL\Exception as DBALException;
3032
use Doctrine\DBAL\Platforms\AbstractPlatform;
33+
use Doctrine\DBAL\Schema\ForeignKeyConstraint;
3134
use Doctrine\DBAL\Schema\Identifier;
3235
use Doctrine\DBAL\Schema\Index;
3336
use Doctrine\DBAL\Schema\Table;
3437
use Doctrine\DBAL\Schema\TableDiff;
3538
use Doctrine\DBAL\Types\Type;
36-
use Doctrine\DBAL\Schema\ForeignKeyConstraint;
3739
use InvalidArgumentException;
3840

3941
class CratePlatform extends AbstractPlatform
4042
{
41-
42-
const TIMESTAMP_FORMAT = 'Y-m-d\TH:i:s';
43-
const TIMESTAMP_FORMAT_TZ = 'Y-m-d\TH:i:sO';
44-
const TABLE_WHERE_CLAUSE_FORMAT = '%s.table_name = %s AND %s.schema_name = %s';
43+
public const TIMESTAMP_FORMAT = 'Y-m-d\TH:i:s';
44+
public const TIMESTAMP_FORMAT_TZ = 'Y-m-d\TH:i:sO';
45+
public const TABLE_WHERE_CLAUSE_FORMAT = '%s.table_name = %s AND %s.schema_name = %s';
4546

4647
/**
4748
* {@inheritDoc}
@@ -605,7 +606,7 @@ public function getCreateTableSQL(Table $table, $createFlags = self::CREATE_INDE
605606
$options['indexes'] = array();
606607
$options['primary'] = array();
607608

608-
if (($createFlags&self::CREATE_INDEXES) > 0) {
609+
if (($createFlags & self::CREATE_INDEXES) > 0) {
609610
foreach ($table->getIndexes() as $index) {
610611
/* @var $index Index */
611612
if ($index->isPrimary()) {
@@ -686,7 +687,7 @@ protected function _getCreateTableSQL($name, array $columns, array $options = ar
686687
$columnListSql .= ', ' . $this->getIndexDeclarationSQL($index, $definition);
687688
}
688689
}
689-
690+
690691
if (isset($options['foreignKeys'])) {
691692
throw DBALException::notSupported("Create Table: foreign keys");
692693
}
@@ -831,15 +832,15 @@ public function getDropDatabaseSQL($database)
831832
{
832833
throw DBALException::notSupported(__METHOD__);
833834
}
834-
835+
835836
/**
836837
* {@inheritDoc}
837838
*/
838839
public function getCreateForeignKeySQL(ForeignKeyConstraint $foreignKey, $table)
839840
{
840841
throw DBALException::notSupported(__METHOD__);
841842
}
842-
843+
843844
/**
844845
* {@inheritDoc}
845846
*/
@@ -854,7 +855,7 @@ public function getGuidTypeDeclarationSQL(array $field)
854855
*
855856
* @return string
856857
*/
857-
public function getTableOptionsSQL(string $table) : string
858+
public function getTableOptionsSQL(string $table): string
858859
{
859860
return "SELECT clustered_by, number_of_shards, partitioned_by, number_of_replicas, column_policy, settings " .
860861
"FROM information_schema.tables c " .

src/Crate/DBAL/Platforms/CratePlatform1.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* Licensed to CRATE Technology GmbH("Crate") under one or more contributor
45
* license agreements. See the NOTICE file distributed with this work for
@@ -24,7 +25,7 @@
2425

2526
class CratePlatform1 extends CratePlatform
2627
{
27-
const TABLE_WHERE_CLAUSE_FORMAT_1 = '%s.table_name = %s AND %s.table_schema = %s';
28+
public const TABLE_WHERE_CLAUSE_FORMAT_1 = '%s.table_name = %s AND %s.table_schema = %s';
2829

2930
/**
3031
* {@inheritDoc}

0 commit comments

Comments
 (0)