mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
FIX: ConfigStaticManifest not handling multipart namespaces
Fixes #2126
This commit is contained in:
parent
83726b21a2
commit
e55be50783
@ -78,7 +78,8 @@ class SS_ConfigStaticManifest {
|
|||||||
$static = $this->statics[$class][$name];
|
$static = $this->statics[$class][$name];
|
||||||
|
|
||||||
if ($static['access'] != T_PRIVATE) {
|
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
|
// Don't warn more than once per static
|
||||||
$this->statics[$class][$name]['access'] = T_PRIVATE;
|
$this->statics[$class][$name]['access'] = T_PRIVATE;
|
||||||
}
|
}
|
||||||
@ -211,13 +212,23 @@ class SS_ConfigStaticManifest_Parser {
|
|||||||
$class = $next[1];
|
$class = $next[1];
|
||||||
}
|
}
|
||||||
else if($type == T_NAMESPACE) {
|
else if($type == T_NAMESPACE) {
|
||||||
$next = $this->next();
|
$namespace = '';
|
||||||
|
while(true) {
|
||||||
|
$next = $this->next();
|
||||||
|
|
||||||
if($next[0] != T_STRING) {
|
if($next == ';') {
|
||||||
user_error("Couldn\'t parse {$this->path} when building config static manifest", E_USER_ERROR);
|
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){
|
else if($type == '{' || $type == T_CURLY_OPEN || $type == T_DOLLAR_OPEN_CURLY_BRACES){
|
||||||
$depth += 1;
|
$depth += 1;
|
||||||
@ -288,7 +299,8 @@ class SS_ConfigStaticManifest_Parser {
|
|||||||
$depth -= 1;
|
$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) {
|
if($type == T_WHITESPACE) {
|
||||||
$value .= ' ';
|
$value .= ' ';
|
||||||
}
|
}
|
||||||
|
@ -170,7 +170,8 @@ DOC;
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$parser = new SS_ConfigStaticManifest_Parser(__DIR__ . '/ConfigStaticManifestTest/ConfigStaticManifestTestMyObject.php');
|
$parser = new SS_ConfigStaticManifest_Parser(__DIR__ .
|
||||||
|
'/ConfigStaticManifestTest/ConfigStaticManifestTestMyObject.php');
|
||||||
$parser->parse();
|
$parser->parse();
|
||||||
|
|
||||||
$statics = $parser->getStatics();
|
$statics = $parser->getStatics();
|
||||||
@ -182,4 +183,19 @@ DOC;
|
|||||||
|
|
||||||
$this->assertEquals($expectedValue, $statics['ConfigStaticManifestTestMyObject']['db']['value']);
|
$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',
|
||||||
|
);
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user