[BUGFIX] Respect interfaces as well when checking class existence 12/37412/2
authorHelmut Hummel <helmut.hummel@typo3.org>
Sun, 1 Mar 2015 14:22:48 +0000 (15:22 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sun, 1 Mar 2015 15:15:59 +0000 (16:15 +0100)
As a backwards compatibility measure, the composer class loader
checked for class existence before requiring a class file, which
could only happen if wrong class name casing was used before.

We now enable this also for interfaces.

Releases: master, 6.2
Resolves: #65434
Change-Id: I6dc1dc6cbf8cb7018ceeff1eb881c80658c11e33
Reviewed-on: http://review.typo3.org/37412
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/contrib/vendor/helhum/class-alias-loader/Classes/Composer/ClassAliasLoader.php

index 5def446..7822cf1 100644 (file)
@@ -100,10 +100,7 @@ class ClassAliasLoader {
         */
        public function loadClass($className) {
                if (!$this->caseSensitiveClassLoading) {
-                       $lowerCasedClassName = strtolower($className);
-                       if ($this->composerClassLoader->findFile($lowerCasedClassName)) {
-                               return $this->composerClassLoader->loadClass($lowerCasedClassName);
-                       }
+                       $className = strtolower($className);
                }
                return $this->composerClassLoader->loadClass($className);
        }
@@ -117,9 +114,9 @@ class ClassAliasLoader {
         * @return bool
         */
        protected function loadOriginalClassAndSetAliases($originalClassName) {
-               if (class_exists($originalClassName, false) || $this->loadClass($originalClassName)) {
+               if ($this->classOrInterfaceExists($originalClassName) || $this->loadClass($originalClassName)) {
                        foreach ($this->aliasMap['classNameToAliasMapping'][$originalClassName] as $aliasClassName) {
-                               if (!class_exists($aliasClassName, false)) {
+                               if (!$this->classOrInterfaceExists($aliasClassName)) {
                                        class_alias($originalClassName, $aliasClassName);
                                }
                        }
@@ -129,6 +126,14 @@ class ClassAliasLoader {
        }
 
        /**
+        * @param string $className
+        * @return bool
+        */
+       protected function classOrInterfaceExists($className) {
+               return class_exists($className, false) || interface_exists($className, false);
+       }
+
+       /**
         * Act as a proxy for method calls to composer class loader
         *
         * @param string $method