Merge branch '2.8' into 3.2
* 2.8: [DI] use assertStringEqualsFile when possible [VarDumper] Adapt to php 7.2 changes [Form][TwigBridge] Don't render _method in form_rest() for a child form [DoctrineBridge][PropertyInfo] Added support for Doctrine Embeddables [Validator] Fix IbanValidator for ukrainian IBANs
This commit is contained in:
commit
a280e81ebb
@ -50,7 +50,17 @@ class DoctrineExtractor implements PropertyListExtractorInterface, PropertyTypeE
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
return array_merge($metadata->getFieldNames(), $metadata->getAssociationNames());
|
$properties = array_merge($metadata->getFieldNames(), $metadata->getAssociationNames());
|
||||||
|
|
||||||
|
if ($metadata instanceof ClassMetadataInfo && class_exists('Doctrine\ORM\Mapping\Embedded') && $metadata->embeddedClasses) {
|
||||||
|
$properties = array_filter($properties, function ($property) {
|
||||||
|
return false === strpos($property, '.');
|
||||||
|
});
|
||||||
|
|
||||||
|
$properties = array_merge($properties, array_keys($metadata->embeddedClasses));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -105,6 +115,10 @@ class DoctrineExtractor implements PropertyListExtractorInterface, PropertyTypeE
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($metadata instanceof ClassMetadataInfo && class_exists('Doctrine\ORM\Mapping\Embedded') && isset($metadata->embeddedClasses[$property])) {
|
||||||
|
return array(new Type(Type::BUILTIN_TYPE_OBJECT, false, $metadata->embeddedClasses[$property]['class']));
|
||||||
|
}
|
||||||
|
|
||||||
if ($metadata->hasField($property)) {
|
if ($metadata->hasField($property)) {
|
||||||
$typeOfField = $metadata->getTypeOfField($property);
|
$typeOfField = $metadata->getTypeOfField($property);
|
||||||
$nullable = $metadata instanceof ClassMetadataInfo && $metadata->isNullable($property);
|
$nullable = $metadata instanceof ClassMetadataInfo && $metadata->isNullable($property);
|
||||||
|
@ -64,6 +64,21 @@ class DoctrineExtractorTest extends TestCase
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testGetPropertiesWithEmbedded()
|
||||||
|
{
|
||||||
|
if (!class_exists('Doctrine\ORM\Mapping\Embedded')) {
|
||||||
|
$this->markTestSkipped('@Embedded is not available in Doctrine ORM lower than 2.5.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->assertEquals(
|
||||||
|
array(
|
||||||
|
'id',
|
||||||
|
'embedded',
|
||||||
|
),
|
||||||
|
$this->extractor->getProperties('Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineWithEmbedded')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider typesProvider
|
* @dataProvider typesProvider
|
||||||
*/
|
*/
|
||||||
@ -72,6 +87,27 @@ class DoctrineExtractorTest extends TestCase
|
|||||||
$this->assertEquals($type, $this->extractor->getTypes('Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineDummy', $property, array()));
|
$this->assertEquals($type, $this->extractor->getTypes('Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineDummy', $property, array()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testExtractWithEmbedded()
|
||||||
|
{
|
||||||
|
if (!class_exists('Doctrine\ORM\Mapping\Embedded')) {
|
||||||
|
$this->markTestSkipped('@Embedded is not available in Doctrine ORM lower than 2.5.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$expectedTypes = array(new Type(
|
||||||
|
Type::BUILTIN_TYPE_OBJECT,
|
||||||
|
false,
|
||||||
|
'Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineEmbeddable'
|
||||||
|
));
|
||||||
|
|
||||||
|
$actualTypes = $this->extractor->getTypes(
|
||||||
|
'Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineWithEmbedded',
|
||||||
|
'embedded',
|
||||||
|
array()
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertEquals($expectedTypes, $actualTypes);
|
||||||
|
}
|
||||||
|
|
||||||
public function typesProvider()
|
public function typesProvider()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
|
@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures;
|
||||||
|
|
||||||
|
use Doctrine\ORM\Mapping\Column;
|
||||||
|
use Doctrine\ORM\Mapping\Embeddable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Embeddable
|
||||||
|
*
|
||||||
|
* @author Udaltsov Valentin <udaltsov.valentin@gmail.com>
|
||||||
|
*/
|
||||||
|
class DoctrineEmbeddable
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @Column(type="string")
|
||||||
|
*/
|
||||||
|
protected $field;
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures;
|
||||||
|
|
||||||
|
use Doctrine\ORM\Mapping\Column;
|
||||||
|
use Doctrine\ORM\Mapping\Entity;
|
||||||
|
use Doctrine\ORM\Mapping\Id;
|
||||||
|
use Doctrine\ORM\Mapping\Embedded;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Entity
|
||||||
|
*
|
||||||
|
* @author Udaltsov Valentin <udaltsov.valentin@gmail.com>
|
||||||
|
*/
|
||||||
|
class DoctrineWithEmbedded
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @Id
|
||||||
|
* @Column(type="smallint")
|
||||||
|
*/
|
||||||
|
public $id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Embedded(class="DoctrineEmbeddable")
|
||||||
|
*/
|
||||||
|
protected $embedded;
|
||||||
|
}
|
@ -322,7 +322,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
|
|
||||||
{% if not form.methodRendered %}
|
{% if not form.methodRendered and form.parent is null %}
|
||||||
{%- do form.setMethodRendered() -%}
|
{%- do form.setMethodRendered() -%}
|
||||||
{% set method = method|upper %}
|
{% set method = method|upper %}
|
||||||
{%- if method in ["GET", "POST"] -%}
|
{%- if method in ["GET", "POST"] -%}
|
||||||
|
@ -122,13 +122,13 @@ class PhpDumperTest extends TestCase
|
|||||||
// without compilation
|
// without compilation
|
||||||
$container = include self::$fixturesPath.'/containers/container9.php';
|
$container = include self::$fixturesPath.'/containers/container9.php';
|
||||||
$dumper = new PhpDumper($container);
|
$dumper = new PhpDumper($container);
|
||||||
$this->assertEquals(str_replace('%path%', str_replace('\\', '\\\\', self::$fixturesPath.DIRECTORY_SEPARATOR.'includes'.DIRECTORY_SEPARATOR), file_get_contents(self::$fixturesPath.'/php/services9.php')), $dumper->dump(), '->dump() dumps services');
|
$this->assertStringEqualsFile(self::$fixturesPath.'/php/services9.php', str_replace(str_replace('\\', '\\\\', self::$fixturesPath.DIRECTORY_SEPARATOR.'includes'.DIRECTORY_SEPARATOR), '%path%', $dumper->dump()), '->dump() dumps services');
|
||||||
|
|
||||||
// with compilation
|
// with compilation
|
||||||
$container = include self::$fixturesPath.'/containers/container9.php';
|
$container = include self::$fixturesPath.'/containers/container9.php';
|
||||||
$container->compile();
|
$container->compile();
|
||||||
$dumper = new PhpDumper($container);
|
$dumper = new PhpDumper($container);
|
||||||
$this->assertEquals(str_replace('%path%', str_replace('\\', '\\\\', self::$fixturesPath.DIRECTORY_SEPARATOR.'includes'.DIRECTORY_SEPARATOR), file_get_contents(self::$fixturesPath.'/php/services9_compiled.php')), $dumper->dump(), '->dump() dumps services');
|
$this->assertStringEqualsFile(self::$fixturesPath.'/php/services9_compiled.php', str_replace(str_replace('\\', '\\\\', self::$fixturesPath.DIRECTORY_SEPARATOR.'includes'.DIRECTORY_SEPARATOR), '%path%', $dumper->dump()), '->dump() dumps services');
|
||||||
|
|
||||||
$dumper = new PhpDumper($container = new ContainerBuilder());
|
$dumper = new PhpDumper($container = new ContainerBuilder());
|
||||||
$container->register('foo', 'FooClass')->addArgument(new \stdClass());
|
$container->register('foo', 'FooClass')->addArgument(new \stdClass());
|
||||||
|
@ -33,7 +33,7 @@ class IbanValidator extends ConstraintValidator
|
|||||||
* a BBAN (Basic Bank Account Number) which has a fixed length per country and,
|
* a BBAN (Basic Bank Account Number) which has a fixed length per country and,
|
||||||
* included within it, a bank identifier with a fixed position and a fixed length per country
|
* included within it, a bank identifier with a fixed position and a fixed length per country
|
||||||
*
|
*
|
||||||
* @see http://www.swift.com/dsp/resources/documents/IBAN_Registry.pdf
|
* @see https://www.swift.com/sites/default/files/resources/iban_registry.pdf
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
@ -129,7 +129,7 @@ class IbanValidator extends ConstraintValidator
|
|||||||
'TL' => 'TL\d{2}\d{3}\d{14}\d{2}', // Timor-Leste
|
'TL' => 'TL\d{2}\d{3}\d{14}\d{2}', // Timor-Leste
|
||||||
'TN' => 'TN59\d{2}\d{3}\d{13}\d{2}', // Tunisia
|
'TN' => 'TN59\d{2}\d{3}\d{13}\d{2}', // Tunisia
|
||||||
'TR' => 'TR\d{2}\d{5}[\dA-Z]{1}[\dA-Z]{16}', // Turkey
|
'TR' => 'TR\d{2}\d{5}[\dA-Z]{1}[\dA-Z]{16}', // Turkey
|
||||||
'UA' => 'UA\d{2}[A-Z]{6}[\dA-Z]{19}', // Ukraine
|
'UA' => 'UA\d{2}\d{6}[\dA-Z]{19}', // Ukraine
|
||||||
'VG' => 'VG\d{2}[A-Z]{4}\d{16}', // Virgin Islands, British
|
'VG' => 'VG\d{2}[A-Z]{4}\d{16}', // Virgin Islands, British
|
||||||
'WF' => 'FR\d{2}\d{5}\d{5}[\dA-Z]{11}\d{2}', // Wallis and Futuna Islands
|
'WF' => 'FR\d{2}\d{5}\d{5}[\dA-Z]{11}\d{2}', // Wallis and Futuna Islands
|
||||||
'XK' => 'XK\d{2}\d{4}\d{10}\d{2}', // Republic of Kosovo
|
'XK' => 'XK\d{2}\d{4}\d{10}\d{2}', // Republic of Kosovo
|
||||||
|
@ -113,7 +113,7 @@ class IbanValidatorTest extends ConstraintValidatorTestCase
|
|||||||
|
|
||||||
//Extended country list
|
//Extended country list
|
||||||
//http://www.nordea.com/Our+services/International+products+and+services/Cash+Management/IBAN+countries/908462.html
|
//http://www.nordea.com/Our+services/International+products+and+services/Cash+Management/IBAN+countries/908462.html
|
||||||
// http://www.swift.com/dsp/resources/documents/IBAN_Registry.pdf
|
// https://www.swift.com/sites/default/files/resources/iban_registry.pdf
|
||||||
array('AO06000600000100037131174'), //Angola
|
array('AO06000600000100037131174'), //Angola
|
||||||
array('AZ21NABZ00000000137010001944'), //Azerbaijan
|
array('AZ21NABZ00000000137010001944'), //Azerbaijan
|
||||||
array('BH29BMAG1299123456BH00'), //Bahrain
|
array('BH29BMAG1299123456BH00'), //Bahrain
|
||||||
@ -151,6 +151,7 @@ class IbanValidatorTest extends ConstraintValidatorTestCase
|
|||||||
array('TL380080012345678910157'), //Timor-Leste
|
array('TL380080012345678910157'), //Timor-Leste
|
||||||
array('TN5914207207100707129648'), //Tunisia
|
array('TN5914207207100707129648'), //Tunisia
|
||||||
array('TR330006100519786457841326'), //Turkey
|
array('TR330006100519786457841326'), //Turkey
|
||||||
|
array('UA213223130000026007233566001'), //Ukraine
|
||||||
array('AE260211000000230064016'), //United Arab Emirates
|
array('AE260211000000230064016'), //United Arab Emirates
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -263,6 +264,7 @@ class IbanValidatorTest extends ConstraintValidatorTestCase
|
|||||||
array('TL3800800123456789101571'), //Timor-Leste
|
array('TL3800800123456789101571'), //Timor-Leste
|
||||||
array('TN59142072071007071296481'), //Tunisia
|
array('TN59142072071007071296481'), //Tunisia
|
||||||
array('TR3300061005197864578413261'), //Turkey
|
array('TR3300061005197864578413261'), //Turkey
|
||||||
|
array('UA21AAAA1300000260072335660012'), //Ukraine
|
||||||
array('AE2602110000002300640161'), //United Arab Emirates
|
array('AE2602110000002300640161'), //United Arab Emirates
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -372,6 +374,7 @@ class IbanValidatorTest extends ConstraintValidatorTestCase
|
|||||||
array('TL380080012345678910158'), //Timor-Leste
|
array('TL380080012345678910158'), //Timor-Leste
|
||||||
array('TN5914207207100707129649'), //Tunisia
|
array('TN5914207207100707129649'), //Tunisia
|
||||||
array('TR330006100519786457841327'), //Turkey
|
array('TR330006100519786457841327'), //Turkey
|
||||||
|
array('UA213223130000026007233566002'), //Ukraine
|
||||||
array('AE260211000000230064017'), //United Arab Emirates
|
array('AE260211000000230064017'), //United Arab Emirates
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ class Caster
|
|||||||
$combine = false;
|
$combine = false;
|
||||||
$p = array_keys($a);
|
$p = array_keys($a);
|
||||||
foreach ($p as $i => $k) {
|
foreach ($p as $i => $k) {
|
||||||
if (isset($k[0]) && "\0" !== $k[0] && !$reflector->hasProperty($k)) {
|
if (isset($k[0]) ? "\0" !== $k[0] && !$reflector->hasProperty($k) : \PHP_VERSION_ID >= 70200) {
|
||||||
$combine = true;
|
$combine = true;
|
||||||
$p[$i] = self::PREFIX_DYNAMIC.$k;
|
$p[$i] = self::PREFIX_DYNAMIC.$k;
|
||||||
} elseif (isset($k[16]) && "\0" === $k[16] && 0 === strpos($k, "\0class@anonymous\0")) {
|
} elseif (isset($k[16]) && "\0" === $k[16] && 0 === strpos($k, "\0class@anonymous\0")) {
|
||||||
|
@ -139,8 +139,22 @@ EOTXT
|
|||||||
$var[] = &$v;
|
$var[] = &$v;
|
||||||
$var[''] = 2;
|
$var[''] = 2;
|
||||||
|
|
||||||
$this->assertDumpMatchesFormat(
|
if (\PHP_VERSION_ID >= 70200) {
|
||||||
<<<'EOTXT'
|
$this->assertDumpMatchesFormat(
|
||||||
|
<<<'EOTXT'
|
||||||
|
array:4 [
|
||||||
|
0 => {}
|
||||||
|
1 => &1 null
|
||||||
|
2 => &1 null
|
||||||
|
"" => 2
|
||||||
|
]
|
||||||
|
EOTXT
|
||||||
|
,
|
||||||
|
$var
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$this->assertDumpMatchesFormat(
|
||||||
|
<<<'EOTXT'
|
||||||
array:4 [
|
array:4 [
|
||||||
"0" => {}
|
"0" => {}
|
||||||
"1" => &1 null
|
"1" => &1 null
|
||||||
@ -148,9 +162,10 @@ array:4 [
|
|||||||
"" => 2
|
"" => 2
|
||||||
]
|
]
|
||||||
EOTXT
|
EOTXT
|
||||||
,
|
,
|
||||||
$var
|
$var
|
||||||
);
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testObjectCast()
|
public function testObjectCast()
|
||||||
@ -158,16 +173,28 @@ EOTXT
|
|||||||
$var = (object) array(1 => 1);
|
$var = (object) array(1 => 1);
|
||||||
$var->{1} = 2;
|
$var->{1} = 2;
|
||||||
|
|
||||||
$this->assertDumpMatchesFormat(
|
if (\PHP_VERSION_ID >= 70200) {
|
||||||
<<<'EOTXT'
|
$this->assertDumpMatchesFormat(
|
||||||
|
<<<'EOTXT'
|
||||||
|
{
|
||||||
|
+"1": 2
|
||||||
|
}
|
||||||
|
EOTXT
|
||||||
|
,
|
||||||
|
$var
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$this->assertDumpMatchesFormat(
|
||||||
|
<<<'EOTXT'
|
||||||
{
|
{
|
||||||
+1: 1
|
+1: 1
|
||||||
+"1": 2
|
+"1": 2
|
||||||
}
|
}
|
||||||
EOTXT
|
EOTXT
|
||||||
,
|
,
|
||||||
$var
|
$var
|
||||||
);
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testClosedResource()
|
public function testClosedResource()
|
||||||
|
@ -233,7 +233,7 @@ object(Symfony\Component\VarDumper\Cloner\Data)#%i (6) {
|
|||||||
EOTXT;
|
EOTXT;
|
||||||
ob_start();
|
ob_start();
|
||||||
var_dump($clone);
|
var_dump($clone);
|
||||||
$this->assertStringMatchesFormat($expected, ob_get_clean());
|
$this->assertStringMatchesFormat(\PHP_VERSION_ID >= 70200 ? str_replace('"1"', '1', $expected) : $expected, ob_get_clean());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCaster()
|
public function testCaster()
|
||||||
|
Reference in New Issue
Block a user