From 67d68383d608862088e44baa3382d205aab62ce1 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Tue, 19 May 2026 14:54:03 +0200 Subject: [PATCH] More precise dirname() return type --- stubs/core.stub | 5 +++++ .../Rules/Constants/data/value-assigned-to-define.php | 1 + 2 files changed, 6 insertions(+) diff --git a/stubs/core.stub b/stubs/core.stub index 9a4d8a711ce..beee073b9d2 100644 --- a/stubs/core.stub +++ b/stubs/core.stub @@ -461,3 +461,8 @@ function proc_open($command, array $descriptor_spec, &$pipes, ?string $cwd = nul * @param-out list $weights */ function getmxrr(string $hostname, &$hosts, &$weights = null): bool {} + +/** + * @return ($path is non-empty-string ? non-empty-string : string) + */ +function dirname(string $path, int $levels = 1): string {} diff --git a/tests/PHPStan/Rules/Constants/data/value-assigned-to-define.php b/tests/PHPStan/Rules/Constants/data/value-assigned-to-define.php index 1bd09e86c64..2503a627485 100644 --- a/tests/PHPStan/Rules/Constants/data/value-assigned-to-define.php +++ b/tests/PHPStan/Rules/Constants/data/value-assigned-to-define.php @@ -12,5 +12,6 @@ define('A_NON_EMPTY_STRING', ''); define('A_NON_EMPTY_STRING', '0'); define('A_NON_EMPTY_STRING', getString()); +define('A_NON_EMPTY_STRING', dirname(__DIR__, 2)); function getString(): string {}