Skip to content

Commit 758077b

Browse files
committed
Dumper: default $wrapLength changed to 120
1 parent fee9c6c commit 758077b

File tree

9 files changed

+56
-38
lines changed

9 files changed

+56
-38
lines changed

src/PhpGenerator/Dumper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ final class Dumper
2323
public $maxDepth = 50;
2424

2525
/** @var int */
26-
public $wrapLength = 100;
26+
public $wrapLength = 120;
2727

2828

2929
/**

tests/PhpGenerator/Closure.long.phpt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ require __DIR__ . '/../bootstrap.php';
1111
$function = new Closure;
1212
$function->setBody('return null;');
1313

14-
for ($name = 'abcde'; $name < 'abcdr'; $name++) {
14+
for ($name = 'abcde'; $name < 'abcdu'; $name++) {
1515
$function->addParameter($name);
1616
$function->addUse($name);
1717
}
@@ -30,7 +30,10 @@ same(
3030
$abcdn,
3131
$abcdo,
3232
$abcdp,
33-
$abcdq
33+
$abcdq,
34+
$abcdr,
35+
$abcds,
36+
$abcdt
3437
) use (
3538
$abcde,
3639
$abcdf,
@@ -44,7 +47,10 @@ same(
4447
$abcdn,
4548
$abcdo,
4649
$abcdp,
47-
$abcdq
50+
$abcdq,
51+
$abcdr,
52+
$abcds,
53+
$abcdt
4854
) {
4955
return null;
5056
}', (string) $function);

tests/PhpGenerator/Dumper.dump().phpt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,15 @@ Assert::same('[$s]', $dumper->dump([new PhpLiteral('$s')]));
4141

4242
Assert::same('[1, 2, 3]', $dumper->dump([1, 2, 3]));
4343
Assert::same("['a', 7 => 'b', 'c', '9a' => 'd', 'e']", $dumper->dump(['a', 7 => 'b', 'c', '9a' => 'd', 9 => 'e']));
44+
45+
$dumper->wrapLength = 100;
4446
same("[
4547
[
4648
'a',
4749
'loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong',
4850
],
4951
]", $dumper->dump([['a', 'loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong']]));
52+
5053
Assert::same("['a' => 1, [\"\\r\" => \"\\r\", 2], 3]", $dumper->dump(['a' => 1, ["\r" => "\r", 2], 3]));
5154

5255
Assert::same("(object) [\n\t'a' => 1,\n\t'b' => 2,\n]", $dumper->dump((object) ['a' => 1, 'b' => 2]));

tests/PhpGenerator/Dumper.format().phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ Assert::same('func(1 ? 2 : 3)', $dumper->format('func(1 \? 2 : 3)'));
2020
Assert::same('func([1, 2])', $dumper->format('func(?)', [1, 2]));
2121
Assert::same('func(1, 2)', $dumper->format('func(...?)', [1, 2]));
2222
Assert::same('func(1, 2)', $dumper->format('func(?*)', [1, 2])); // old way
23+
24+
$dumper->wrapLength = 100;
2325
same(
2426
'func(
2527
10,

tests/PhpGenerator/Printer.phpt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ $class->addConstant('FORCE_ARRAY', new PhpLiteral('Nette\Utils\Json::FORCE_ARRAY
2626
->setVisibility('private')
2727
->addComment('Commented');
2828

29-
$class->addConstant('MULTILINE_LONG', ['aaaaaaa' => 1, 'bbbbbbb' => 2, 'ccccccc' => 3, 'ddddddd' => 4, 'eeeeee' => 5]);
30-
$class->addConstant('SHORT', ['aaaaaaa' => 1, 'bbbbbbb' => 2, 'ccccccc' => 3, 'ddddddd' => 4, 'eeeeee' => 5]);
29+
$class->addConstant('MULTILINE_LONG', ['aaaaaaaa' => 1, 'bbbbbbbb' => 2, 'cccccccc' => 3, 'dddddddd' => 4, 'eeeeeeee' => 5, 'ffffffff' => 6]);
30+
$class->addConstant('SHORT', ['aaaaaaaa' => 1, 'bbbbbbbb' => 2, 'cccccccc' => 3, 'dddddddd' => 4, 'eeeeeeee' => 5, 'ffffffff' => 6]);
3131

3232
$class->addProperty('handle')
3333
->setVisibility('private')
@@ -36,14 +36,14 @@ $class->addProperty('handle')
3636
$class->addProperty('order')
3737
->setValue(new PhpLiteral('RecursiveIteratorIterator::SELF_FIRST'));
3838

39-
$class->addProperty('multilineLong', ['aaaaaaa' => 1, 'bbbbbbb' => 2, 'ccccccc' => 3, 'ddddddd' => 4, 'eeeeee' => 5]);
40-
$class->addProperty('short', ['aaaaaaa' => 1, 'bbbbbbb' => 2, 'ccccccc' => 3, 'ddddddd' => 4, 'eeeeee' => 5]);
39+
$class->addProperty('multilineLong', ['aaaaaaaa' => 1, 'bbbbbbbb' => 2, 'cccccccc' => 3, 'dddddddd' => 4, 'eeeeeeee' => 5, 'ffffffff' => 6]);
40+
$class->addProperty('short', ['aaaaaaaa' => 1, 'bbbbbbbb' => 2, 'cccccccc' => 3, 'dddddddd' => 4, 'eeeeeeee' => 5, 'ffffffff' => 6]);
4141

4242
$class->addMethod('first')
4343
->addComment('@return resource')
4444
->setFinal(true)
4545
->setReturnType('stdClass')
46-
->setBody("func();\nreturn ?;", [['aaaaaaaaaaaa' => 1, 'bbbbbbbbbbb' => 2, 'cccccccccccccc' => 3, 'dddddddddddd' => 4, 'eeeeeeeeeeee' => 5]])
46+
->setBody("func();\nreturn ?;", [['aaaaaaaaaaaa' => 1, 'bbbbbbbbbbb' => 2, 'cccccccccccccc' => 3, 'dddddddddddd' => 4, 'eeeeeeeeeeee' => 5, 'ffffffff' => 6]])
4747
->addParameter('var')
4848
->setType('stdClass');
4949

tests/PhpGenerator/PsrPrinter.phpt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ $class->addConstant('FORCE_ARRAY', new PhpLiteral('Nette\Utils\Json::FORCE_ARRAY
2525
->setVisibility('private')
2626
->addComment('Commented');
2727

28-
$class->addConstant('MULTILINE_LONG', ['aaaaaaa' => 1, 'bbbbbbb' => 2, 'ccccccc' => 3, 'ddddddd' => 4, 'eeeeee' => 5]);
29-
$class->addConstant('SHORT', ['aaaaaaa' => 1, 'bbbbbbb' => 2, 'ccccccc' => 3, 'ddddddd' => 4, 'eeeeee' => 5]);
28+
$class->addConstant('MULTILINE_LONG', ['aaaaaaaa' => 1, 'bbbbbbbb' => 2, 'cccccccc' => 3, 'dddddddd' => 4, 'eeeeeeee' => 5, 'ffffffff' => 6]);
29+
$class->addConstant('SHORT', ['aaaaaaaa' => 1, 'bbbbbbbb' => 2, 'cccccccc' => 3, 'dddddddd' => 4, 'eeeeeeee' => 5, 'ffffffff' => 6]);
3030

3131
$class->addProperty('handle')
3232
->setVisibility('private')
@@ -35,14 +35,14 @@ $class->addProperty('handle')
3535
$class->addProperty('order')
3636
->setValue(new PhpLiteral('RecursiveIteratorIterator::SELF_FIRST'));
3737

38-
$class->addProperty('multilineLong', ['aaaaaaa' => 1, 'bbbbbbb' => 2, 'ccccccc' => 3, 'ddddddd' => 4, 'eeeeee' => 5]);
39-
$class->addProperty('short', ['aaaaaaa' => 1, 'bbbbbbb' => 2, 'ccccccc' => 3, 'ddddddd' => 4, 'eeeeee' => 5]);
38+
$class->addProperty('multilineLong', ['aaaaaaaa' => 1, 'bbbbbbbb' => 2, 'cccccccc' => 3, 'dddddddd' => 4, 'eeeeeeee' => 5, 'ffffffff' => 6]);
39+
$class->addProperty('short', ['aaaaaaaa' => 1, 'bbbbbbbb' => 2, 'cccccccc' => 3, 'dddddddd' => 4, 'eeeeeeee' => 5, 'ffffffff' => 6]);
4040

4141
$class->addMethod('first')
4242
->addComment('@return resource')
4343
->setFinal(true)
4444
->setReturnType('stdClass')
45-
->setBody("func();\nreturn ?;", [['aaaaaaaaaaaa' => 1, 'bbbbbbbbbbb' => 2, 'cccccccccccccc' => 3, 'dddddddddddd' => 4, 'eeeeeeeeeeee' => 5]])
45+
->setBody("func();\nreturn ?;", [['aaaaaaaaaaaa' => 1, 'bbbbbbbbbbb' => 2, 'cccccccccccccc' => 3, 'dddddddddddd' => 4, 'eeeeeeeeeeee' => 5, 'ffffffff' => 6]])
4646
->addParameter('var')
4747
->setType('stdClass');
4848

tests/PhpGenerator/expected/Printer.class.expect

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,30 @@ final class Example extends ParentClass implements IExample
1212
/** Commented */
1313
private const FORCE_ARRAY = Nette\Utils\Json::FORCE_ARRAY;
1414
const MULTILINE_LONG = [
15-
'aaaaaaa' => 1,
16-
'bbbbbbb' => 2,
17-
'ccccccc' => 3,
18-
'ddddddd' => 4,
19-
'eeeeee' => 5,
15+
'aaaaaaaa' => 1,
16+
'bbbbbbbb' => 2,
17+
'cccccccc' => 3,
18+
'dddddddd' => 4,
19+
'eeeeeeee' => 5,
20+
'ffffffff' => 6,
2021
];
21-
const SHORT = ['aaaaaaa' => 1, 'bbbbbbb' => 2, 'ccccccc' => 3, 'ddddddd' => 4, 'eeeeee' => 5];
22+
const SHORT = ['aaaaaaaa' => 1, 'bbbbbbbb' => 2, 'cccccccc' => 3, 'dddddddd' => 4, 'eeeeeeee' => 5, 'ffffffff' => 6];
2223

2324
/** @var resource orignal file handle */
2425
private $handle;
2526

2627
public $order = RecursiveIteratorIterator::SELF_FIRST;
2728

2829
public $multilineLong = [
29-
'aaaaaaa' => 1,
30-
'bbbbbbb' => 2,
31-
'ccccccc' => 3,
32-
'ddddddd' => 4,
33-
'eeeeee' => 5,
30+
'aaaaaaaa' => 1,
31+
'bbbbbbbb' => 2,
32+
'cccccccc' => 3,
33+
'dddddddd' => 4,
34+
'eeeeeeee' => 5,
35+
'ffffffff' => 6,
3436
];
3537

36-
public $short = ['aaaaaaa' => 1, 'bbbbbbb' => 2, 'ccccccc' => 3, 'ddddddd' => 4, 'eeeeee' => 5];
38+
public $short = ['aaaaaaaa' => 1, 'bbbbbbbb' => 2, 'cccccccc' => 3, 'dddddddd' => 4, 'eeeeeeee' => 5, 'ffffffff' => 6];
3739

3840

3941
/**
@@ -48,6 +50,7 @@ final class Example extends ParentClass implements IExample
4850
'cccccccccccccc' => 3,
4951
'dddddddddddd' => 4,
5052
'eeeeeeeeeeee' => 5,
53+
'ffffffff' => 6,
5154
];
5255
}
5356

tests/PhpGenerator/expected/Printer.method.expect

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ final public function first(stdClass $var): stdClass
1010
'cccccccccccccc' => 3,
1111
'dddddddddddd' => 4,
1212
'eeeeeeeeeeee' => 5,
13+
'ffffffff' => 6,
1314
];
1415
}

tests/PhpGenerator/expected/PsrPrinter.class.expect

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,30 @@ final class Example extends ParentClass implements IExample
1212
/** Commented */
1313
private const FORCE_ARRAY = Nette\Utils\Json::FORCE_ARRAY;
1414
const MULTILINE_LONG = [
15-
'aaaaaaa' => 1,
16-
'bbbbbbb' => 2,
17-
'ccccccc' => 3,
18-
'ddddddd' => 4,
19-
'eeeeee' => 5,
15+
'aaaaaaaa' => 1,
16+
'bbbbbbbb' => 2,
17+
'cccccccc' => 3,
18+
'dddddddd' => 4,
19+
'eeeeeeee' => 5,
20+
'ffffffff' => 6,
2021
];
21-
const SHORT = ['aaaaaaa' => 1, 'bbbbbbb' => 2, 'ccccccc' => 3, 'ddddddd' => 4, 'eeeeee' => 5];
22+
const SHORT = ['aaaaaaaa' => 1, 'bbbbbbbb' => 2, 'cccccccc' => 3, 'dddddddd' => 4, 'eeeeeeee' => 5, 'ffffffff' => 6];
2223

2324
/** @var resource orignal file handle */
2425
private $handle;
2526

2627
public $order = RecursiveIteratorIterator::SELF_FIRST;
2728

2829
public $multilineLong = [
29-
'aaaaaaa' => 1,
30-
'bbbbbbb' => 2,
31-
'ccccccc' => 3,
32-
'ddddddd' => 4,
33-
'eeeeee' => 5,
30+
'aaaaaaaa' => 1,
31+
'bbbbbbbb' => 2,
32+
'cccccccc' => 3,
33+
'dddddddd' => 4,
34+
'eeeeeeee' => 5,
35+
'ffffffff' => 6,
3436
];
3537

36-
public $short = ['aaaaaaa' => 1, 'bbbbbbb' => 2, 'ccccccc' => 3, 'ddddddd' => 4, 'eeeeee' => 5];
38+
public $short = ['aaaaaaaa' => 1, 'bbbbbbbb' => 2, 'cccccccc' => 3, 'dddddddd' => 4, 'eeeeeeee' => 5, 'ffffffff' => 6];
3739

3840
/**
3941
* @return resource
@@ -47,6 +49,7 @@ final class Example extends ParentClass implements IExample
4749
'cccccccccccccc' => 3,
4850
'dddddddddddd' => 4,
4951
'eeeeeeeeeeee' => 5,
52+
'ffffffff' => 6,
5053
];
5154
}
5255

0 commit comments

Comments
 (0)