mirror of
https://github.com/danog/psalm.git
synced 2025-01-22 22:01:48 +01:00
non-empty-string always returs non-empty-string, fix tests
This commit is contained in:
parent
25c7f37a44
commit
9d7d4bff28
@ -62,7 +62,7 @@ class DirnameReturnTypeProvider implements FunctionReturnTypeProviderInterface
|
|||||||
$statements_source->getCodebase()->config,
|
$statements_source->getCodebase()->config,
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($evaled_path === null && $dir_level === 1) {
|
if ($evaled_path === null) {
|
||||||
$type = $node_type_provider->getType($call_args[0]->value);
|
$type = $node_type_provider->getType($call_args[0]->value);
|
||||||
if ($type !== null && $type->isSingle()) {
|
if ($type !== null && $type->isSingle()) {
|
||||||
$atomic_type = array_values($type->getAtomicTypes())[0];
|
$atomic_type = array_values($type->getAtomicTypes())[0];
|
||||||
|
@ -35,18 +35,18 @@ class DirnameTest extends TestCase
|
|||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
yield 'dirnameOfIntLevelReturnsString' => [
|
yield 'dirnameOfIntLevelLiteralReturnsLiteral' => [
|
||||||
'code' => '<?php
|
'code' => '<?php
|
||||||
$dir = dirname("' . $input . '", 10);
|
$dir = dirname("' . $input . '", 10);
|
||||||
',
|
',
|
||||||
'assertions' => [
|
'assertions' => [
|
||||||
'$dir===' => 'string',
|
'$dir===' => '.',
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
yield 'dirnameOfNonEmptyStringIntLevelOneReturnsNonEmptyString' => [
|
yield 'dirnameOfNonEmptyStringIntLevelOneReturnsNonEmptyString' => [
|
||||||
'code' => '<?php
|
'code' => '<?php
|
||||||
$dir = dirname(uniqid() . "abc", 1);
|
$dir = dirname(uniqid() . "abc", 2);
|
||||||
',
|
',
|
||||||
'assertions' => [
|
'assertions' => [
|
||||||
'$dir===' => 'non-empty-string',
|
'$dir===' => 'non-empty-string',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user