Minor cleanups and improvements

This commit is contained in:
Javier Eguiluz 2016-09-06 11:23:48 +02:00 committed by Fabien Potencier
parent 42b26411f1
commit e4193c746c
6 changed files with 23 additions and 25 deletions

View File

@ -56,14 +56,12 @@ class RepeatedPass implements CompilerPassInterface
*/ */
public function process(ContainerBuilder $container) public function process(ContainerBuilder $container)
{ {
$this->repeat = false; do {
foreach ($this->passes as $pass) { $this->repeat = false;
$pass->process($container); foreach ($this->passes as $pass) {
} $pass->process($container);
}
if ($this->repeat) { } while ($this->repeat);
$this->process($container);
}
} }
/** /**

View File

@ -130,7 +130,7 @@ class GraphvizDumper extends Dumper
* *
* @return array An array of edges * @return array An array of edges
*/ */
private function findEdges($id, $arguments, $required, $name) private function findEdges($id, array $arguments, $required, $name)
{ {
$edges = array(); $edges = array();
foreach ($arguments as $argument) { foreach ($arguments as $argument) {
@ -246,7 +246,7 @@ class GraphvizDumper extends Dumper
* *
* @return string A comma separated list of attributes * @return string A comma separated list of attributes
*/ */
private function addAttributes($attributes) private function addAttributes(array $attributes)
{ {
$code = array(); $code = array();
foreach ($attributes as $k => $v) { foreach ($attributes as $k => $v) {
@ -263,7 +263,7 @@ class GraphvizDumper extends Dumper
* *
* @return string A space separated list of options * @return string A space separated list of options
*/ */
private function addOptions($options) private function addOptions(array $options)
{ {
$code = array(); $code = array();
foreach ($options as $k => $v) { foreach ($options as $k => $v) {

View File

@ -375,7 +375,7 @@ class PhpDumper extends Dumper
* @throws InvalidArgumentException * @throws InvalidArgumentException
* @throws RuntimeException * @throws RuntimeException
*/ */
private function addServiceInstance($id, $definition) private function addServiceInstance($id, Definition $definition)
{ {
$class = $definition->getClass(); $class = $definition->getClass();
@ -425,7 +425,7 @@ class PhpDumper extends Dumper
* *
* @return bool * @return bool
*/ */
private function isSimpleInstance($id, $definition) private function isSimpleInstance($id, Definition $definition)
{ {
foreach (array_merge(array($definition), $this->getInlinedDefinitions($definition)) as $sDefinition) { foreach (array_merge(array($definition), $this->getInlinedDefinitions($definition)) as $sDefinition) {
if ($definition !== $sDefinition && !$this->hasReference($id, $sDefinition->getMethodCalls())) { if ($definition !== $sDefinition && !$this->hasReference($id, $sDefinition->getMethodCalls())) {
@ -449,7 +449,7 @@ class PhpDumper extends Dumper
* *
* @return string * @return string
*/ */
private function addServiceMethodCalls($id, $definition, $variableName = 'instance') private function addServiceMethodCalls($id, Definition $definition, $variableName = 'instance')
{ {
$calls = ''; $calls = '';
foreach ($definition->getMethodCalls() as $call) { foreach ($definition->getMethodCalls() as $call) {
@ -464,7 +464,7 @@ class PhpDumper extends Dumper
return $calls; return $calls;
} }
private function addServiceProperties($id, $definition, $variableName = 'instance') private function addServiceProperties($id, Definition $definition, $variableName = 'instance')
{ {
$code = ''; $code = '';
foreach ($definition->getProperties() as $name => $value) { foreach ($definition->getProperties() as $name => $value) {
@ -484,7 +484,7 @@ class PhpDumper extends Dumper
* *
* @throws ServiceCircularReferenceException when the container contains a circular reference * @throws ServiceCircularReferenceException when the container contains a circular reference
*/ */
private function addServiceInlinedDefinitionsSetup($id, $definition) private function addServiceInlinedDefinitionsSetup($id, Definition $definition)
{ {
$this->referenceVariables[$id] = new Variable('instance'); $this->referenceVariables[$id] = new Variable('instance');
@ -528,7 +528,7 @@ class PhpDumper extends Dumper
* *
* @return string * @return string
*/ */
private function addServiceConfigurator($id, $definition, $variableName = 'instance') private function addServiceConfigurator($id, Definition $definition, $variableName = 'instance')
{ {
if (!$callable = $definition->getConfigurator()) { if (!$callable = $definition->getConfigurator()) {
return ''; return '';
@ -560,7 +560,7 @@ class PhpDumper extends Dumper
* *
* @return string * @return string
*/ */
private function addService($id, $definition) private function addService($id, Definition $definition)
{ {
$this->definitionVariables = new \SplObjectStorage(); $this->definitionVariables = new \SplObjectStorage();
$this->referenceVariables = array(); $this->referenceVariables = array();
@ -1124,7 +1124,7 @@ EOF;
* *
* @throws InvalidArgumentException * @throws InvalidArgumentException
*/ */
private function exportParameters($parameters, $path = '', $indent = 12) private function exportParameters(array $parameters, $path = '', $indent = 12)
{ {
$php = array(); $php = array();
foreach ($parameters as $key => $value) { foreach ($parameters as $key => $value) {

View File

@ -262,7 +262,7 @@ class XmlDumper extends Dumper
* @param \DOMElement $parent * @param \DOMElement $parent
* @param string $keyAttribute * @param string $keyAttribute
*/ */
private function convertParameters($parameters, $type, \DOMElement $parent, $keyAttribute = 'key') private function convertParameters(array $parameters, $type, \DOMElement $parent, $keyAttribute = 'key')
{ {
$withKeys = array_keys($parameters) !== range(0, count($parameters) - 1); $withKeys = array_keys($parameters) !== range(0, count($parameters) - 1);
foreach ($parameters as $key => $value) { foreach ($parameters as $key => $value) {
@ -311,7 +311,7 @@ class XmlDumper extends Dumper
* *
* @return array * @return array
*/ */
private function escape($arguments) private function escape(array $arguments)
{ {
$args = array(); $args = array();
foreach ($arguments as $k => $v) { foreach ($arguments as $k => $v) {

View File

@ -304,7 +304,7 @@ class YamlDumper extends Dumper
* *
* @return array * @return array
*/ */
private function prepareParameters($parameters, $escape = true) private function prepareParameters(array $parameters, $escape = true)
{ {
$filtered = array(); $filtered = array();
foreach ($parameters as $key => $value) { foreach ($parameters as $key => $value) {
@ -327,7 +327,7 @@ class YamlDumper extends Dumper
* *
* @return array * @return array
*/ */
private function escape($arguments) private function escape(array $arguments)
{ {
$args = array(); $args = array();
foreach ($arguments as $k => $v) { foreach ($arguments as $k => $v) {

View File

@ -386,9 +386,9 @@ class YamlFileLoader extends FileLoader
{ {
if (is_array($value)) { if (is_array($value)) {
$value = array_map(array($this, 'resolveServices'), $value); $value = array_map(array($this, 'resolveServices'), $value);
} elseif (is_string($value) && 0 === strpos($value, '@=')) { } elseif (is_string($value) && 0 === strpos($value, '@=')) {
return new Expression(substr($value, 2)); return new Expression(substr($value, 2));
} elseif (is_string($value) && 0 === strpos($value, '@')) { } elseif (is_string($value) && 0 === strpos($value, '@')) {
if (0 === strpos($value, '@@')) { if (0 === strpos($value, '@@')) {
$value = substr($value, 1); $value = substr($value, 1);
$invalidBehavior = null; $invalidBehavior = null;