diff --git a/src/PhpGenerator/Dumper.php b/src/PhpGenerator/Dumper.php index 82a254ee..4155c488 100644 --- a/src/PhpGenerator/Dumper.php +++ b/src/PhpGenerator/Dumper.php @@ -23,7 +23,7 @@ final class Dumper public $maxDepth = 50; /** @var int */ - public $wrapLength = 100; + public $wrapLength = 120; /** diff --git a/tests/PhpGenerator/Closure.long.phpt b/tests/PhpGenerator/Closure.long.phpt index 8a63c28b..4193211d 100644 --- a/tests/PhpGenerator/Closure.long.phpt +++ b/tests/PhpGenerator/Closure.long.phpt @@ -11,7 +11,7 @@ require __DIR__ . '/../bootstrap.php'; $function = new Closure; $function->setBody('return null;'); -for ($name = 'abcde'; $name < 'abcdr'; $name++) { +for ($name = 'abcde'; $name < 'abcdu'; $name++) { $function->addParameter($name); $function->addUse($name); } @@ -30,7 +30,10 @@ same( $abcdn, $abcdo, $abcdp, - $abcdq + $abcdq, + $abcdr, + $abcds, + $abcdt ) use ( $abcde, $abcdf, @@ -44,7 +47,10 @@ same( $abcdn, $abcdo, $abcdp, - $abcdq + $abcdq, + $abcdr, + $abcds, + $abcdt ) { return null; }', (string) $function); diff --git a/tests/PhpGenerator/Dumper.dump().phpt b/tests/PhpGenerator/Dumper.dump().phpt index 562ff769..476c675b 100644 --- a/tests/PhpGenerator/Dumper.dump().phpt +++ b/tests/PhpGenerator/Dumper.dump().phpt @@ -41,12 +41,15 @@ Assert::same('[$s]', $dumper->dump([new PhpLiteral('$s')])); Assert::same('[1, 2, 3]', $dumper->dump([1, 2, 3])); Assert::same("['a', 7 => 'b', 'c', '9a' => 'd', 'e']", $dumper->dump(['a', 7 => 'b', 'c', '9a' => 'd', 9 => 'e'])); + +$dumper->wrapLength = 100; same("[ [ 'a', 'loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong', ], ]", $dumper->dump([['a', 'loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong']])); + Assert::same("['a' => 1, [\"\\r\" => \"\\r\", 2], 3]", $dumper->dump(['a' => 1, ["\r" => "\r", 2], 3])); Assert::same("(object) [\n\t'a' => 1,\n\t'b' => 2,\n]", $dumper->dump((object) ['a' => 1, 'b' => 2])); diff --git a/tests/PhpGenerator/Dumper.format().phpt b/tests/PhpGenerator/Dumper.format().phpt index 84e96196..cceb8894 100644 --- a/tests/PhpGenerator/Dumper.format().phpt +++ b/tests/PhpGenerator/Dumper.format().phpt @@ -20,6 +20,8 @@ Assert::same('func(1 ? 2 : 3)', $dumper->format('func(1 \? 2 : 3)')); Assert::same('func([1, 2])', $dumper->format('func(?)', [1, 2])); Assert::same('func(1, 2)', $dumper->format('func(...?)', [1, 2])); Assert::same('func(1, 2)', $dumper->format('func(?*)', [1, 2])); // old way + +$dumper->wrapLength = 100; same( 'func( 10, diff --git a/tests/PhpGenerator/Printer.phpt b/tests/PhpGenerator/Printer.phpt index f5a20530..a887f1b8 100644 --- a/tests/PhpGenerator/Printer.phpt +++ b/tests/PhpGenerator/Printer.phpt @@ -26,8 +26,8 @@ $class->addConstant('FORCE_ARRAY', new PhpLiteral('Nette\Utils\Json::FORCE_ARRAY ->setVisibility('private') ->addComment('Commented'); -$class->addConstant('MULTILINE_LONG', ['aaaaaaa' => 1, 'bbbbbbb' => 2, 'ccccccc' => 3, 'ddddddd' => 4, 'eeeeee' => 5]); -$class->addConstant('SHORT', ['aaaaaaa' => 1, 'bbbbbbb' => 2, 'ccccccc' => 3, 'ddddddd' => 4, 'eeeeee' => 5]); +$class->addConstant('MULTILINE_LONG', ['aaaaaaaa' => 1, 'bbbbbbbb' => 2, 'cccccccc' => 3, 'dddddddd' => 4, 'eeeeeeee' => 5, 'ffffffff' => 6]); +$class->addConstant('SHORT', ['aaaaaaaa' => 1, 'bbbbbbbb' => 2, 'cccccccc' => 3, 'dddddddd' => 4, 'eeeeeeee' => 5, 'ffffffff' => 6]); $class->addProperty('handle') ->setVisibility('private') @@ -36,14 +36,14 @@ $class->addProperty('handle') $class->addProperty('order') ->setValue(new PhpLiteral('RecursiveIteratorIterator::SELF_FIRST')); -$class->addProperty('multilineLong', ['aaaaaaa' => 1, 'bbbbbbb' => 2, 'ccccccc' => 3, 'ddddddd' => 4, 'eeeeee' => 5]); -$class->addProperty('short', ['aaaaaaa' => 1, 'bbbbbbb' => 2, 'ccccccc' => 3, 'ddddddd' => 4, 'eeeeee' => 5]); +$class->addProperty('multilineLong', ['aaaaaaaa' => 1, 'bbbbbbbb' => 2, 'cccccccc' => 3, 'dddddddd' => 4, 'eeeeeeee' => 5, 'ffffffff' => 6]); +$class->addProperty('short', ['aaaaaaaa' => 1, 'bbbbbbbb' => 2, 'cccccccc' => 3, 'dddddddd' => 4, 'eeeeeeee' => 5, 'ffffffff' => 6]); $class->addMethod('first') ->addComment('@return resource') ->setFinal(true) ->setReturnType('stdClass') - ->setBody("func();\nreturn ?;", [['aaaaaaaaaaaa' => 1, 'bbbbbbbbbbb' => 2, 'cccccccccccccc' => 3, 'dddddddddddd' => 4, 'eeeeeeeeeeee' => 5]]) + ->setBody("func();\nreturn ?;", [['aaaaaaaaaaaa' => 1, 'bbbbbbbbbbb' => 2, 'cccccccccccccc' => 3, 'dddddddddddd' => 4, 'eeeeeeeeeeee' => 5, 'ffffffff' => 6]]) ->addParameter('var') ->setType('stdClass'); diff --git a/tests/PhpGenerator/PsrPrinter.phpt b/tests/PhpGenerator/PsrPrinter.phpt index bec0871c..8dd5b3c8 100644 --- a/tests/PhpGenerator/PsrPrinter.phpt +++ b/tests/PhpGenerator/PsrPrinter.phpt @@ -25,8 +25,8 @@ $class->addConstant('FORCE_ARRAY', new PhpLiteral('Nette\Utils\Json::FORCE_ARRAY ->setVisibility('private') ->addComment('Commented'); -$class->addConstant('MULTILINE_LONG', ['aaaaaaa' => 1, 'bbbbbbb' => 2, 'ccccccc' => 3, 'ddddddd' => 4, 'eeeeee' => 5]); -$class->addConstant('SHORT', ['aaaaaaa' => 1, 'bbbbbbb' => 2, 'ccccccc' => 3, 'ddddddd' => 4, 'eeeeee' => 5]); +$class->addConstant('MULTILINE_LONG', ['aaaaaaaa' => 1, 'bbbbbbbb' => 2, 'cccccccc' => 3, 'dddddddd' => 4, 'eeeeeeee' => 5, 'ffffffff' => 6]); +$class->addConstant('SHORT', ['aaaaaaaa' => 1, 'bbbbbbbb' => 2, 'cccccccc' => 3, 'dddddddd' => 4, 'eeeeeeee' => 5, 'ffffffff' => 6]); $class->addProperty('handle') ->setVisibility('private') @@ -35,14 +35,14 @@ $class->addProperty('handle') $class->addProperty('order') ->setValue(new PhpLiteral('RecursiveIteratorIterator::SELF_FIRST')); -$class->addProperty('multilineLong', ['aaaaaaa' => 1, 'bbbbbbb' => 2, 'ccccccc' => 3, 'ddddddd' => 4, 'eeeeee' => 5]); -$class->addProperty('short', ['aaaaaaa' => 1, 'bbbbbbb' => 2, 'ccccccc' => 3, 'ddddddd' => 4, 'eeeeee' => 5]); +$class->addProperty('multilineLong', ['aaaaaaaa' => 1, 'bbbbbbbb' => 2, 'cccccccc' => 3, 'dddddddd' => 4, 'eeeeeeee' => 5, 'ffffffff' => 6]); +$class->addProperty('short', ['aaaaaaaa' => 1, 'bbbbbbbb' => 2, 'cccccccc' => 3, 'dddddddd' => 4, 'eeeeeeee' => 5, 'ffffffff' => 6]); $class->addMethod('first') ->addComment('@return resource') ->setFinal(true) ->setReturnType('stdClass') - ->setBody("func();\nreturn ?;", [['aaaaaaaaaaaa' => 1, 'bbbbbbbbbbb' => 2, 'cccccccccccccc' => 3, 'dddddddddddd' => 4, 'eeeeeeeeeeee' => 5]]) + ->setBody("func();\nreturn ?;", [['aaaaaaaaaaaa' => 1, 'bbbbbbbbbbb' => 2, 'cccccccccccccc' => 3, 'dddddddddddd' => 4, 'eeeeeeeeeeee' => 5, 'ffffffff' => 6]]) ->addParameter('var') ->setType('stdClass'); diff --git a/tests/PhpGenerator/expected/Printer.class.expect b/tests/PhpGenerator/expected/Printer.class.expect index 624a46b7..9b634582 100644 --- a/tests/PhpGenerator/expected/Printer.class.expect +++ b/tests/PhpGenerator/expected/Printer.class.expect @@ -12,13 +12,14 @@ final class Example extends ParentClass implements IExample /** Commented */ private const FORCE_ARRAY = Nette\Utils\Json::FORCE_ARRAY; const MULTILINE_LONG = [ - 'aaaaaaa' => 1, - 'bbbbbbb' => 2, - 'ccccccc' => 3, - 'ddddddd' => 4, - 'eeeeee' => 5, + 'aaaaaaaa' => 1, + 'bbbbbbbb' => 2, + 'cccccccc' => 3, + 'dddddddd' => 4, + 'eeeeeeee' => 5, + 'ffffffff' => 6, ]; - const SHORT = ['aaaaaaa' => 1, 'bbbbbbb' => 2, 'ccccccc' => 3, 'ddddddd' => 4, 'eeeeee' => 5]; + const SHORT = ['aaaaaaaa' => 1, 'bbbbbbbb' => 2, 'cccccccc' => 3, 'dddddddd' => 4, 'eeeeeeee' => 5, 'ffffffff' => 6]; /** @var resource orignal file handle */ private $handle; @@ -26,14 +27,15 @@ final class Example extends ParentClass implements IExample public $order = RecursiveIteratorIterator::SELF_FIRST; public $multilineLong = [ - 'aaaaaaa' => 1, - 'bbbbbbb' => 2, - 'ccccccc' => 3, - 'ddddddd' => 4, - 'eeeeee' => 5, + 'aaaaaaaa' => 1, + 'bbbbbbbb' => 2, + 'cccccccc' => 3, + 'dddddddd' => 4, + 'eeeeeeee' => 5, + 'ffffffff' => 6, ]; - public $short = ['aaaaaaa' => 1, 'bbbbbbb' => 2, 'ccccccc' => 3, 'ddddddd' => 4, 'eeeeee' => 5]; + public $short = ['aaaaaaaa' => 1, 'bbbbbbbb' => 2, 'cccccccc' => 3, 'dddddddd' => 4, 'eeeeeeee' => 5, 'ffffffff' => 6]; /** @@ -48,6 +50,7 @@ final class Example extends ParentClass implements IExample 'cccccccccccccc' => 3, 'dddddddddddd' => 4, 'eeeeeeeeeeee' => 5, + 'ffffffff' => 6, ]; } diff --git a/tests/PhpGenerator/expected/Printer.method.expect b/tests/PhpGenerator/expected/Printer.method.expect index 6d5d35fb..09412c5f 100644 --- a/tests/PhpGenerator/expected/Printer.method.expect +++ b/tests/PhpGenerator/expected/Printer.method.expect @@ -10,5 +10,6 @@ final public function first(stdClass $var): stdClass 'cccccccccccccc' => 3, 'dddddddddddd' => 4, 'eeeeeeeeeeee' => 5, + 'ffffffff' => 6, ]; } diff --git a/tests/PhpGenerator/expected/PsrPrinter.class.expect b/tests/PhpGenerator/expected/PsrPrinter.class.expect index 790c140c..da79dec9 100644 --- a/tests/PhpGenerator/expected/PsrPrinter.class.expect +++ b/tests/PhpGenerator/expected/PsrPrinter.class.expect @@ -12,13 +12,14 @@ final class Example extends ParentClass implements IExample /** Commented */ private const FORCE_ARRAY = Nette\Utils\Json::FORCE_ARRAY; const MULTILINE_LONG = [ - 'aaaaaaa' => 1, - 'bbbbbbb' => 2, - 'ccccccc' => 3, - 'ddddddd' => 4, - 'eeeeee' => 5, + 'aaaaaaaa' => 1, + 'bbbbbbbb' => 2, + 'cccccccc' => 3, + 'dddddddd' => 4, + 'eeeeeeee' => 5, + 'ffffffff' => 6, ]; - const SHORT = ['aaaaaaa' => 1, 'bbbbbbb' => 2, 'ccccccc' => 3, 'ddddddd' => 4, 'eeeeee' => 5]; + const SHORT = ['aaaaaaaa' => 1, 'bbbbbbbb' => 2, 'cccccccc' => 3, 'dddddddd' => 4, 'eeeeeeee' => 5, 'ffffffff' => 6]; /** @var resource orignal file handle */ private $handle; @@ -26,14 +27,15 @@ final class Example extends ParentClass implements IExample public $order = RecursiveIteratorIterator::SELF_FIRST; public $multilineLong = [ - 'aaaaaaa' => 1, - 'bbbbbbb' => 2, - 'ccccccc' => 3, - 'ddddddd' => 4, - 'eeeeee' => 5, + 'aaaaaaaa' => 1, + 'bbbbbbbb' => 2, + 'cccccccc' => 3, + 'dddddddd' => 4, + 'eeeeeeee' => 5, + 'ffffffff' => 6, ]; - public $short = ['aaaaaaa' => 1, 'bbbbbbb' => 2, 'ccccccc' => 3, 'ddddddd' => 4, 'eeeeee' => 5]; + public $short = ['aaaaaaaa' => 1, 'bbbbbbbb' => 2, 'cccccccc' => 3, 'dddddddd' => 4, 'eeeeeeee' => 5, 'ffffffff' => 6]; /** * @return resource @@ -47,6 +49,7 @@ final class Example extends ParentClass implements IExample 'cccccccccccccc' => 3, 'dddddddddddd' => 4, 'eeeeeeeeeeee' => 5, + 'ffffffff' => 6, ]; }