Skip to content

Commit

Permalink
[Config] #7644 add tests for passing number looking attributes as str…
Browse files Browse the repository at this point in the history
…ings
  • Loading branch information
cordoval authored and fabpot committed Apr 20, 2013
1 parent 96251ac commit d98118a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
10 changes: 9 additions & 1 deletion src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php
Expand Up @@ -117,7 +117,15 @@ public function getDataForPhpize()
array(100.0, '1e2'),
array(-120.0, '-1.2E2'),
array(-10100.1, '-10100.1'),
array(-10100.1, '-10,100.1'),
array('-10,100.1', '-10,100.1'),
array('1234 5678 9101 1121 3141', '1234 5678 9101 1121 3141'),
array('1,2,3,4', '1,2,3,4'),
array('11,22,33,44', '11,22,33,44'),
array('11,222,333,4', '11,222,333,4'),
array('1,222,333,444', '1,222,333,444'),
array('11,222,333,444', '11,222,333,444'),
array('111,222,333,444', '111,222,333,444'),
array('1111,2222,3333,4444,5555', '1111,2222,3333,4444,5555'),
array('foo', 'foo'),
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Config/Util/XmlUtils.php
Expand Up @@ -193,8 +193,8 @@ public static function phpize($value)
return false;
case is_numeric($value):
return '0x' == $value[0].$value[1] ? hexdec($value) : floatval($value);
case preg_match('/^(-|\+)?[0-9,]+(\.[0-9]+)?$/', $value):
return floatval(str_replace(',', '', $value));
case preg_match('/^(-|\+)?[0-9]+(\.[0-9]+)?$/', $value):
return floatval($value);
default:
return $value;
}
Expand Down
Expand Up @@ -16,7 +16,7 @@
<parameter>on</parameter>
<parameter>off</parameter>
<parameter key="float">1.3</parameter>
<parameter>1,000.3</parameter>
<parameter>1000.3</parameter>
<parameter>a string</parameter>
<parameter type="collection">
<parameter>foo</parameter>
Expand Down

0 comments on commit d98118a

Please sign in to comment.