Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

- Readded check for _config.php in ClassManifest.

- Added UnitTest for files with underscore prefix.
  • Loading branch information...
commit 42f8d9f77a6e13c2b0513d837e1e9a92261bf642 1 parent 7927fff
@AngryPHPNerd AngryPHPNerd authored
View
28 core/manifest/ClassManifest.php
@@ -52,7 +52,7 @@ public static function get_class_parser() {
15 => '{',
));
}
-
+
/**
* @return TokenisedRegularExpression
*/
@@ -78,7 +78,7 @@ public static function get_namespaced_class_parser() {
17 => '{',
));
}
-
+
/**
* @return TokenisedRegularExpression
*/
@@ -92,7 +92,7 @@ public static function get_namespace_parser() {
5 => ';',
));
}
-
+
/**
* @return TokenisedRegularExpression
*/
@@ -103,7 +103,7 @@ public static function get_interface_parser() {
2 => array(T_STRING, 'save_to' => 'interfaceName')
));
}
-
+
/**
* Constructs and initialises a new class manifest, either loading the data
* from the cache or re-scanning for classes.
@@ -243,11 +243,11 @@ public function getImplementorsOf($interface) {
public function getConfigs() {
return $this->configs;
}
-
+
/**
* Returns an array of module names mapped to their paths.
* "Modules" in sapphire are simply directories with a _config.php file.
- *
+ *
* @return array
*/
public function getModules() {
@@ -268,7 +268,7 @@ public function regenerate($cache = true) {
'classes', 'roots', 'children', 'descendants', 'interfaces',
'implementors', 'configs'
);
-
+
// Reset the manifest so stale info doesn't cause errors.
foreach ($reset as $reset) {
$this->$reset = array();
@@ -276,7 +276,7 @@ public function regenerate($cache = true) {
$finder = new ManifestFileFinder();
$finder->setOptions(array(
- 'name_regex' => '/^[^_].*\.php$/',
+ 'name_regex' => '/^(_config.php|[^_].*\.php)$/',
'ignore_files' => array('index.php', 'main.php', 'cli-script.php'),
'ignore_tests' => !$this->tests,
'file_callback' => array($this, 'handleFile')
@@ -328,7 +328,7 @@ public function handleFile($basename, $pathname, $depth) {
$namespace = $data['namespace'];
}
}
-
+
if (!$classes) {
$tokens = token_get_all($file);
if(version_compare(PHP_VERSION, '5.3', '>=')) {
@@ -353,7 +353,7 @@ public function handleFile($basename, $pathname, $depth) {
$name = $namespace . $class['className'];
$extends = isset($class['extends']) ? implode('', $class['extends']) : null;
$implements = isset($class['interfaces']) ? $class['interfaces'] : null;
-
+
if($extends && $extends[0] != '\\') {
$extends = $namespace . $extends;
} elseif($extends) {
@@ -380,7 +380,7 @@ public function handleFile($basename, $pathname, $depth) {
} else {
$this->roots[] = $name;
}
-
+
if ($implements) {
$interface = $namespace;
for($i = 0; $i < count($implements); ++$i) {
@@ -395,7 +395,7 @@ public function handleFile($basename, $pathname, $depth) {
}
if($i == count($implements)-1 || $implements[$i+1] == ',') {
$interface = strtolower($interface);
-
+
if (!isset($this->implementors[$interface])) {
$this->implementors[$interface] = array($name);
} else {
@@ -405,7 +405,7 @@ public function handleFile($basename, $pathname, $depth) {
}
}
}
-
+
foreach ($interfaces as $interface) {
$this->interfaces[strtolower($namespace . $interface['interfaceName'])] = $pathname;
}
@@ -421,7 +421,7 @@ public function handleFile($basename, $pathname, $depth) {
protected function coalesceDescendants($class) {
$result = array();
$lClass = strtolower($class);
-
+
if (array_key_exists($lClass, $this->children)) {
$this->descendants[$lClass] = array();
View
5 tests/core/manifest/ClassManifestTest.php
@@ -105,7 +105,7 @@ public function testGetConfigs() {
$this->assertEquals($expect, $this->manifest->getConfigs());
$this->assertEquals($expect, $this->manifestTests->getConfigs());
}
-
+
public function testGetModules() {
$expect = array("module" => "{$this->base}/module");
$this->assertEquals($expect, $this->manifest->getModules());
@@ -117,4 +117,7 @@ public function testTestManifestIncludesTestClasses() {
$this->assertContains('testclassa', array_keys($this->manifestTests->getClasses()));
}
+ public function testManifestExcludeFilesPrefixedWithUnderscore() {
+ $this->assertNotContains('ignore', array_keys($this->manifest->getClasses()));
+ }
}
View
5 tests/core/manifest/fixtures/classmanifest/module/classes/_Ignore.php
@@ -0,0 +1,5 @@
+<?php
+/**
+ * @ignore
+ */
+class Ignore extends ClassC { }
Please sign in to comment.
Something went wrong with that request. Please try again.