diff --git a/src/functions.php b/src/functions.php index b5f489a1e..08670def2 100644 --- a/src/functions.php +++ b/src/functions.php @@ -16,7 +16,7 @@ function isAbsolutePath($path) $regex = '%^(?(?:[[:print:]]{2,}://)*)'; // Optional root prefix. - $regex .= '(?(?:[[:alpha:]]:/|/)?)'; + $regex .= '(?(?:[[:alpha:]]:[\\\/]|[\\\/])?)'; // Actual path. $regex .= '(?(?:[[:print:]]*))$%'; diff --git a/tests/Config/PluginTest.php b/tests/Config/PluginTest.php index 9604d4504..304f10b39 100644 --- a/tests/Config/PluginTest.php +++ b/tests/Config/PluginTest.php @@ -4,7 +4,6 @@ namespace Psalm\Tests\Config; use function define; use function defined; use const DIRECTORY_SEPARATOR; -use const PHP_OS; use function dirname; use function get_class; use function getcwd; @@ -18,7 +17,6 @@ use Psalm\PluginRegistrationSocket; use Psalm\Tests\Internal\Provider; use Psalm\Tests\TestConfig; use function sprintf; -use function stripos; class PluginTest extends \Psalm\Tests\TestCase { @@ -821,10 +819,6 @@ class PluginTest extends \Psalm\Tests\TestCase */ public function testPluginFilenameCanBeAbsolute() { - if ($this->runningOnWindows()) { - $this->markTestIncomplete('Test fails on Windows - see https://github.com/vimeo/psalm/issues/1913'); - } - $this->project_analyzer = $this->getProjectAnalyzerWithConfig( TestConfig::loadFromXML( dirname(__DIR__, 2) . DIRECTORY_SEPARATOR, @@ -871,9 +865,4 @@ class PluginTest extends \Psalm\Tests\TestCase $this->project_analyzer->getCodebase()->config->initializePlugins($this->project_analyzer); } - - private function runningOnWindows(): bool - { - return stripos(PHP_OS, 'WIN') === 0; - } } diff --git a/tests/IsAbsolutePathTest.php b/tests/IsAbsolutePathTest.php index 4f03a18df..02c63ab7b 100644 --- a/tests/IsAbsolutePathTest.php +++ b/tests/IsAbsolutePathTest.php @@ -29,6 +29,10 @@ class IsAbsolutePathTest extends TestCase ['relative/path/to/something', false], ['relative/path/to/something/file.php', false], ['c:/path/to/something', true], + ['C:\path\to\something', true], + ['C:\path/to\something', true], + ['\path\to\something', true], + ['C:\path/to\..\..\something', true], ['file://c:/path/to/something', true], ['zlib://c:/path/to/something', true], ];