Skip to content

Commit 509cc1d

Browse files
committed
Fix line length issues
Signed-off-by: Maurício Meneghini Fauth <[email protected]>
1 parent 57b812d commit 509cc1d

14 files changed

+123
-50
lines changed

phpcs.xml.dist

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414
<exclude-pattern>*/src/Contexts/*</exclude-pattern>
1515
</rule>
1616

17-
<rule ref="Generic.Files.LineLength.TooLong">
18-
<severity>4</severity>
19-
</rule>
2017
<rule ref="Generic.Metrics.NestingLevel.TooHigh">
2118
<severity>4</severity>
2219
</rule>

src/Components/AlterOperation.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,8 @@ public static function parse(Parser $parser, TokensList $list, array $options =
286286
|| array_key_exists($token->value, self::$TABLE_OPTIONS))
287287
&& ! self::checkIfColumnDefinitionKeyword($token->value)
288288
) {
289-
// This alter operation has finished, which means a comma was missing before start of new alter operation
289+
// This alter operation has finished, which means a comma
290+
// was missing before start of new alter operation
290291
$parser->error(
291292
'Missing comma before start of a new alter operation.',
292293
$token

src/Components/IndexHint.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,10 @@ public static function parse(Parser $parser, TokensList $list, array $options =
151151
break;
152152
case 3:
153153
if ($token->type === Token::TYPE_KEYWORD) {
154-
if ($token->keyword === 'JOIN' || $token->keyword === 'GROUP BY' || $token->keyword === 'ORDER BY') {
154+
if ($token->keyword === 'JOIN'
155+
|| $token->keyword === 'GROUP BY'
156+
|| $token->keyword === 'ORDER BY'
157+
) {
155158
$expr->for = $token->keyword;
156159
} else {
157160
$parser->error('Unexpected keyword.', $token);

src/Components/PartitionDefinition.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,8 @@ public static function build($component, array $options = [])
250250
return trim(
251251
'PARTITION ' . $component->name
252252
. (empty($component->type) ? '' : ' VALUES ' . $component->type . ' ' . $component->expr . ' ')
253-
. (! empty($component->options) && ! empty($component->type) ? '' : ' ') . $component->options . $subpartitions
253+
. (! empty($component->options) && ! empty($component->type) ? '' : ' ')
254+
. $component->options . $subpartitions
254255
);
255256
}
256257
}

src/Lexer.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,10 @@ public function lex()
312312
// Parsing the delimiter.
313313
$this->delimiter = null;
314314
$delimiterLen = 0;
315-
while (++$this->last < $this->len && ! Context::isWhitespace($this->str[$this->last]) && $delimiterLen < 15) {
315+
while (++$this->last < $this->len
316+
&& ! Context::isWhitespace($this->str[$this->last])
317+
&& $delimiterLen < 15
318+
) {
316319
$this->delimiter .= $this->str[$this->last];
317320
++$delimiterLen;
318321
}

src/Statements/CallStatement.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class CallStatement extends Statement
3535
*/
3636
public function build()
3737
{
38-
return 'CALL ' . $this->call->name . '(' . ($this->call->parameters ? implode(',', $this->call->parameters->raw) : '') . ')';
38+
return 'CALL ' . $this->call->name . '('
39+
. ($this->call->parameters ? implode(',', $this->call->parameters->raw) : '') . ')';
3940
}
4041
}

src/Utils/Formatter.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,9 @@ public function formatList($list)
435435

436436
// Checking if this clause ended.
437437
if ($isClause = static::isClause($curr)) {
438-
if (($isClause === 2 || $this->options['clause_newline']) && empty(self::$SHORT_CLAUSES[$lastClause])) {
438+
if (($isClause === 2 || $this->options['clause_newline'])
439+
&& empty(self::$SHORT_CLAUSES[$lastClause])
440+
) {
439441
$lineEnded = true;
440442
if ($this->options['parts_newline'] && $indent > 0) {
441443
--$indent;
@@ -445,7 +447,8 @@ public function formatList($list)
445447

446448
// Inline JOINs
447449
if (($prev->type === Token::TYPE_KEYWORD && isset(JoinKeyword::$JOINS[$prev->value]))
448-
|| (in_array($curr->value, ['ON', 'USING'], true) && isset(JoinKeyword::$JOINS[$list->tokens[$list->idx - 2]->value]))
450+
|| (in_array($curr->value, ['ON', 'USING'], true)
451+
&& isset(JoinKeyword::$JOINS[$list->tokens[$list->idx - 2]->value]))
449452
|| isset($list->tokens[$list->idx - 4], JoinKeyword::$JOINS[$list->tokens[$list->idx - 4]->value])
450453
|| isset($list->tokens[$list->idx - 6], JoinKeyword::$JOINS[$list->tokens[$list->idx - 6]->value])
451454
) {
@@ -514,7 +517,9 @@ public function formatList($list)
514517
|| ! (
515518
($prev->type === Token::TYPE_OPERATOR && ($prev->value === '.' || $prev->value === '('))
516519
// No space after . (
517-
|| ($curr->type === Token::TYPE_OPERATOR && ($curr->value === '.' || $curr->value === ',' || $curr->value === '(' || $curr->value === ')'))
520+
|| ($curr->type === Token::TYPE_OPERATOR
521+
&& ($curr->value === '.' || $curr->value === ','
522+
|| $curr->value === '(' || $curr->value === ')'))
518523
// No space before . , ( )
519524
|| $curr->type === Token::TYPE_DELIMITER && mb_strlen((string) $curr->value, 'UTF-8') < 2
520525
)

tests/Components/ConditionTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ public function testParse()
1717

1818
public function testParseBetween()
1919
{
20-
$component = Condition::parse(new Parser(), $this->getTokensList('(id BETWEEN 10 AND 20) OR (id BETWEEN 30 AND 40)'));
20+
$component = Condition::parse(
21+
new Parser(),
22+
$this->getTokensList('(id BETWEEN 10 AND 20) OR (id BETWEEN 30 AND 40)')
23+
);
2124
$this->assertEquals($component[0]->expr, '(id BETWEEN 10 AND 20)');
2225
$this->assertEquals($component[1]->expr, 'OR');
2326
$this->assertEquals($component[2]->expr, '(id BETWEEN 30 AND 40)');

tests/Components/CreateDefinitionTest.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,14 @@ public function testBuild()
5757
'CREATE TABLE `payment` (' .
5858
'-- snippet' . "\n" .
5959
'`customer_id` smallint(5) unsigned NOT NULL,' .
60-
'CONSTRAINT `fk_payment_customer` FOREIGN KEY (`customer_id`) REFERENCES `customer` (`customer_id`) ON UPDATE CASCADE' .
60+
'CONSTRAINT `fk_payment_customer` FOREIGN KEY (`customer_id`) ' .
61+
'REFERENCES `customer` (`customer_id`) ON UPDATE CASCADE' .
6162
') ENGINE=InnoDB"'
6263
);
6364
$this->assertInstanceOf(CreateStatement::class, $parser->statements[0]);
6465
$this->assertEquals(
65-
'CONSTRAINT `fk_payment_customer` FOREIGN KEY (`customer_id`) REFERENCES `customer` (`customer_id`) ON UPDATE CASCADE',
66+
'CONSTRAINT `fk_payment_customer` FOREIGN KEY (`customer_id`) ' .
67+
'REFERENCES `customer` (`customer_id`) ON UPDATE CASCADE',
6668
CreateDefinition::build($parser->statements[0]->fields[1])
6769
);
6870
}
@@ -73,13 +75,15 @@ public function testBuild2()
7375
'CREATE TABLE `payment` (' .
7476
'-- snippet' . "\n" .
7577
'`customer_id` smallint(5) unsigned NOT NULL,' .
76-
'`customer_data` longtext CHARACTER SET utf8mb4 CHARSET utf8mb4_bin NOT NULL CHECK (json_valid(customer_data)),' .
77-
'CONSTRAINT `fk_payment_customer` FOREIGN KEY (`customer_id`) REFERENCES `customer` (`customer_id`) ON UPDATE CASCADE' .
78+
'`customer_data` longtext CHARACTER SET utf8mb4 CHARSET utf8mb4_bin NOT NULL ' .
79+
'CHECK (json_valid(customer_data)),CONSTRAINT `fk_payment_customer` FOREIGN KEY ' .
80+
'(`customer_id`) REFERENCES `customer` (`customer_id`) ON UPDATE CASCADE' .
7881
') ENGINE=InnoDB"'
7982
);
8083
$this->assertInstanceOf(CreateStatement::class, $parser->statements[0]);
8184
$this->assertEquals(
82-
'CONSTRAINT `fk_payment_customer` FOREIGN KEY (`customer_id`) REFERENCES `customer` (`customer_id`) ON UPDATE CASCADE',
85+
'CONSTRAINT `fk_payment_customer` FOREIGN KEY (`customer_id`) ' .
86+
'REFERENCES `customer` (`customer_id`) ON UPDATE CASCADE',
8387
CreateDefinition::build($parser->statements[0]->fields[2])
8488
);
8589
}

tests/Lexer/ContextTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,9 @@ public function contextNames()
107107

108108
public function testLoadError()
109109
{
110-
$this->expectExceptionMessage('Specified context ("\PhpMyAdmin\SqlParser\Contexts\ContextFoo") does not exist.');
110+
$this->expectExceptionMessage(
111+
'Specified context ("\PhpMyAdmin\SqlParser\Contexts\ContextFoo") does not exist.'
112+
);
111113
$this->expectException(Throwable::class);
112114
Context::load('Foo');
113115
}

tests/Misc/UtfStringTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ class UtfStringTest extends TestCase
1313
/**
1414
* Sample phrase in French.
1515
*/
16-
public const TEST_PHRASE = 'Les naïfs ægithales hâtifs pondant à Noël où il gèle sont sûrs d\'être déçus en voyant leurs drôles d\'œufs abîmés.';
16+
public const TEST_PHRASE = 'Les naïfs ægithales hâtifs pondant à Noël où il '
17+
. 'gèle sont sûrs d\'être déçus en voyant leurs drôles d\'œufs abîmés.';
1718

1819
/**
1920
* The length of the sample phrase.

tests/Utils/BufferedQueryTest.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ public function extractProvider()
7171
'/* a comment */ DELIMITER $$' . "\n" .
7272
'' . "\n" .
7373
'# Bash-like comment sytanx.' . "\n" .
74-
'CREATE DEFINER=`root`@`localhost` PROCEDURE `film_in_stock` (IN `p_film_id` INT, IN `p_store_id` INT, OUT `p_film_count` INT) READS SQL DATA' . "\n" .
74+
'CREATE DEFINER=`root`@`localhost` PROCEDURE `film_in_stock` (IN `p_film_id` ' .
75+
'INT, IN `p_store_id` INT, OUT `p_film_count` INT) READS SQL DATA' . "\n" .
7576
'BEGIN' . "\n" .
7677
' SELECT inventory_id' . "\n" .
7778
' FROM inventory' . "\n" .
@@ -189,7 +190,8 @@ public function extractProvider()
189190
'SET time_zone = "+00:00"',
190191

191192
'# Bash-like comment sytanx.' . "\n" .
192-
'CREATE DEFINER=`root`@`localhost` PROCEDURE `film_in_stock` (IN `p_film_id` INT, IN `p_store_id` INT, OUT `p_film_count` INT) READS SQL DATA' . "\n" .
193+
'CREATE DEFINER=`root`@`localhost` PROCEDURE `film_in_stock` (IN `p_film_id` ' .
194+
'INT, IN `p_store_id` INT, OUT `p_film_count` INT) READS SQL DATA' . "\n" .
193195
'BEGIN' . "\n" .
194196
' SELECT inventory_id' . "\n" .
195197
' FROM inventory' . "\n" .
@@ -245,7 +247,8 @@ public function extractProvider()
245247
'/* a comment */ DELIMITER $$',
246248

247249
'# Bash-like comment sytanx.' . "\n" .
248-
'CREATE DEFINER=`root`@`localhost` PROCEDURE `film_in_stock` (IN `p_film_id` INT, IN `p_store_id` INT, OUT `p_film_count` INT) READS SQL DATA' . "\n" .
250+
'CREATE DEFINER=`root`@`localhost` PROCEDURE `film_in_stock` (IN `p_film_id` ' .
251+
'INT, IN `p_store_id` INT, OUT `p_film_count` INT) READS SQL DATA' . "\n" .
249252
'BEGIN' . "\n" .
250253
' SELECT inventory_id' . "\n" .
251254
' FROM inventory' . "\n" .
@@ -301,7 +304,8 @@ public function extractProvider()
301304
'SET time_zone = "+00:00";',
302305

303306
'# Bash-like comment sytanx.' . "\n" .
304-
'CREATE DEFINER=`root`@`localhost` PROCEDURE `film_in_stock` (IN `p_film_id` INT, IN `p_store_id` INT, OUT `p_film_count` INT) READS SQL DATA' . "\n" .
307+
'CREATE DEFINER=`root`@`localhost` PROCEDURE `film_in_stock` (IN `p_film_id` ' .
308+
'INT, IN `p_store_id` INT, OUT `p_film_count` INT) READS SQL DATA' . "\n" .
305309
'BEGIN' . "\n" .
306310
' SELECT inventory_id' . "\n" .
307311
' FROM inventory' . "\n" .

0 commit comments

Comments
 (0)