8000 Merge branch '2.3' into 2.7 · symfony/symfony@eb23f05 · GitHub
[go: up one dir, main page]

Skip to content

Commit eb23f05

Browse files
Merge branch '2.3' into 2.7
* 2.3: [travis] Disable hirak/prestissimo for deps=low/high tests [HttpFoundation] fix phpdoc of UploadedFile [ci] Skip dns-sensitive tests when DnsMock is not found Optimize ReplaceAliasByActualDefinitionPass [Process] use __METHOD__ where applicable Conflicts: .travis.yml src/Symfony/Component/DependencyInjection/Compiler/ReplaceAliasByActualDefinitionPass.php src/Symfony/Component/Process/Process.php src/Symfony/Component/Process/ProcessBuilder.php
2 parents 83bb723 + 1314365 commit eb23f05

File tree

9 files changed

+118
-124
lines changed

9 files changed

+118
-124
lines changed

.composer/composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"require": {
3-
"php": ">=5.3.7",
4-
"hirak/prestissimo": "^0.1.15"
3+
"hirak/prestissimo": "^0.1.18"
54
}
65
}

.composer/composer.lock

Lines changed: 3 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.travis.yml

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -35,44 +35,46 @@ cache:
3535
services: mongodb
3636

3737
before_install:
38+
- PHP=$TRAVIS_PHP_VERSION
3839
# Matrix lines for intermediate PHP versions are skipped for pull requests
39-
- if [[ ! $deps && ! $TRAVIS_PHP_VERSION = ${MIN_PHP%.*} && $TRAVIS_PHP_VERSION != hhvm && $TRAVIS_PULL_REQUEST != false ]]; then deps=skip; fi;
40+
- if [[ ! $deps && ! $PHP = ${MIN_PHP%.*} && $PHP != hhvm && $TRAVIS_PULL_REQUEST != false ]]; then deps=skip; skip=1; fi
4041
# A sigchild-enabled-PHP is used to test the Process component on the lowest PHP matrix line
41-
- if [[ ! $deps && $TRAVIS_PHP_VERSION = ${MIN_PHP%.*} && ! -d php-$MIN_PHP/sapi ]]; then wget http://museum.php.net/php5/php-$MIN_PHP.tar.bz2 -O - | tar -xj; (cd php-$MIN_PHP; ./configure --enable-sigchild --enable-pcntl; make -j2); fi;
42-
- if [[ $TRAVIS_PHP_VERSION != hhvm ]]; then INI_FILE=~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini; else INI_FILE=/etc/hhvm/php.ini; fi;
43-
- echo memory_limit = -1 >> $INI_FILE
44-
- echo session.gc_probability = 0 >> $INI_FILE
45-
- if [[ $TRAVIS_PHP_VERSION = 5.* ]]; then echo extension = mongo.so >> $INI_FILE; fi;
46-
- if [[ $TRAVIS_PHP_VERSION = 5.* ]]; then echo extension = memcache.so >> $INI_FILE; fi;
47-
- if [[ $TRAVIS_PHP_VERSION = 5.* ]]; then (echo yes | pecl install -f apcu-4.0.10 && echo apc.enable_cli = 1 >> $INI_FILE); fi;
48-
- if [[ $TRAVIS_PHP_VERSION = 7.* ]]; then (echo yes | pecl install -f apcu-5.1.2 && echo apc.enable_cli = 1 >> $INI_FILE); fi;
49-
- if [[ $TRAVIS_PHP_VERSION = 5.* && ! $deps ]]; then (cd src/Symfony/Component/Debug/Resources/ext && phpize && ./configure && make && echo extension = $(pwd)/modules/symfony_debug.so >> $INI_FILE); fi;
50-
- if [[ $TRAVIS_PHP_VERSION = 5.* ]]; then pecl install -f memcached-2.1.0; fi;
51-
- if [[ $TRAVIS_PHP_VERSION != hhvm ]]; then echo extension = ldap.so >> $INI_FILE; fi;
52-
- if [[ $TRAVIS_PHP_VERSION != hhvm ]]; then phpenv config-rm xdebug.ini; fi;
53-
- if [[ $deps != skip ]]; then composer self-update; fi;
54-
- if [[ $deps != skip && $TRAVIS_REPO_SLUG = symfony/symfony ]]; then cp .composer/* ~/.composer/; composer global install; fi;
55-
- if [[ $deps != skip ]]; then ./phpunit install; fi;
56-
- export PHPUNIT=$(readlink -f ./phpunit)
42+
- if [[ ! $deps && $PHP = ${MIN_PHP%.*} && ! -d php-$MIN_PHP/sapi ]]; then wget http://museum.php.net/php5/php-$MIN_PHP.tar.bz2 -O - | tar -xj; (cd php-$MIN_PHP; ./configure --enable-sigchild --enable-pcntl; make -j2); fi
43+
- if [[ $PHP != hhvm ]]; then INI_FILE=~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini; else INI_FILE=/etc/hhvm/php.ini; fi
44+
- if [[ ! $skip ]]; then echo memory_limit = -1 >> $INI_FILE; fi
45+
- if [[ ! $skip ]]; then echo session.gc_probability = 0 >> $INI_FILE; fi
46+
- if [[ ! $skip && $PHP = 5.* ]]; then echo extension = mongo.so >> $INI_FILE; fi
47+
- if [[ ! $skip && $PHP = 5.* ]]; then echo extension = memcache.so >> $INI_FILE; fi
48+
- if [[ ! $skip && $PHP = 5.* ]]; then (echo yes | pecl install -f apcu-4.0.10 && echo apc.enable_cli = 1 >> $INI_FILE); fi
49+
- if [[ ! $skip && $PHP = 7.* ]]; then (echo yes | pecl install -f apcu-5.1.2 && echo apc.enable_cli = 1 >> $INI_FILE); fi
50+
- if [[ ! $deps && $PHP = 5.* ]]; then (cd src/Symfony/Component/Debug/Resources/ext && phpize && ./configure && make && echo extension = $(pwd)/modules/symfony_debug.so >> $INI_FILE); fi
51+
- if [[ ! $skip && $PHP = 5.* ]]; then pecl install -f memcached-2.1.0; fi
52+
- if [[ ! $skip && $PHP != hhvm ]]; then echo extension = ldap.so >> $INI_FILE; fi
53+
- if [[ ! $skip && $PHP != hhvm ]]; then phpenv config-rm xdebug.ini; fi
54+
- if [[ ! $skip ]]; then composer self-update; fi
55+
- if [[ ! $skip ]]; then cp .composer/* ~/.composer/; composer global install; fi
56+
- if [[ ! $skip ]]; then ./phpunit install; fi
57+
- if [[ ! $skip && $deps ]]; then composer global remove hirak/prestissimo; fi
58+
- if [[ ! $skip ]]; then export PHPUNIT=$(readlink -f ./phpunit); fi
5759

5860
install:
59-
- if [[ $deps != skip ]]; then COMPONENTS=$(find src/Symfony -mindepth 3 -type f -name phpunit.xml.dist -printf '%h\n'); fi;
61+
- if [[ ! $skip ]]; then COMPONENTS=$(find src/Symfony -mindepth 3 -type f -name phpunit.xml.dist -printf '%h\n'); fi
6062
# Create local composer packages for each patched components and reference them in composer.json files when cross-testing components
61-
- if [[ $deps != skip && $deps ]]; then php .travis.php $TRAVIS_COMMIT_RANGE $TRAVIS_BRANCH $COMPONENTS; fi;
63+
- if [[ ! $skip && $deps ]]; then php .travis.php $TRAVIS_COMMIT_RANGE $TRAVIS_BRANCH $COMPONENTS; fi
6264
# For the master branch when deps=high, the version before master is checked out and tested with the locally patched components
63-
- if [[ $deps = high && $TRAVIS_BRANCH = master ]]; then SYMFONY_VERSION=$(git ls-remote --heads | grep -o '/[1-9].*' | tail -n 1 | sed s/.//); else SYMFONY_VERSION=$(cat composer.json | grep '^ *"dev-master". *"[1-9]' | grep -o '[0-9.]*'); fi;
64-
- if [[ $deps = high && $TRAVIS_BRANCH = master ]]; then git fetch origin $SYMFONY_VERSION; git checkout -m FETCH_HEAD; COMPONENTS=$(find src/Symfony -mindepth 3 -type f -name phpunit.xml.dist -printf '%h\n'); ./phpunit install; fi;
65+
- if [[ $deps = high && $TRAVIS_BRANCH = master ]]; then SYMFONY_VERSION=$(git ls-remote --heads | grep -o '/[1-9].*' | tail -n 1 | sed s/.//); else SYMFONY_VERSION=$(cat composer.json | grep '^ *"dev-master". *"[1-9]' | grep -o '[0-9.]*'); fi
66+
- if [[ $deps = high && $TRAVIS_BRANCH = master ]]; then git fetch origin $SYMFONY_VERSION; git checkout -m FETCH_HEAD; COMPONENTS=$(find src/Symfony -mindepth 3 -type f -name phpunit.xml.dist -printf '%h\n'); ./phpunit install; fi
6567
# Legacy tests are skipped when deps=high and when the current branch version has not the same major version number than the next one
66-
- if [[ $deps = high && ${SYMFONY_VERSION%.*} != $(git show $(git ls-remote --heads | grep -FA1 /$SYMFONY_VERSION | tail -n 1):composer.json | grep '^ *"dev-master". *"[1-9]' | grep -o '[0-9]*' | head -n 1) ]]; then LEGACY=,legacy; fi;
67-
- export COMPOSER_ROOT_VERSION=$SYMFONY_VERSION.x-dev;
68-
- if [[ ! $deps ]]; then composer update; else export SYMFONY_DEPRECATIONS_HELPER=weak; fi;
69-
- if [[ $TRAVIS_BRANCH = master ]]; then export SYMFONY_PHPUNIT_OVERLOAD=1; fi;
70-
- if [[ $TRAVIS_PHP_VERSION != hhvm ]]; then php -i; else hhvm --php -r 'print_r($_SERVER);print_r(ini_get_all());'; fi;
68+
- if [[ $deps = high && ${SYMFONY_VERSION%.*} != $(git show $(git ls-remote --heads | grep -FA1 /$SYMFONY_VERSION | tail -n 1):composer.json | grep '^ *"dev-master". *"[1-9]' | grep -o '[0-9]*' | head -n 1) ]]; then LEGACY=,legacy; fi
69+
- export COMPOSER_ROOT_VERSION=$SYMFONY_VERSION.x-dev
70+
- if [[ ! $deps ]]; then composer update; else export SYMFONY_DEPRECATIONS_HELPER=weak; fi
71+
- if [[ $TRAVIS_BRANCH = master ]]; then export SYMFONY_PHPUNIT_OVERLOAD=1; fi
72+
- if [[ $PHP != hhvm ]]; then php -i; else hhvm --php -r 'print_r($_SERVER);print_r(ini_get_all());'; fi
7173

7274
script:
73-
- if [[ ! $deps ]]; then echo "$COMPONENTS" | parallel --gnu '$PHPUNIT --exclude-group tty,benchmark,intl-data {}'; fi;
74-
- if [[ ! $deps ]]; then echo -e "\\nRunning tests requiring tty"; $PHPUNIT --group tty; fi;
75-
- if [[ ! $deps && $TRAVIS_PHP_VERSION = ${MIN_PHP%.*} ]]; then echo -e "1\\n0" | xargs -I{} sh -c 'echo "\\nPHP --enable-sigchild enhanced={}" && ENHANCE_SIGCHLD={} php-$MIN_PHP/sapi/cli/php .phpunit/phpunit-4.8/phpunit --colors=always src/Symfony/Component/Process/'; fi;
76-
- if [[ $deps = high ]]; then echo "$COMPONENTS" | parallel --gnu -j10% 'cd {}; composer update; $PHPUNIT --exclude-group tty,benchmark,intl-data'$LEGACY; fi;
77-
- if [[ $deps = low ]]; then echo "$COMPONENTS" | parallel --gnu -j10% 'cd {}; composer update --prefer-lowest --prefer-stable; $PHPUNIT --exclude-group tty,benchmark,intl-data'; fi;
78-
- if [[ $deps = skip ]]; then echo This matrix line is skipped for pull requests.; fi;
75+
- if [[ $skip ]]; then echo -e "\\n\\e[1;34mIntermediate PHP version $PHP is skipped for pull requests.\\e[0m"; fi
76+
- if [[ ! $deps ]]; then echo "$COMPONENTS" | parallel --gnu '$PHPUNIT --exclude-group tty,benchmark,intl-data {}'; fi
77+
- if [[ ! $deps ]]; then echo -e "\\nRunning tests requiring tty"; $PHPUNIT --group tty; fi
78+
- if [[ ! $deps && $PHP = ${MIN_PHP%.*} ]]; then echo -e "1\\n0" | xargs -I{} sh -c 'echo "\\nPHP --enable-sigchild enhanced={}" && ENHANCE_SIGCHLD={} php-$MIN_PHP/sapi/cli/php .phpunit/phpunit-4.8/phpunit --colors=always src/Symfony/Component/Process/'; fi
79+
- if [[ $deps = high ]]; then echo "$COMPONENTS" | parallel --gnu -j10% 'cd {}; composer update --no-progress --ansi; $PHPUNIT --exclude-group tty,benchmark,intl-data'$LEGACY; fi
80+
- if [[ $deps = low ]]; then echo "$COMPONENTS" | parallel --gnu -j10% 'cd {}; composer update --no-progress --ansi --prefer-lowest --prefer-stable; $PHPUNIT --exclude-group tty,benchmark,intl-data'; fi

appveyor.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ install:
5353
- copy /Y php.ini-max php.ini
5454
- cd c:\projects\symfony
5555
- mkdir %APPDATA%\Composer
56-
- IF %APPVEYOR_REPO_NAME%==symfony/symfony copy /Y .composer\* %APPDATA%\Composer\
57-
- IF %APPVEYOR_REPO_NAME%==symfony/symfony composer global install --no-progress --ansi || echo curl.cainfo needs PHP 5.3.7
56+
- copy /Y .composer\* %APPDATA%\Composer\
57+
- composer global install --no-progress --ansi
5858
- php phpunit install
5959
- IF %APPVEYOR_REPO_BRANCH%==master (SET COMPOSER_ROOT_VERSION=dev-master) ELSE (SET COMPOSER_ROOT_VERSION=%APPVEYOR_REPO_BRANCH%.x-dev)
6060
- composer update --no-progress --ansi

src/Symfony/Component/DependencyInjection/Compiler/ReplaceAliasByActualDefinitionPass.php

Lines changed: 65 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ class ReplaceAliasByActualDefinitionPass implements CompilerPassInterface
2525
{
2626
private $compiler;
2727
private $formatter;
28-
private $sourceId;
2928

3029
/**
3130
* Process the Container to replace aliases with service definitions.
@@ -36,118 +35,110 @@ class ReplaceAliasByActualDefinitionPass implements CompilerPassInterface
3635
*/
3736
public function process(ContainerBuilder $container)
3837
{
38+
// Setup
3939
$this->compiler = $container->getCompiler();
4040
$this->formatter = $this->compiler->getLoggingFormatter();
41-
42-
foreach ($container->getAliases() as $id => $alias) {
43-
$aliasId = (string) $alias;
44-
45-
if ('service_container' === $aliasId) {
41+
// First collect all alias targets that need to be replaced
42+
$seenAliasTargets = array();
43+
$replacements = array();
44+
foreach ($container->getAliases() as $definitionId => $target) {
45+
$targetId = (string) $target;
46+
// Special case: leave this target alone
47+
if ('service_container' === $targetId) {
4648
continue;
4749
}
48-
50+
// Check if target needs to be replaces
51+
if (isset($replacements[$targetId])) {
52+
$container->setAlias($definitionId, $replacements[$targetId]);
53+
}
54+
// No neeed to process the same target twice
55+
if (isset($seenAliasTargets[$targetId])) {
56+
continue;
57+
}
58+
// Process new target
59+
$seenAliasTargets[$targetId] = true;
4960
try {
50-
$definition = $container->getDefinition($aliasId);
61+
$definition = $container->getDefinition($targetId);
5162
} catch (InvalidArgumentException $e) {
52-
throw new InvalidArgumentException(sprintf('Unable to replace alias "%s" with actual definition "%s".', $id, $alias), null, $e);
63+
throw new InvalidArgumentException(sprintf('Unable to replace alias "%s" with actual definition "%s".', $definitionId, $targetId), null, $e);
5364
}
54-
5565
if ($definition->isPublic()) {
5666
continue;
5767
}
58-
68+
// Remove private definition and schedule for replacement
5969
$definition->setPublic(true);
60-
$container->setDefinition($id, $definition);
61-
$container->removeDefinition($aliasId);
62-
63-
$this->updateReferences($container, $aliasId, $id);
64-
65-
// we have to restart the process due to concurrent modification of
66-
// the container
67-
$this->process($container);
68-
69-
break;
70+
$container->setDefinition($definitionId, $definition);
71+
$container->removeDefinition($targetId);
72+
$replacements[$targetId] = $definitionId;
7073
}
71-
}
7274

73-
/**
74-
* Updates references to remove aliases.
75-
*
76-
* @param ContainerBuilder $container The container
77-
* @param string $currentId The alias identifier being replaced
78-
* @param string $newId The id of the service the alias points to
79-
*/
80-
private function updateReferences($container, $currentId, $newId)
81-
{
82-
foreach ($container->getAliases() as $id => $alias) {
83-
if ($currentId === (string) $alias) {
84-
$container->setAlias($id, $newId);
85-
}
86-
}
87-
88-
foreach ($container->getDefinitions() as $id => $definition) {
89-
$this->sourceId = $id;
90-
91-
$definition->setArguments(
92-
$this->updateArgumentReferences($definition->getArguments(), $currentId, $newId)
93-
);
94-
95-
$definition->setMethodCalls(
96-
$this->updateArgumentReferences($definition->getMethodCalls(), $currentId, $newId)
97-
);
98-
99-
$definition->setProperties(
100-
$this->updateArgumentReferences($definition->getProperties(), $currentId, $newId)
101-
);
102-
103-
$definition->setFactoryService($this->updateFactoryServiceReference($definition->getFactoryService(false), $currentId, $newId), false);
104-
$definition->setFactory($this->updateFactoryReference($definition->getFactory(), $currentId, $newId));
75+
// Now replace target instances in all definitions
76+
foreach ($container->getDefinitions() as $definitionId => $definition) {
77+
$definition->setArguments($this->updateArgumentReferences($replacements, $definitionId, $definition->getArguments()));
78+
$definition->setMethodCalls($this->updateArgumentReferences($replacements, $definitionId, $definition->getMethodCalls()));
79+
$definition->setProperties($this->updateArgumentReferences($replacements, $definitionId, $definition->getProperties()));
80+
$definition->setFactoryService($this->updateFactoryReferenceId($replacements, $definition->getFactoryService(false)), false);
81+
$definition->setFactory($this->updateFactoryReference($replacements, $definition->getFactory()));
10582
}
10683
}
10784

10885
/**
109-
* Updates argument references.
86+
* Recursively updates references in an array.
11087
*
111-
* @param array $arguments An array of Arguments
112-
* @param string $currentId The alias identifier
113-
* @param string $newId The identifier the alias points to
88+
* @param array $replacements Table of aliases to replace
89+
* @param string $definitionId Identifier of this definition
90+
* @param array $arguments Where to replace the aliases
11491
*
11592
* @return array
11693
*/
117-
private function updateArgumentReferences(array $arguments, $currentId, $newId)
94+
private function updateArgumentReferences(array $replacements, $definitionId, array $arguments)
11895
{
11996
foreach ($arguments as $k => $argument) {
97+
// Handle recursion step
12098
if (is_array($argument)) {
121-
$arguments[$k] = $this->updateArgumentReferences($argument, $currentId, $newId);
122-
} elseif ($argument instanceof Reference) {
123-
if ($currentId === (string) $argument) {
124-
$arguments[$k] = new Reference($newId, $argument->getInvalidBehavior());
125-
$this->compiler->addLogMessage($this->formatter->formatUpdateReference($this, $this->sourceId, $currentId, $newId));
126-
}
99+
$arguments[$k] = $this->updateArgumentReferences($replacements, $definitionId, $argument);
100+
continue;
101+
}
102+
// Skip arguments that don't need replacement
103+
if (!$argument instanceof Reference) {
104+
continue;
105+
}
106+
$referenceId = (string) $argument;
107+
if (!isset($replacements[$referenceId])) {
108+
continue;
127109
}
110+
// Perform the replacement
111+
$newId = $replacements[$referenceId];
112+
$arguments[$k] = new Reference($newId, $argument->getInvalidBehavior());
113+
$this->compiler->addLogMessage($this->formatter->formatUpdateReference($this, $definitionId, $referenceId, $newId));
128114
}
129115

130116
return $arguments;
131117
}
132118

133-
private function updateFactoryServiceReference($factoryService, $currentId, $newId)
119+
/**
120+
* Returns the updated reference for the factory service.
121+
*
122+
* @param array $replacements Table of aliases to replace
123+
* @param string|null $referenceId Factory service reference identifier
124+
*
125+
* @return string|null
126+
*/
127+
private function updateFactoryReferenceId(array $replacements, $referenceId)
134128
{
135-
if (null === $factoryService) {
129+
if (null === $referenceId) {
136130
return;
137131
}
138132

139-
return $currentId === $factoryService ? $newId : $factoryService;
133+
return isset($replacements[$referenceId]) ? $replacements[$referenceId] : $referenceId;
140134
}
141135

142-
private function updateFactoryReference($factory, $currentId, $newId)
136+
private function updateFactoryReference(array $replacements, $factory)
143137
{
144-
if (null === $factory || !is_array($factory) || !$factory[0] instanceof Reference) {
145-
return $factory;
138+
if (is_array($factory) && $factory[0] instanceof Reference && isset($replacements[$referenceId = (string) $factory[0]])) {
139+
$factory[0] = new Reference($replacements[$referenceId], $factory[0]->getInvalidBehavior());
146140
}
147141

148-
if ($currentId === (string) $factory[0]) {
149-
$factory[0] = new Reference($newId, $factory[0]->getInvalidBehavior());
150-
}
151142

152143
return $factory;
153144
}

0 commit comments

Comments
 (0)
0