From 866a9a387f7f5c0b33c91fc62a6b1fda53e25165 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20FIDRY?= Date: Sat, 7 Oct 2017 13:29:59 +0200 Subject: [PATCH] Account for PHP case-insensitiveness (#118) --- specs/misc.php | 37 +++++++++++++++++++ .../Collection/UseStmtCollection.php | 9 +---- 2 files changed, 39 insertions(+), 7 deletions(-) diff --git a/specs/misc.php b/specs/misc.php index 56786f35..c50d1e5a 100644 --- a/specs/misc.php +++ b/specs/misc.php @@ -41,4 +41,41 @@ PHP , + + [ + 'spec' => <<<'SPEC' +When resolving fully qualified class names, keep in mind that classes are case insensitive in PHP. +SPEC + , + 'payload' => <<<'PHP' +getFirst(); + $name = strtolower($node->getFirst()); $useStatements = $this->nodes[(string) $namespaceName] ?? []; foreach ($useStatements as $use_) { foreach ($use_->uses as $useStatement) { if ($useStatement instanceof UseUse) { - if ($name === $useStatement->alias) { + if ($name === strtolower($useStatement->alias)) { // Match the alias return $useStatement->name; } elseif (null !== $useStatement->alias) { continue; } - - if ($name === $useStatement->name->getLast() && $useStatement->alias === null) { - // Match a simple use statement - return $useStatement->name; - } } } }