8000 merged 2.0 · seqally/symfony@a8faa83 · GitHub
[go: up one dir, main page]

Skip to content

Commit a8faa83

Browse files
committed
merged 2.0
2 parents 36f619b + d2d849c commit a8faa83

File tree

16 files changed

+131
-12
lines changed

16 files changed

+131
-12
lines changed

src/Symfony/Bundle/DoctrineBundle/DoctrineBundle.php

Lines changed: 1 addition & 1 deletion
< 8000 /div>
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class_exists('Doctrine\ORM\Mapping\Driver\AnnotationDriver');
4949
$className = substr($class, strlen($namespace) +1);
5050
$file = $dir.DIRECTORY_SEPARATOR.$className.'.php';
5151

52-
if (!is_file($file) && $this->container->getParameter('kernel.debug')) {
52+
if (!is_file($file) && $container->getParameter('kernel.debug')) {
5353
$originalClassName = substr($className, 0, -5);
5454
$registry = $container->get('doctrine');
5555

src/Symfony/Component/Form/Extension/Core/DataTransformer/ScalarToChoiceTransformer.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,25 @@
1313

1414
use Symfony\Component\Form\Util\FormUtil;
1515
use Symfony\Component\Form\DataTransformerInterface;
16+
use Symfony\Component\Form\Exception\UnexpectedTypeException;
1617

1718
class ScalarToChoiceTransformer implements DataTransformerInterface
1819
{
1920
public function transform($value)
2021
{
22+
if (null !== $value && !is_scalar($value)) {
23+
throw new UnexpectedTypeException($value, 'scalar');
24+
}
25+
2126
return FormUtil::toArrayKey($value);
2227
}
2328

2429
public function reverseTransform($value)
2530
{
31+
if (null !== $value && !is_scalar($value)) {
32+
throw new UnexpectedTypeException($value, 'scalar');
33+
}
34+
2635
return $value;
2736
}
2837
}

src/Symfony/Component/Form/Extension/Core/Type/EmailType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class EmailType extends AbstractType
2020
*/
2121
public function getParent(array $options)
2222
{
23-
return 'field';
23+
return 'text';
2424
}
2525

2626
/**

src/Symfony/Component/Form/Extension/Core/Type/TextareaType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class TextareaType extends AbstractType
2020
*/
2121
public function getParent(array $options)
2222
{
23-
return 'field';
23+
return 'text';
2424
}
2525

2626
/**

src/Symfony/Component/Form/Util/FormUtil.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,7 @@ abstract class FormUtil
1515
{
1616
static public function toArrayKey($value)
1717
{
18-
if ((string) (int) $value === (string) $value) {
19-
return (int) $value;
20-
}
21-
22-
if (is_bool($value)) {
18+
if (is_bool($value) || (string) (int) $value === (string) $value) {
2319
return (int) $value;
2420
}
2521

@@ -52,7 +48,7 @@ static public function isChoiceGroup($choice)
5248
*/
5349
static public function isChoiceSelected($choice, $value)
5450
{
55-
$choice = FormUtil::toArrayKey($choice);
51+
$choice = static::toArrayKey($choice);
5652

5753
// The value should already have been converted by value transformers,
5854
// otherwise we had to do the conversion on every call of this method

src/Symfony/Component/HttpFoundation/Request.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1121,7 +1121,7 @@ protected function prepareRequestUri()
11211121
{
11221122
$requestUri = '';
11231123

1124-
if ($this->headers->has('X_REWRITE_URL')) {
1124+
if ($this->headers->has('X_REWRITE_URL') && false !== stripos(PHP_OS, 'WIN')) {
11251125
// check this first so IIS will catch
11261126
$requestUri = $this->headers->get('X_REWRITE_URL');
11271127
} elseif ($this->server->get('IIS_WasUrlRewritten') == '1' && $this->server->get('UNENCODED_URL') != '') {

src/Symfony/Component/Translation/Loader/CsvFileLoader.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ public function load($resource, $locale, $domain = 'messages')
3535
{
3636
$messages = array();
3737

38+
if (!stream_is_local($resource)) {
39+
throw new \InvalidArgumentException(sprintf('This is not a local file "%s".', $resource));
40+
}
41+
3842
try {
3943
$file = new \SplFileObject($resource, 'rb');
4044
} catch(\RuntimeException $e) {

src/Symfony/Component/Translation/Loader/PhpFileLoader.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ class PhpFileLoader extends ArrayLoader implements LoaderInterface
2929
*/
3030
public function load($resource, $locale, $domain = 'messages')
3131
{
32+
if (!stream_is_local($resource)) {
33+
throw new \InvalidArgumentException(sprintf('This is not a local file "%s".', $resource));
34+
}
35+
3236
$messages = require($resource);
3337

3438
$catalogue = parent::load($messages, $locale, $domain);

src/Symfony/Component/Translation/Loader/XliffFileLoader.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ class XliffFileLoader implements LoaderInterface
3030
*/
3131
public function load($resource, $locale, $domain = 'messages')
3232
{
33+
if (!stream_is_local($resource)) {
34+
throw new \InvalidArgumentException(sprintf('This is not a local file "%s".', $resource));
35+
}
36+
3337
$xml = $this->parseFile($resource);
3438
$xml->registerXPathNamespace('xliff', 'urn:oasis:names:tc:xliff:document:1.2');
3539

tests/Symfony/Tests/Component/Form/Extension/Core/DataTransformer/ScalarToChoiceTransformerTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,20 @@ public function testReverseTransform($in, $out)
6262
{
6363
$this->assertSame($out, $this->transformer->transform($in));
6464
}
65+
66+
/**
67+
* @expectedException Symfony\Component\Form\Exception\UnexpectedTypeException
68+
*/
69+
public function testTransformExpectsScalar()
70+
{
71+
$this->transformer->transform(array());
72+
}
73+
74+
/**
75+
* @expectedException Symfony\Component\Form\Exception\UnexpectedTypeException
76+
*/
77+
public function testReverseTransformExpectsScalar()
78+
{
79+
$this->transformer->reverseTransform(array());
80+
}
6581
}

0 commit comments

Comments
 (0)
0