From d688d5fd740ac1073ae56a8faf4e14edbd595a38 Mon Sep 17 00:00:00 2001 From: Matt Brown Date: Wed, 4 Nov 2020 12:30:02 -0500 Subject: [PATCH] Add support for @return never --- .../Expression/Call/ArgumentAnalyzer.php | 2 +- src/Psalm/Internal/Type/TypeTokenizer.php | 1 + src/Psalm/Type/Atomic.php | 1 + tests/ClassTest.php | 11 ++++++++++- tests/ReturnTypeTest.php | 17 +++++++++++++++++ 5 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentAnalyzer.php index db6796081..3ac817033 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentAnalyzer.php @@ -137,7 +137,7 @@ class ArgumentAnalyzer $gt_count = 0; foreach ($values as $value) { - $ord = ord($value); + $ord = \ord($value); if ($ord > $prev_ord) { $gt_count++; diff --git a/src/Psalm/Internal/Type/TypeTokenizer.php b/src/Psalm/Internal/Type/TypeTokenizer.php index 441fff4cd..8d6ee17d0 100644 --- a/src/Psalm/Internal/Type/TypeTokenizer.php +++ b/src/Psalm/Internal/Type/TypeTokenizer.php @@ -62,6 +62,7 @@ class TypeTokenizer 'no-return' => true, 'never-return' => true, 'never-returns' => true, + 'never' => true, 'array-key' => true, 'key-of' => true, 'value-of' => true, diff --git a/src/Psalm/Type/Atomic.php b/src/Psalm/Type/Atomic.php index dda8d85a9..7c941b15e 100644 --- a/src/Psalm/Type/Atomic.php +++ b/src/Psalm/Type/Atomic.php @@ -136,6 +136,7 @@ abstract class Atomic implements TypeNode case 'never-return': case 'never-returns': + case 'never': case 'no-return': return new TNever(); diff --git a/tests/ClassTest.php b/tests/ClassTest.php index 39b1d6611..f691d99e5 100644 --- a/tests/ClassTest.php +++ b/tests/ClassTest.php @@ -483,17 +483,25 @@ class ClassTest extends TestCase ], 'resourceAndNumericSoftlyReserved' => [ ' [ diff --git a/tests/ReturnTypeTest.php b/tests/ReturnTypeTest.php index ac1c8dcf0..95d8dfaf9 100644 --- a/tests/ReturnTypeTest.php +++ b/tests/ReturnTypeTest.php @@ -594,6 +594,23 @@ class ReturnTypeTest extends TestCase foo(); }', ], + 'noReturnCallReturnsNever' => [ + ' [ '