123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225 |
- --TEST--
- PHP 7.0 test.
- --RULESET--
- {
- "@Symfony": true,
- "ordered_imports": true,
- "random_api_migration": true,
- "visibility_required": {"elements": ["property", "method"]}
- }
- --EXPECT--
- <?php
- // strict types
- declare(strict_types=1);
- // new imports
- use some\a\ClassA;
- use some\a\ClassB;
- use some\a\ClassC as C;
- use const some\a\ConstA;
- use const some\a\ConstB;
- use const some\a\ConstC;
- use function some\a\fn_a;
- use function some\a\fn_b;
- use function some\a\fn_c;
- use some\x\ClassX;
- use function some\x\D;
- use const some\x\E;
- function dummyUsage()
- {
- // class' class const
- echo ClassA::class.ClassB::class.ClassX::class.C::class.E;
- fn_a(fn_b(fn_c()));
- D();
- echo ConstA.ConstB.ConstC;
- }
- interface FooInterface
- {
- }
- class Foo implements FooInterface
- {
- // semi-reserved keyword as const
- const FOR = 1;
- // array const
- const ARR = [1, 2];
- // semi-reserved keyword as function name
- public function list($a, $b)
- {
- // combined comparison operator
- echo $a <=> $b;
- // isset ternary
- echo $a ?? $b;
- // new random generator
- echo mt_rand(0, 1);
- // uniform variable syntax
- $a = ['b' => 'c'];
- $c = 'Next step !';
- echo ${$a['b']};
- // uniform variable syntax on function
- $this->getFnc()();
- }
- // scalar typehinting
- public function bar1(int $a): string
- {
- }
- // scalar typehinting
- public function bar2(int $a): string
- {
- }
- public function getFnc1()
- {
- return function () {
- echo 1;
- };
- }
- public function getFnc2()
- {
- return function () { echo 1; };
- }
- public function gen1()
- {
- yield 1;
- // generator delegation
- yield from $this->gen2();
- }
- public function gen2()
- {
- yield 2;
- }
- }
- // anonymous class
- $message = (new class {});
- $message = (new class implements FooInterface {});
- if (1) {
- $message = (new class extends Foo {
- public function bar()
- {
- echo 1;
- }
- });
- }
- // unicode escape
- echo "\u{26C4}";
- --INPUT--
- <?php
- // strict types
- declare (strict_types = 1);
- // new imports
- use some\a\{ClassA, ClassB, ClassC as C};
- use function some\a\{fn_a, fn_b, fn_c};
- use const some\a\{ConstA, ConstB, ConstC};
- use some\x\{ClassX, function CC as C, function D, const E, function A\B};
- function dummyUsage()
- {
- // class' class const
- echo ClassA::class . ClassB::class . ClassX::class . C::class.E;
- fn_a(fn_b(fn_c())); D();
- echo ConstA . ConstB . ConstC;
- }
- interface FooInterface
- {
- }
- class Foo implements FooInterface
- {
- // semi-reserved keyword as const
- const FOR = 1;
- // array const
- const ARR = array(1, 2);
- // semi-reserved keyword as function name
- public function list($a,$b)
- {
- // combined comparison operator
- echo $a<=>$b;
- // isset ternary
- echo $a??$b;
- // new random generator
- echo rand(0, 1);
- // uniform variable syntax
- $a = array('b' => 'c');
- $c = 'Next step !';
- echo ${$a['b']};
- // uniform variable syntax on function
- $this->getFnc()();
- }
- // scalar typehinting
- public function bar1(int $a):string{}
- // scalar typehinting
- public function bar2(int $a) : string{}
- public function getFnc1()
- {
- return function () {
- echo 1; };
- }
- public function getFnc2()
- {
- return function () { echo 1; };
- }
- public function gen1()
- {
- yield 1;
- // generator delegation
- yield FROM $this->gen2();
- }
- public function gen2()
- {
- yield 2;
- }
- }
- // anonymous class
- $message = (new class {});
- $message = (new class() implements FooInterface {});
- if (1) {
- $message = (new class() extends Foo{ public function bar() { echo 1; } });
- }
- // unicode escape
- echo "\u{26C4}";
|