Merge branch '2.8' into 3.2

* 2.8:
  Fixing missing abstract attribute in XmlDumper
  [Form] Remove DateTimeToStringTransformer $parseUsingPipe option
  Fix file perms
  Fixed filename in help text for update-data.php
This commit is contained in:
Fabien Potencier 2017-05-25 15:59:05 -07:00
commit 810623df5e
9 changed files with 35 additions and 92 deletions

View File

@ -200,6 +200,10 @@ class XmlDumper extends Dumper
$service->appendChild($autowiringType);
}
if ($definition->isAbstract()) {
$service->setAttribute('abstract', 'true');
}
if ($callable = $definition->getConfigurator()) {
$configurator = $this->document->createElement('configurator');

View File

@ -171,4 +171,12 @@ class XmlDumperTest extends TestCase
$this->assertEquals(file_get_contents(self::$fixturesPath.'/xml/services24.xml'), $dumper->dump());
}
public function testDumpAbstractServices()
{
$container = include self::$fixturesPath.'/containers/container_abstract.php';
$dumper = new XmlDumper($container);
$this->assertEquals(file_get_contents(self::$fixturesPath.'/xml/services_abstract.xml'), $dumper->dump());
}
}

View File

@ -0,0 +1,12 @@
<?php
use Symfony\Component\DependencyInjection\ContainerBuilder;
$container = new ContainerBuilder();
$container
->register('foo', 'Foo')
->setAbstract(true)
;
return $container;

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<service id="foo" class="Foo" abstract="true"/>
</services>
</container>

0
src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php Executable file → Normal file
View File

0
src/Symfony/Component/Finder/Tests/GlobTest.php Executable file → Normal file
View File

View File

@ -40,15 +40,6 @@ class DateTimeToStringTransformer extends BaseDateTimeTransformer
*/
private $parseFormat;
/**
* Whether to parse by appending a pipe "|" to the parse format.
*
* This only works as of PHP 5.3.7.
*
* @var bool
*/
private $parseUsingPipe;
/**
* Transforms a \DateTime instance to a string.
*
@ -57,16 +48,14 @@ class DateTimeToStringTransformer extends BaseDateTimeTransformer
* @param string $inputTimezone The name of the input timezone
* @param string $outputTimezone The name of the output timezone
* @param string $format The date format
* @param bool $parseUsingPipe Whether to parse by appending a pipe "|" to the parse format
*
* @throws UnexpectedTypeException if a timezone is not a string
*/
public function __construct($inputTimezone = null, $outputTimezone = null, $format = 'Y-m-d H:i:s', $parseUsingPipe = true)
public function __construct($inputTimezone = null, $outputTimezone = null, $format = 'Y-m-d H:i:s')
{
parent::__construct($inputTimezone, $outputTimezone);
$this->generateFormat = $this->parseFormat = $format;
$this->parseUsingPipe = $parseUsingPipe || null === $parseUsingPipe;
// See http://php.net/manual/en/datetime.createfromformat.php
// The character "|" in the format makes sure that the parts of a date
@ -76,7 +65,7 @@ class DateTimeToStringTransformer extends BaseDateTimeTransformer
// where the time corresponds to the current server time.
// With "|" and "Y-m-d", "2010-02-03" becomes "2010-02-03 00:00:00",
// which is at least deterministic and thus used here.
if ($this->parseUsingPipe && false === strpos($this->parseFormat, '|')) {
if (false === strpos($this->parseFormat, '|')) {
$this->parseFormat .= '|';
}
}
@ -145,70 +134,6 @@ class DateTimeToStringTransformer extends BaseDateTimeTransformer
}
try {
// On PHP versions < 5.3.7 we need to emulate the pipe operator
// and reset parts not given in the format to their equivalent
// of the UNIX base timestamp.
if (!$this->parseUsingPipe) {
list($year, $month, $day, $hour, $minute, $second) = explode('-', $dateTime->format('Y-m-d-H-i-s'));
// Check which of the date parts are present in the pattern
preg_match(
'/('.
'(?P<day>[djDl])|'.
'(?P<month>[FMmn])|'.
'(?P<year>[Yy])|'.
'(?P<hour>[ghGH])|'.
'(?P<minute>i)|'.
'(?P<second>s)|'.
'(?P<dayofyear>z)|'.
'(?P<timestamp>U)|'.
'[^djDlFMmnYyghGHiszU]'.
')*/',
$this->parseFormat,
$matches
);
// preg_match() does not guarantee to set all indices, so
// set them unless given
$matches = array_merge(array(
'day' => false,
'month' => false,
'year' => false,
'hour' => false,
'minute' => false,
'second' => false,
'dayofyear' => false,
'timestamp' => false,
), $matches);
// Reset all parts that don't exist in the format to the
// corresponding part of the UNIX base timestamp
if (!$matches['timestamp']) {
if (!$matches['dayofyear']) {
if (!$matches['day']) {
$day = 1;
}
if (!$matches['month']) {
$month = 1;
}
}
if (!$matches['year']) {
$year = 1970;
}
if (!$matches['hour']) {
$hour = 0;
}
if (!$matches['minute']) {
$minute = 0;
}
if (!$matches['second']) {
$second = 0;
}
$dateTime->setDate($year, $month, $day);
$dateTime->setTime($hour, $minute, $second);
}
}
if ($this->inputTimezone !== $this->outputTimezone) {
$dateTime->setTimezone(new \DateTimeZone($this->inputTimezone));
}

View File

@ -118,21 +118,9 @@ class DateTimeToStringTransformerTest extends DateTimeTestCase
/**
* @dataProvider dataProvider
*/
public function testReverseTransformUsingPipe($format, $input, $output)
public function testReverseTransform($format, $input, $output)
{
$reverseTransformer = new DateTimeToStringTransformer('UTC', 'UTC', $format, true);
$output = new \DateTime($output);
$this->assertDateTimeEquals($output, $reverseTransformer->reverseTransform($input));
}
/**
* @dataProvider dataProvider
*/
public function testReverseTransformWithoutUsingPipe($format, $input, $output)
{
$reverseTransformer = new DateTimeToStringTransformer('UTC', 'UTC', $format, false);
$reverseTransformer = new DateTimeToStringTransformer('UTC', 'UTC', $format);
$output = new \DateTime($output);

View File

@ -36,7 +36,7 @@ $argv = $_SERVER['argv'];
if ($argc > 3 || 2 === $argc && '-h' === $argv[1]) {
bailout(<<<'MESSAGE'
Usage: php update-icu-component.php <path/to/icu/source> <path/to/icu/build>
Usage: php update-data.php <path/to/icu/source> <path/to/icu/build>
Updates the ICU data for Symfony to the latest version of ICU.