[BUGFIX] Respect interfaces as well when checking class existence 13/37413/2
authorHelmut Hummel <helmut.hummel@typo3.org>
Sun, 1 Mar 2015 14:23:33 +0000 (15:23 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sun, 1 Mar 2015 15:17:17 +0000 (16:17 +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/37413
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 5bfa485..7822cf1 100644 (file)
@@ -114,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);
                                }
                        }
@@ -126,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