Permalink
Browse files

Fix #249: Non namespaced classes trigger notice during autoloading

We bail out early, if a non namespaced class is attempted to be
autoloaded.
  • Loading branch information...
cmb69 committed Jun 17, 2017
1 parent 13fde47 commit a156ad40a45cb8b24600e1856fc7ed2338c4867c
Showing with 13 additions and 0 deletions.
  1. +3 −0 cmsimple/functions.php
  2. +10 −0 tests/unit/AutoloadTest.php
View
@@ -2618,6 +2618,9 @@ function XH_autoload($className)
$className = str_replace('_', '\\', $className);
// set $package, $subpackages and $class
$subpackages = explode('\\', $className);
if (count($subpackages) <= 1) {
return;
}
$packages = array_splice($subpackages, 0, 1);
$package = $packages[0];
$classes = array_splice($subpackages, -1);
@@ -44,6 +44,11 @@ class Bar {}
<?php
namespace Foo;
class Plugin {}
EOT;
const CLASS_FOO = <<<'EOT'
<?php
class Foo{}
EOT;
/**
@@ -99,4 +104,9 @@ public function testNonExistentClass()
{
$this->assertFalse(class_exists(Bar::class));
}
public function testNonNamespacedClassIsNotLoaded()
{
$this->assertFalse(class_exists('\Foo'));
}
}

0 comments on commit a156ad4

Please sign in to comment.