123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209 |
- --TEST--
- PHP 7.3 test.
- --RULESET--
- {
- "@Symfony": true,
- "@Symfony:risky": true,
- "@PHP73Migration": true,
- "@PHP71Migration:risky": true,
- "list_syntax": {"syntax": "short"},
- "mb_str_functions": true,
- "method_chaining_indentation": true,
- "multiline_whitespace_before_semicolons": true,
- "native_function_invocation": {"include": ["get_class"]},
- "no_unset_cast": true,
- "no_unset_on_property": true,
- "php_unit_dedicate_assert": true,
- "php_unit_expectation": true,
- "php_unit_mock": true,
- "php_unit_strict": true,
- "php_unit_test_case_static_method_calls": {"call_type": "this"},
- "strict_param": true
- }
- --REQUIREMENTS--
- {"php": 70300, "php<": 80000}
- --EXPECT--
- <?php
- declare(strict_types=1);
- function foo($a = true): void // In PHP 8.0: true, false and null are converted from special-cased constants into reserved keywords.
- {
- }
- $firstKey = array_key_first($items);
- $lastKey = array_key_last($items);
- is_countable($foo);
- // https://wiki.php.net/rfc/list_reference_assignment
- [$a, &$b] = $array; // `list_syntax` rule
- // https://github.com/php/php-src/pull/2978 instanceof now allows literals as the first operand (the result is always false).
- null instanceof stdClass;
- // https://wiki.php.net/rfc/trailing-comma-function-calls Trailing commas in function and method calls are now allowed.
- foo(
- $arg,
- $arg2,
- );
- __DIR__; // `dir_constant` rule
- dirname($path, 3); // `combine_nested_dirname` rule
- $foo->__invoke(1); // `magic_method_casing` rule
- implode('', $pieces); // `implode_call` rule
- implode('', $pieces); // `implode_call` rule
- null === $var; // `is_null` rule
- mb_strpos($a, $b); // `mb_str_functions` rule
- sample('foo', 'foobarbaz', 'baz'); // `method_argument_space` rule
- $user->setEmail('voff.web@gmail.com') // `method_chaining_indentation` rule
- ->setPassword('233434');
- $a = (int) $b; // `modernize_types_casting` rule
- $this->method1() // `multiline_whitespace_before_semicolons` rule
- ->method2(3);
- mb_strlen($str); // `native_function_casing` rule
- $c = \get_class($d); // `native_function_invocation` rule
- $a = rtrim($b); // `no_alias_functions` rule
- $foo->bar($arg1, $arg2); // `no_spaces_inside_parenthesis` rule
- final class MyClass extends PHPUnit_Framework_TestCase
- {
- public function testFoo(): void
- {
- $this->assertTrue($a); // `php_unit_construct` rule
- $this->assertNan($a); // `php_unit_dedicate_assert` rule
- $this->expectException('RuntimeException');
- $this->expectExceptionMessage('Msg');
- $this->expectExceptionCode(123); // `php_unit_expectation` rule
- $this->createMock('Foo'); // `php_unit_mock` rule
- $this->assertSame(1, 2); // `php_unit_test_case_static_method_calls` rule
- $this->assertSame(1, $a, ''); // `php_unit_strict` rule
- }
- }
- $a ** 1; // `pow_to_exponentiation` rule
- random_int($a, $b); // `random_api_migration` rule
- $foo = (int) $foo; // `set_type_to_cast` rule
- in_array($b, $c, true); // `strict_param` rule
- @trigger_error('Warning.', \E_USER_DEPRECATED); // `error_suppression` rule
- foo(null === $a); // `yoda_style` rule
- $a = null; // `no_unset_cast` rule
- $foo->bar = null; // `no_unset_on_property` rule
- // https://wiki.php.net/rfc/flexible_heredoc_nowdoc_syntaxes
- $a = <<<'EOD'
- abc
- def
- ghi
- EOD;
- $a = [<<<'EOD'
- foo
- EOD, <<<'EOD'
- bar
- EOD
- ];
- $a = [
- <<<'EOD'
- foo
- EOD,
- <<<'EOD'
- bar
- EOD,
- ];
- foo(
- <<<'EOD'
- bar
- EOD,
- 'baz'
- );
- --INPUT--
- <?php
- function foo($a = TRUE) // In PHP 8.0: true, false and null are converted from special-cased constants into reserved keywords.
- {
- }
- $firstKey = ARRAY_KEY_FIRST($items);
- $lastKey = ARRAY_Key_last($items);
- IS_COUNTABLE($foo);
- // https://wiki.php.net/rfc/list_reference_assignment
- list($a, &$b) = $array; // `list_syntax` rule
- // https://github.com/php/php-src/pull/2978 instanceof now allows literals as the first operand (the result is always false).
- null instanceof \stdClass;
- // https://wiki.php.net/rfc/trailing-comma-function-calls Trailing commas in function and method calls are now allowed.
- foo(
- $arg,
- $arg2,
- );
- dirname(__FILE__, ); // `dir_constant` rule
- dirname(dirname(dirname($path, ), ), ); // `combine_nested_dirname` rule
- $foo->__INVOKE(1, ); // `magic_method_casing` rule
- implode($pieces, '', ); // `implode_call` rule
- implode($pieces, ); // `implode_call` rule
- is_null($var, ); // `is_null` rule
- strpos($a, $b, ); // `mb_str_functions` rule
- sample('foo', 'foobarbaz', 'baz' , ); // `method_argument_space` rule
- $user->setEmail('voff.web@gmail.com', ) // `method_chaining_indentation` rule
- ->setPassword('233434', );
- $a = intval($b, ); // `modernize_types_casting` rule
- $this->method1() // `multiline_whitespace_before_semicolons` rule
- ->method2(3, )
- ;
- STRLEN($str, ); // `native_function_casing` rule
- $c = get_class($d, ); // `native_function_invocation` rule
- $a = chop($b, ); // `no_alias_functions` rule
- $foo->bar( $arg1, $arg2, );// `no_spaces_inside_parenthesis` rule
- final class MyTest extends \PHPUnit_Framework_TestCase
- {
- public function testFoo(): void
- {
- $this->assertSame(true, $a, ); // `php_unit_construct` rule
- $this->assertTrue(is_nan($a, ), ); // `php_unit_dedicate_assert` rule
- $this->setExpectedException('RuntimeException', 'Msg', 123, ); // `php_unit_expectation` rule
- $this->getMock('Foo', ); // `php_unit_mock` rule
- static::assertSame(1, 2, ); // `php_unit_test_case_static_method_calls` rule
- self::assertEquals(1, $a, '', ); // `php_unit_strict` rule
- }
- }
- pow($a, 1, ); // `pow_to_exponentiation` rule
- rand($a, $b, ); // `random_api_migration` rule
- settype($foo, "integer", ); // `set_type_to_cast` rule
- in_array($b, $c, ); // `strict_param` rule
- trigger_error('Warning.', E_USER_DEPRECATED, ); // `error_suppression` rule
- foo($a === null, ); // `yoda_style` rule
- $a =(unset)$z; // `no_unset_cast` rule
- unset($foo->bar,); // `no_unset_on_property` rule
- // https://wiki.php.net/rfc/flexible_heredoc_nowdoc_syntaxes
- $a = <<<'EOD'
- abc
- def
- ghi
- EOD;
- $a = [<<<'EOD'
- foo
- EOD
- , <<<'EOD'
- bar
- EOD
- ];
- $a = [
- <<<'EOD'
- foo
- EOD
- ,
- <<<'EOD'
- bar
- EOD
- ];
- foo(
- <<<'EOD'
- bar
- EOD
- ,
- 'baz'
- );
|