Merge branch '3.4' into 4.2
* 3.4: fix inline handling when dumping tagged values [PropertyAccess] Fix PropertyAccessorCollectionTest Typo in web profiler relax some date parser patterns Avoid getting right to left style
This commit is contained in:
commit
f7d8f1b478
|
@ -663,7 +663,7 @@
|
||||||
</table>
|
</table>
|
||||||
{% else %}
|
{% else %}
|
||||||
<div class="empty">
|
<div class="empty">
|
||||||
<p>No options where passed when constructing this form.</p>
|
<p>No options were passed when constructing this form.</p>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -54,6 +54,7 @@
|
||||||
text-align: left;
|
text-align: left;
|
||||||
text-transform: none;
|
text-transform: none;
|
||||||
z-index: 99999;
|
z-index: 99999;
|
||||||
|
direction: ltr;
|
||||||
|
|
||||||
/* neutralize the aliasing defined by external CSS styles */
|
/* neutralize the aliasing defined by external CSS styles */
|
||||||
-webkit-font-smoothing: subpixel-antialiased;
|
-webkit-font-smoothing: subpixel-antialiased;
|
||||||
|
|
|
@ -33,7 +33,7 @@ class DayTransformer extends Transformer
|
||||||
*/
|
*/
|
||||||
public function getReverseMatchingRegExp(int $length): string
|
public function getReverseMatchingRegExp(int $length): string
|
||||||
{
|
{
|
||||||
return 1 === $length ? '\d{1,2}' : '\d{'.$length.'}';
|
return 1 === $length ? '\d{1,2}' : '\d{1,'.$length.'}';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -104,7 +104,7 @@ class MonthTransformer extends Transformer
|
||||||
$regExp = '[JFMASOND]';
|
$regExp = '[JFMASOND]';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$regExp = '\d{'.$length.'}';
|
$regExp = '\d{1,'.$length.'}';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ class YearTransformer extends Transformer
|
||||||
*/
|
*/
|
||||||
public function getReverseMatchingRegExp(int $length): string
|
public function getReverseMatchingRegExp(int $length): string
|
||||||
{
|
{
|
||||||
return 2 === $length ? '\d{2}' : '\d{4}';
|
return 2 === $length ? '\d{2}' : '\d{1,4}';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -600,6 +600,7 @@ abstract class AbstractIntlDateFormatterTest extends TestCase
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
['y-M-d', '1970-1-1', 0],
|
['y-M-d', '1970-1-1', 0],
|
||||||
|
['y-MM-d', '1970-1-1', 0],
|
||||||
['y-MMM-d', '1970-Jan-1', 0],
|
['y-MMM-d', '1970-Jan-1', 0],
|
||||||
['y-MMMM-d', '1970-January-1', 0],
|
['y-MMMM-d', '1970-January-1', 0],
|
||||||
];
|
];
|
||||||
|
@ -618,6 +619,7 @@ abstract class AbstractIntlDateFormatterTest extends TestCase
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
['y-M-d', '1970-1-1', 0],
|
['y-M-d', '1970-1-1', 0],
|
||||||
|
['y-M-dd', '1970-1-1', 0],
|
||||||
['y-M-dd', '1970-1-01', 0],
|
['y-M-dd', '1970-1-01', 0],
|
||||||
['y-M-ddd', '1970-1-001', 0],
|
['y-M-ddd', '1970-1-001', 0],
|
||||||
];
|
];
|
||||||
|
|
|
@ -183,6 +183,17 @@ class IntlDateFormatterTest extends AbstractIntlDateFormatterTest
|
||||||
return $this->notImplemented(parent::parseQuarterProvider());
|
return $this->notImplemented(parent::parseQuarterProvider());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testParseThreeDigitsYears()
|
||||||
|
{
|
||||||
|
if (PHP_INT_SIZE < 8) {
|
||||||
|
$this->markTestSkipped('Parsing three digits years requires a 64bit PHP.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$formatter = $this->getDefaultDateFormatter('yyyy-M-d');
|
||||||
|
$this->assertSame(-32157648000, $formatter->parse('950-12-19'));
|
||||||
|
$this->assertIsIntlSuccess($formatter, 'U_ZERO_ERROR', IntlGlobals::U_ZERO_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
protected function getDateFormatter($locale, $datetype, $timetype, $timezone = null, $calendar = IntlDateFormatter::GREGORIAN, $pattern = null)
|
protected function getDateFormatter($locale, $datetype, $timetype, $timezone = null, $calendar = IntlDateFormatter::GREGORIAN, $pattern = null)
|
||||||
{
|
{
|
||||||
return new IntlDateFormatter($locale, $datetype, $timetype, $timezone, $calendar, $pattern);
|
return new IntlDateFormatter($locale, $datetype, $timetype, $timezone, $calendar, $pattern);
|
||||||
|
|
|
@ -43,6 +43,28 @@ class PropertyAccessorCollectionTest_Car
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class PropertyAccessorCollectionTest_CarOnlyAdder
|
||||||
|
{
|
||||||
|
public function addAxis($axis)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAxes()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class PropertyAccessorCollectionTest_CarOnlyRemover
|
||||||
|
{
|
||||||
|
public function removeAxis($axis)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAxes()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class PropertyAccessorCollectionTest_CarNoAdderAndRemover
|
class PropertyAccessorCollectionTest_CarNoAdderAndRemover
|
||||||
{
|
{
|
||||||
public function getAxes()
|
public function getAxes()
|
||||||
|
@ -143,25 +165,25 @@ abstract class PropertyAccessorCollectionTest extends PropertyAccessorArrayAcces
|
||||||
|
|
||||||
public function testIsWritableReturnsTrueIfAdderAndRemoverExists()
|
public function testIsWritableReturnsTrueIfAdderAndRemoverExists()
|
||||||
{
|
{
|
||||||
$car = $this->getMockBuilder(__CLASS__.'_Car')->getMock();
|
$car = new PropertyAccessorCollectionTest_Car();
|
||||||
$this->assertTrue($this->propertyAccessor->isWritable($car, 'axes'));
|
$this->assertTrue($this->propertyAccessor->isWritable($car, 'axes'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testIsWritableReturnsFalseIfOnlyAdderExists()
|
public function testIsWritableReturnsFalseIfOnlyAdderExists()
|
||||||
{
|
{
|
||||||
$car = $this->getMockBuilder(__CLASS__.'_CarOnlyAdder')->getMock();
|
$car = new PropertyAccessorCollectionTest_CarOnlyAdder();
|
||||||
$this->assertFalse($this->propertyAccessor->isWritable($car, 'axes'));
|
$this->assertFalse($this->propertyAccessor->isWritable($car, 'axes'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testIsWritableReturnsFalseIfOnlyRemoverExists()
|
public function testIsWritableReturnsFalseIfOnlyRemoverExists()
|
||||||
{
|
{
|
||||||
$car = $this->getMockBuilder(__CLASS__.'_CarOnlyRemover')->getMock();
|
$car = new PropertyAccessorCollectionTest_CarOnlyRemover();
|
||||||
$this->assertFalse($this->propertyAccessor->isWritable($car, 'axes'));
|
$this->assertFalse($this->propertyAccessor->isWritable($car, 'axes'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testIsWritableReturnsFalseIfNoAdderNorRemoverExists()
|
public function testIsWritableReturnsFalseIfNoAdderNorRemoverExists()
|
||||||
{
|
{
|
||||||
$car = $this->getMockBuilder(__CLASS__.'_CarNoAdderAndRemover')->getMock();
|
$car = new PropertyAccessorCollectionTest_CarNoAdderAndRemover();
|
||||||
$this->assertFalse($this->propertyAccessor->isWritable($car, 'axes'));
|
$this->assertFalse($this->propertyAccessor->isWritable($car, 'axes'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,7 +193,7 @@ abstract class PropertyAccessorCollectionTest extends PropertyAccessorArrayAcces
|
||||||
*/
|
*/
|
||||||
public function testSetValueFailsIfAdderAndRemoverExistButValueIsNotTraversable()
|
public function testSetValueFailsIfAdderAndRemoverExistButValueIsNotTraversable()
|
||||||
{
|
{
|
||||||
$car = $this->getMockBuilder(__CLASS__.'_Car')->getMock();
|
$car = new PropertyAccessorCollectionTest_Car();
|
||||||
|
|
||||||
$this->propertyAccessor->setValue($car, 'axes', 'Not an array or Traversable');
|
$this->propertyAccessor->setValue($car, 'axes', 'Not an array or Traversable');
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,8 @@
|
||||||
|
|
||||||
namespace Symfony\Component\Yaml;
|
namespace Symfony\Component\Yaml;
|
||||||
|
|
||||||
|
use Symfony\Component\Yaml\Tag\TaggedValue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dumper dumps PHP variables to YAML strings.
|
* Dumper dumps PHP variables to YAML strings.
|
||||||
*
|
*
|
||||||
|
@ -56,7 +58,7 @@ class Dumper
|
||||||
$dumpObjectAsInlineMap = empty((array) $input);
|
$dumpObjectAsInlineMap = empty((array) $input);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($inline <= 0 || (!\is_array($input) && $dumpObjectAsInlineMap) || empty($input)) {
|
if ($inline <= 0 || (!\is_array($input) && !$input instanceof TaggedValue && $dumpObjectAsInlineMap) || empty($input)) {
|
||||||
$output .= $prefix.Inline::dump($input, $flags);
|
$output .= $prefix.Inline::dump($input, $flags);
|
||||||
} else {
|
} else {
|
||||||
$dumpAsMap = Inline::isHash($input);
|
$dumpAsMap = Inline::isHash($input);
|
||||||
|
@ -75,6 +77,19 @@ class Dumper
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($value instanceof TaggedValue) {
|
||||||
|
$output .= sprintf('%s%s !%s', $prefix, $dumpAsMap ? Inline::dump($key, $flags).':' : '-', $value->getTag());
|
||||||
|
|
||||||
|
if ($inline - 1 <= 0) {
|
||||||
|
$output .= ' '.$this->dump($value->getValue(), $inline - 1, 0, $flags)."\n";
|
||||||
|
} else {
|
||||||
|
$output .= "\n";
|
||||||
|
$output .= $this->dump($value->getValue(), $inline - 1, $dumpAsMap ? $indent + $this->indentation : $indent + 2, $flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$dumpObjectAsInlineMap = true;
|
$dumpObjectAsInlineMap = true;
|
||||||
|
|
||||||
if (Yaml::DUMP_OBJECT_AS_MAP & $flags && ($value instanceof \ArrayObject || $value instanceof \stdClass)) {
|
if (Yaml::DUMP_OBJECT_AS_MAP & $flags && ($value instanceof \ArrayObject || $value instanceof \stdClass)) {
|
||||||
|
|
|
@ -14,6 +14,7 @@ namespace Symfony\Component\Yaml\Tests;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Symfony\Component\Yaml\Dumper;
|
use Symfony\Component\Yaml\Dumper;
|
||||||
use Symfony\Component\Yaml\Parser;
|
use Symfony\Component\Yaml\Parser;
|
||||||
|
use Symfony\Component\Yaml\Tag\TaggedValue;
|
||||||
use Symfony\Component\Yaml\Yaml;
|
use Symfony\Component\Yaml\Yaml;
|
||||||
|
|
||||||
class DumperTest extends TestCase
|
class DumperTest extends TestCase
|
||||||
|
@ -368,6 +369,94 @@ outer2:
|
||||||
inner2: c
|
inner2: c
|
||||||
inner3: { deep1: d, deep2: e }
|
inner3: { deep1: d, deep2: e }
|
||||||
|
|
||||||
|
YAML;
|
||||||
|
$this->assertSame($expected, $yaml);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testDumpingTaggedValueSequenceRespectsInlineLevel()
|
||||||
|
{
|
||||||
|
$data = [
|
||||||
|
new TaggedValue('user', [
|
||||||
|
'username' => 'jane',
|
||||||
|
]),
|
||||||
|
new TaggedValue('user', [
|
||||||
|
'username' => 'john',
|
||||||
|
]),
|
||||||
|
];
|
||||||
|
|
||||||
|
$yaml = $this->dumper->dump($data, 2);
|
||||||
|
|
||||||
|
$expected = <<<YAML
|
||||||
|
- !user
|
||||||
|
username: jane
|
||||||
|
- !user
|
||||||
|
username: john
|
||||||
|
|
||||||
|
YAML;
|
||||||
|
$this->assertSame($expected, $yaml);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testDumpingTaggedValueSequenceWithInlinedTagValues()
|
||||||
|
{
|
||||||
|
$data = [
|
||||||
|
new TaggedValue('user', [
|
||||||
|
'username' => 'jane',
|
||||||
|
]),
|
||||||
|
new TaggedValue('user', [
|
||||||
|
'username' => 'john',
|
||||||
|
]),
|
||||||
|
];
|
||||||
|
|
||||||
|
$yaml = $this->dumper->dump($data, 1);
|
||||||
|
|
||||||
|
$expected = <<<YAML
|
||||||
|
- !user { username: jane }
|
||||||
|
- !user { username: john }
|
||||||
|
|
||||||
|
YAML;
|
||||||
|
$this->assertSame($expected, $yaml);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testDumpingTaggedValueMapRespectsInlineLevel()
|
||||||
|
{
|
||||||
|
$data = [
|
||||||
|
'user1' => new TaggedValue('user', [
|
||||||
|
'username' => 'jane',
|
||||||
|
]),
|
||||||
|
'user2' => new TaggedValue('user', [
|
||||||
|
'username' => 'john',
|
||||||
|
]),
|
||||||
|
];
|
||||||
|
|
||||||
|
$yaml = $this->dumper->dump($data, 2);
|
||||||
|
|
||||||
|
$expected = <<<YAML
|
||||||
|
user1: !user
|
||||||
|
username: jane
|
||||||
|
user2: !user
|
||||||
|
username: john
|
||||||
|
|
||||||
|
YAML;
|
||||||
|
$this->assertSame($expected, $yaml);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testDumpingTaggedValueMapWithInlinedTagValues()
|
||||||
|
{
|
||||||
|
$data = [
|
||||||
|
'user1' => new TaggedValue('user', [
|
||||||
|
'username' => 'jane',
|
||||||
|
]),
|
||||||
|
'user2' => new TaggedValue('user', [
|
||||||
|
'username' => 'john',
|
||||||
|
]),
|
||||||
|
];
|
||||||
|
|
||||||
|
$yaml = $this->dumper->dump($data, 1);
|
||||||
|
|
||||||
|
$expected = <<<YAML
|
||||||
|
user1: !user { username: jane }
|
||||||
|
user2: !user { username: john }
|
||||||
|
|
||||||
YAML;
|
YAML;
|
||||||
$this->assertSame($expected, $yaml);
|
$this->assertSame($expected, $yaml);
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue