1
0
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:
kkmuffme 2023-05-30 16:44:23 +02:00
parent 25c7f37a44
commit 9d7d4bff28
2 changed files with 4 additions and 4 deletions

View File

@ -62,7 +62,7 @@ class DirnameReturnTypeProvider implements FunctionReturnTypeProviderInterface
$statements_source->getCodebase()->config,
);
if ($evaled_path === null && $dir_level === 1) {
if ($evaled_path === null) {
$type = $node_type_provider->getType($call_args[0]->value);
if ($type !== null && $type->isSingle()) {
$atomic_type = array_values($type->getAtomicTypes())[0];

View File

@ -35,18 +35,18 @@ class DirnameTest extends TestCase
],
];
yield 'dirnameOfIntLevelReturnsString' => [
yield 'dirnameOfIntLevelLiteralReturnsLiteral' => [
'code' => '<?php
$dir = dirname("' . $input . '", 10);
',
'assertions' => [
'$dir===' => 'string',
'$dir===' => '.',
],
];
yield 'dirnameOfNonEmptyStringIntLevelOneReturnsNonEmptyString' => [
'code' => '<?php
$dir = dirname(uniqid() . "abc", 1);
$dir = dirname(uniqid() . "abc", 2);
',
'assertions' => [
'$dir===' => 'non-empty-string',