1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-22 05:41:20 +01:00

Add support for @return never

This commit is contained in:
Matt Brown 2020-11-04 12:30:02 -05:00 committed by Daniil Gentili
parent 0f022c711d
commit d688d5fd74
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
5 changed files with 30 additions and 2 deletions

View File

@ -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++;

View File

@ -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,

View File

@ -136,6 +136,7 @@ abstract class Atomic implements TypeNode
case 'never-return':
case 'never-returns':
case 'never':
case 'no-return':
return new TNever();

View File

@ -483,17 +483,25 @@ class ClassTest extends TestCase
],
'resourceAndNumericSoftlyReserved' => [
'<?php
namespace {
class Numeric {}
class Never {}
}
namespace Foo {
class Resource {}
class Numeric {}
class Never {}
}
namespace Bar {
use \Foo\Resource;
use \Foo\Numeric;
use \Foo\Never;
new \Foo\Resource();
new \Foo\Numeric();
new \Foo\Never();
new Resource();
new Numeric();
@ -501,9 +509,10 @@ class ClassTest extends TestCase
/**
* @param Resource $r
* @param Numeric $n
* @param Never $nev
* @return void
*/
function foo(Resource $r, Numeric $n) : void {}
function foo(Resource $r, Numeric $n, Never $nev) : void {}
}'
],
'inheritInterfaceFromParent' => [

View File

@ -594,6 +594,23 @@ class ReturnTypeTest extends TestCase
foo();
}',
],
'noReturnCallReturnsNever' => [
'<?php
namespace Foo;
/**
* @return never
*/
function foo() : void {
exit();
}
/**
* @return never
*/
function bar() : void {
foo();
}',
],
'suppressInvalidReturnType' => [
'<?php
/**