Permalink
Browse files

FIX: ConfigStaticManifest not handling multipart namespaces

Fixes #2126
  • Loading branch information...
1 parent 83726b2 commit e55be5078337126fc6c6937c24f992fd1015eba7 @simonwelsh simonwelsh committed Jun 26, 2013
@@ -78,7 +78,8 @@ public function get($class, $name, $default) {
$static = $this->statics[$class][$name];
if ($static['access'] != T_PRIVATE) {
- Deprecation::notice('3.2.0', "Config static $class::\$$name must be marked as private", Deprecation::SCOPE_GLOBAL);
+ Deprecation::notice('3.2.0', "Config static $class::\$$name must be marked as private",
+ Deprecation::SCOPE_GLOBAL);
// Don't warn more than once per static
$this->statics[$class][$name]['access'] = T_PRIVATE;
}
@@ -211,13 +212,23 @@ function parse() {
$class = $next[1];
}
else if($type == T_NAMESPACE) {
- $next = $this->next();
-
- if($next[0] != T_STRING) {
- user_error("Couldn\'t parse {$this->path} when building config static manifest", E_USER_ERROR);
+ $namespace = '';
+ while(true) {
+ $next = $this->next();
+
+ if($next == ';') {
+ break;
+ } elseif($next[0] == T_NS_SEPARATOR) {
+ $namespace .= $next[1];
+ $next = $this->next();
+ }
+
+ if($next[0] != T_STRING) {
+ user_error("Couldn\'t parse {$this->path} when building config static manifest", E_USER_ERROR);
+ }
+
+ $namespace .= $next[1];
}
-
- $namespace = $next[1];
}
else if($type == '{' || $type == T_CURLY_OPEN || $type == T_DOLLAR_OPEN_CURLY_BRACES){
$depth += 1;
@@ -288,7 +299,8 @@ function parseStatic($access, $class) {
$depth -= 1;
}
- // Parse out the assignment side of a static declaration, ending on either a ';' or a ',' outside an array
+ // Parse out the assignment side of a static declaration,
+ // ending on either a ';' or a ',' outside an array
if($type == T_WHITESPACE) {
$value .= ' ';
}
@@ -170,7 +170,8 @@ public function testParsingShortArray() {
return;
}
- $parser = new SS_ConfigStaticManifest_Parser(__DIR__ . '/ConfigStaticManifestTest/ConfigStaticManifestTestMyObject.php');
+ $parser = new SS_ConfigStaticManifest_Parser(__DIR__ .
+ '/ConfigStaticManifestTest/ConfigStaticManifestTestMyObject.php');
$parser->parse();
$statics = $parser->getStatics();
@@ -182,4 +183,19 @@ public function testParsingShortArray() {
$this->assertEquals($expectedValue, $statics['ConfigStaticManifestTestMyObject']['db']['value']);
}
+
+ public function testParsingNamespacesclass() {
+ $parser = new SS_ConfigStaticManifest_Parser(__DIR__ .
+ '/ConfigStaticManifestTest/ConfigStaticManifestTestNamespace.php');
+ $parser->parse();
+
+ $statics = $parser->getStatics();
+
+ $expectedValue = array(
+ 'Name' => 'Varchar',
+ 'Description' => 'Text',
+ );
+
+ $this->assertEquals($expectedValue, $statics['config\staticmanifest\NamespaceTest']['db']['value']);
+ }
}
@@ -0,0 +1,10 @@
+<?php
+
+namespace config\staticmanifest;
+
+class NamespaceTest implements \TestOnly {
+ static private $db = array(
+ 'Name' => 'Varchar',
+ 'Description' => 'Text',
+ );
+}

0 comments on commit e55be50

Please sign in to comment.