Skip to content

Commit 6d3b4ac

Browse files
TomasVotrubastaabm
authored andcommitted
[cs] apply PSR-12 and other sets
1 parent 803e2d5 commit 6d3b4ac

File tree

91 files changed

+427
-276
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+427
-276
lines changed

bootstrap.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
use Dotenv\Dotenv;
46
use staabm\PHPStanDba\QueryReflection\QueryReflection;
57
use staabm\PHPStanDba\QueryReflection\RuntimeConfiguration;
68
use staabm\PHPStanDba\Tests\ReflectorFactory;
79

8-
require_once __DIR__.'/vendor/autoload.php';
10+
require_once __DIR__ . '/vendor/autoload.php';
911

1012
if (false === getenv('GITHUB_ACTION')) {
1113
$dotenv = Dotenv::createImmutable(__DIR__);

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
},
4444
"scripts": {
4545
"csfix": [
46-
"vendor/bin/ecs --ansi"
46+
"vendor/bin/ecs --ansi --fix"
4747
],
4848
"test": [
4949
"@putenv DBA_REFLECTOR=mysqli",

ecs.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
declare(strict_types=1);
44

5-
use PhpCsFixer\Fixer\Import\NoUnusedImportsFixer;
65
use Symplify\EasyCodingStandard\Config\ECSConfig;
76
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;
87

@@ -15,18 +14,18 @@
1514
]);
1615

1716
$ecsConfig->skip([
18-
'*/data/*'
17+
'*/data/*',
1918
]);
2019

2120
// this way you can add sets - group of rules
2221
$ecsConfig->sets([
2322
// run and fix, one by one
24-
SetList::SPACES,
25-
SetList::ARRAY,
26-
SetList::STRICT,
27-
SetList::DOCBLOCK,
28-
SetList::NAMESPACES,
29-
SetList::COMMENTS,
30-
SetList::PSR_12,
23+
SetList::SPACES,
24+
SetList::ARRAY,
25+
SetList::STRICT,
26+
SetList::DOCBLOCK,
27+
SetList::NAMESPACES,
28+
SetList::COMMENTS,
29+
SetList::PSR_12,
3130
]);
3231
};

src/Analyzer/QueryPlanAnalyzer.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ final class QueryPlanAnalyzer
1313
* number of unindexed reads allowed before a query is considered inefficient.
1414
*/
1515
public const DEFAULT_UNINDEXED_READS_THRESHOLD = 100000;
16+
1617
/**
1718
* allows analyzing queries even on empty database schemas.
1819
*/
1920
public const TABLES_WITHOUT_DATA = 0;
21+
2022
/**
2123
* max number of rows in a table, for which we don't report errors, because using a index/table-scan wouldn't improve performance.
2224
* requires production quality data in the database at analysis time.

src/Analyzer/QueryPlanAnalyzerMysql.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@ final class QueryPlanAnalyzerMysql
1717
* @deprecated use QueryPlanAnalyzer::DEFAULT_UNINDEXED_READS_THRESHOLD instead
1818
*/
1919
public const DEFAULT_UNINDEXED_READS_THRESHOLD = QueryPlanAnalyzer::DEFAULT_UNINDEXED_READS_THRESHOLD;
20+
2021
/**
2122
* @api
2223
*
2324
* @deprecated use QueryPlanAnalyzer::TABLES_WITHOUT_DATA instead
2425
*/
2526
public const TABLES_WITHOUT_DATA = QueryPlanAnalyzer::TABLES_WITHOUT_DATA;
27+
2628
/**
2729
* @api
2830
*
@@ -48,7 +50,7 @@ public function __construct($connection)
4850
*/
4951
public function analyze(string $query): QueryPlanResult
5052
{
51-
$simulatedQuery = 'EXPLAIN '.$query;
53+
$simulatedQuery = 'EXPLAIN ' . $query;
5254

5355
if ($this->connection instanceof PDO) {
5456
$this->connection->beginTransaction();

src/Analyzer/QueryPlanResult.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
final class QueryPlanResult
88
{
99
public const NO_INDEX = 'no-index';
10+
1011
public const TABLE_SCAN = 'table-scan';
12+
1113
public const UNINDEXED_READS = 'unindexed-reads';
1214

1315
/**
@@ -32,8 +34,6 @@ public function getSimulatedQuery(): string
3234

3335
/**
3436
* @param self::* $result
35-
*
36-
* @return void
3737
*/
3838
public function addRow(string $table, string $result)
3939
{

src/Ast/ExpressionFinder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ private function findFirstPreviousOfNode(Node $node, callable $filter): ?Node
138138
// move to previous expression
139139
$previousStatement = $node->getAttribute(PreviousConnectingVisitor::ATTRIBUTE_PREVIOUS);
140140
if (null !== $previousStatement) {
141-
if (!$previousStatement instanceof Node) {
141+
if (! $previousStatement instanceof Node) {
142142
throw new ShouldNotHappenException();
143143
}
144144
$foundNode = $this->findFirst([$previousStatement], $filter);

src/Ast/PreviousConnectingVisitor.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@
44

55
namespace staabm\PHPStanDba\Ast;
66

7-
use function array_pop;
87
use PhpParser\Node;
98
use PhpParser\NodeVisitorAbstract;
9+
use function array_pop;
1010

1111
final class PreviousConnectingVisitor extends NodeVisitorAbstract
1212
{
1313
public const ATTRIBUTE_PARENT = 'dba-parent';
14+
1415
public const ATTRIBUTE_PREVIOUS = 'dba-previous';
1516

1617
/**

src/CacheNotPopulatedException.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace staabm\PHPStanDba;
46

57
final class CacheNotPopulatedException extends DbaException

src/DbaException.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace staabm\PHPStanDba;
46

57
class DbaException extends \RuntimeException

0 commit comments

Comments
 (0)