mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
Fix issue with slashes after ? in type
This commit is contained in:
parent
aebbd473d9
commit
a30d229040
@ -404,7 +404,7 @@ abstract class Type
|
||||
public static function tokenize($string_type, $ignore_space = true)
|
||||
{
|
||||
// remove all unacceptable characters
|
||||
$string_type = preg_replace('/\?(?=[a-zA-Z])/', 'null|', $string_type);
|
||||
$string_type = preg_replace('/\?(?=[\\\\a-zA-Z])/', 'null|', $string_type);
|
||||
|
||||
$type_tokens = [''];
|
||||
$was_char = false;
|
||||
|
@ -769,6 +769,17 @@ class AnnotationTest extends TestCase
|
||||
'$e' => 'callable():string',
|
||||
],
|
||||
],
|
||||
'slashAfter?' => [
|
||||
'<?php
|
||||
namespace ns;
|
||||
|
||||
/** @param ?\stdClass $s */
|
||||
function foo($s) : void {
|
||||
}
|
||||
|
||||
foo(null);
|
||||
foo(new \stdClass);',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -61,6 +61,14 @@ class TypeParseTest extends TestCase
|
||||
$this->assertSame('null|string', (string) Type::parseString('?string'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testNullableFullyQualified()
|
||||
{
|
||||
$this->assertSame('null|stdClass', (string) Type::parseString('?\\stdClass'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user