From d0d9ef8ad472af2a6c68bf2c51cb4ccf667a1928 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Bundyra?= Date: Tue, 19 Nov 2019 21:54:01 +0000 Subject: [PATCH] Adds PHP 7.4 fn closure surrpot in PSR12.Functions.ReturnTypeDeclaration --- .../PSR12/Sniffs/Functions/ReturnTypeDeclarationSniff.php | 1 + .../PSR12/Tests/Functions/ReturnTypeDeclarationUnitTest.inc | 2 ++ .../Tests/Functions/ReturnTypeDeclarationUnitTest.inc.fixed | 2 ++ .../PSR12/Tests/Functions/ReturnTypeDeclarationUnitTest.php | 1 + 4 files changed, 6 insertions(+) diff --git a/src/Standards/PSR12/Sniffs/Functions/ReturnTypeDeclarationSniff.php b/src/Standards/PSR12/Sniffs/Functions/ReturnTypeDeclarationSniff.php index 82c25d097f..1ea6b3e6f5 100644 --- a/src/Standards/PSR12/Sniffs/Functions/ReturnTypeDeclarationSniff.php +++ b/src/Standards/PSR12/Sniffs/Functions/ReturnTypeDeclarationSniff.php @@ -27,6 +27,7 @@ public function register() return [ T_FUNCTION, T_CLOSURE, + T_FN, ]; }//end register() diff --git a/src/Standards/PSR12/Tests/Functions/ReturnTypeDeclarationUnitTest.inc b/src/Standards/PSR12/Tests/Functions/ReturnTypeDeclarationUnitTest.inc index 45b043f16e..2a68862c32 100644 --- a/src/Standards/PSR12/Tests/Functions/ReturnTypeDeclarationUnitTest.inc +++ b/src/Standards/PSR12/Tests/Functions/ReturnTypeDeclarationUnitTest.inc @@ -60,3 +60,5 @@ function functionName(?string $arg1, ?int &$arg2):?string {} function functionName(?string $arg1, ?int &$arg2): ?string {} function functionName(?string $arg1, ?int &$arg2): ?string {} + +fn (?\DateTime $arg) : ?\DateTime => $arg; diff --git a/src/Standards/PSR12/Tests/Functions/ReturnTypeDeclarationUnitTest.inc.fixed b/src/Standards/PSR12/Tests/Functions/ReturnTypeDeclarationUnitTest.inc.fixed index 531508e75b..827e03c7b4 100644 --- a/src/Standards/PSR12/Tests/Functions/ReturnTypeDeclarationUnitTest.inc.fixed +++ b/src/Standards/PSR12/Tests/Functions/ReturnTypeDeclarationUnitTest.inc.fixed @@ -56,3 +56,5 @@ function functionName(?string $arg1, ?int &$arg2): ?string {} function functionName(?string $arg1, ?int &$arg2): ?string {} function functionName(?string $arg1, ?int &$arg2): ?string {} function functionName(?string $arg1, ?int &$arg2): ?string {} + +fn (?\DateTime $arg): ?\DateTime => $arg; diff --git a/src/Standards/PSR12/Tests/Functions/ReturnTypeDeclarationUnitTest.php b/src/Standards/PSR12/Tests/Functions/ReturnTypeDeclarationUnitTest.php index 7849035e79..fc6b5e19c5 100644 --- a/src/Standards/PSR12/Tests/Functions/ReturnTypeDeclarationUnitTest.php +++ b/src/Standards/PSR12/Tests/Functions/ReturnTypeDeclarationUnitTest.php @@ -37,6 +37,7 @@ protected function getErrorList() 59 => 1, 60 => 1, 62 => 1, + 64 => 1, ]; }//end getErrorList()