minor #27852 Fix coding standards (stof)
This PR was squashed before being merged into the 2.8 branch (closes #27852). Discussion ---------- Fix coding standards | Q | A | ------------- | --- | Branch? | 2.8 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | n/a This PR is mostly about running the PHP-CS-Fixer (v2.12.1) in the whole codebase. - I updated the exclude rule to avoid some false positives for the `error_suppression` fixer (we have more files triggering unsilenced deprecations on purpose than when building the initial whitelist, mostly). - I ran the fixer with this updated config. Most changes were related to fully-qualifying some constants, with the new fixer implemented in https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/3127, for which @nicolas-grekas and I suggested a config to include in the Symfony ruleset. Based on the output, I suggested a feature request in https://github.com/FriendsOfPHP/PHP-CS-Fixer/issues/3872 as we might want to avoid the `\` in non-namespaced files to improve readability. We might want to remove the second commit of this PR if we decide to wait for the feature to be implemented (update: implementation is contributed in https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/3876) - I added the `native_function_invocation` fixer explicitly, to automatically fully-qualify calls to compiler-optimized functions. This feature was implemented in PHP-CS-Fixer based on our feature request (as currently, we do such thing only manually in some hot path, because it could not be automated). I opened https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/3873 to include it in the ruleset automatically. TODOs: - [x] agree on the updated rules - [x] update fabbot to use the new version of PHP-CS-Fixer - [ ] make separate PRs for newer branches with their own updates (exclude rules, and CS fixes), once this PR gets merged. Commits -------538c69dc26
Fix Clidumper tests04654cfeb3
Enable the fixer enforcing fully-qualified calls for compiler-optimized functionsf00b3279ea
Apply fixers720ed4d379
Disable the native_constant_invocation fixer until it can be scoped8892b98627
Update the list of excluded files for the CS fixer
This commit is contained in:
commit
82d13dae31
10
.php_cs.dist
10
.php_cs.dist
@ -15,6 +15,10 @@ return PhpCsFixer\Config::create()
|
|||||||
// rule disabled due to https://bugs.php.net/bug.php?id=60573 bug;
|
// rule disabled due to https://bugs.php.net/bug.php?id=60573 bug;
|
||||||
// to be re-enabled (by dropping next line, rule is part of @Symfony already) on branch that requires PHP 5.4+
|
// to be re-enabled (by dropping next line, rule is part of @Symfony already) on branch that requires PHP 5.4+
|
||||||
'self_accessor' => false,
|
'self_accessor' => false,
|
||||||
|
// TODO remove the disabling once https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/3876 is merged and released
|
||||||
|
'native_constant_invocation' => false,
|
||||||
|
// Part of @Symfony:risky in PHP-CS-Fixer 2.13.0. To be removed from the config file once upgrading
|
||||||
|
'native_function_invocation' => array('include' => array('@compiler_optimized'), 'scope' => 'namespaced'),
|
||||||
))
|
))
|
||||||
->setRiskyAllowed(true)
|
->setRiskyAllowed(true)
|
||||||
->setFinder(
|
->setFinder(
|
||||||
@ -32,7 +36,11 @@ return PhpCsFixer\Config::create()
|
|||||||
'Symfony/Component/VarDumper/Tests/Fixtures',
|
'Symfony/Component/VarDumper/Tests/Fixtures',
|
||||||
// resource templates
|
// resource templates
|
||||||
'Symfony/Bundle/FrameworkBundle/Resources/views/Form',
|
'Symfony/Bundle/FrameworkBundle/Resources/views/Form',
|
||||||
|
// explicit trigger_error tests
|
||||||
|
'Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/',
|
||||||
))
|
))
|
||||||
|
// Support for older PHPunit version
|
||||||
|
->notPath('Symfony/Bridge/PhpUnit/SymfonyTestsListener.php')
|
||||||
// file content autogenerated by `var_export`
|
// file content autogenerated by `var_export`
|
||||||
->notPath('Symfony/Component/Translation/Tests/fixtures/resources.php')
|
->notPath('Symfony/Component/Translation/Tests/fixtures/resources.php')
|
||||||
// test template
|
// test template
|
||||||
@ -40,8 +48,6 @@ return PhpCsFixer\Config::create()
|
|||||||
// explicit heredoc test
|
// explicit heredoc test
|
||||||
->notPath('Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Resources/views/translation.html.php')
|
->notPath('Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Resources/views/translation.html.php')
|
||||||
// explicit trigger_error tests
|
// explicit trigger_error tests
|
||||||
->notPath('Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/default.phpt')
|
|
||||||
->notPath('Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/weak.phpt')
|
|
||||||
->notPath('Symfony/Component/Debug/Tests/DebugClassLoaderTest.php')
|
->notPath('Symfony/Component/Debug/Tests/DebugClassLoaderTest.php')
|
||||||
)
|
)
|
||||||
;
|
;
|
||||||
|
@ -54,7 +54,7 @@ class ContainerAwareEventManager extends EventManager
|
|||||||
$initialized = isset($this->initialized[$eventName]);
|
$initialized = isset($this->initialized[$eventName]);
|
||||||
|
|
||||||
foreach ($this->listeners[$eventName] as $hash => $listener) {
|
foreach ($this->listeners[$eventName] as $hash => $listener) {
|
||||||
if (!$initialized && is_string($listener)) {
|
if (!$initialized && \is_string($listener)) {
|
||||||
$this->listeners[$eventName][$hash] = $listener = $this->container->get($listener);
|
$this->listeners[$eventName][$hash] = $listener = $this->container->get($listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,7 +98,7 @@ class ContainerAwareEventManager extends EventManager
|
|||||||
*/
|
*/
|
||||||
public function addEventListener($events, $listener)
|
public function addEventListener($events, $listener)
|
||||||
{
|
{
|
||||||
if (is_string($listener)) {
|
if (\is_string($listener)) {
|
||||||
if ($this->initialized) {
|
if ($this->initialized) {
|
||||||
throw new \RuntimeException('Adding lazy-loading listeners after construction is not supported.');
|
throw new \RuntimeException('Adding lazy-loading listeners after construction is not supported.');
|
||||||
}
|
}
|
||||||
@ -124,7 +124,7 @@ class ContainerAwareEventManager extends EventManager
|
|||||||
*/
|
*/
|
||||||
public function removeEventListener($events, $listener)
|
public function removeEventListener($events, $listener)
|
||||||
{
|
{
|
||||||
if (is_string($listener)) {
|
if (\is_string($listener)) {
|
||||||
$hash = '_service_'.$listener;
|
$hash = '_service_'.$listener;
|
||||||
} else {
|
} else {
|
||||||
// Picks the hash code related to that listener
|
// Picks the hash code related to that listener
|
||||||
|
@ -120,14 +120,14 @@ class DoctrineDataCollector extends DataCollector
|
|||||||
if (null === $query['params']) {
|
if (null === $query['params']) {
|
||||||
$query['params'] = array();
|
$query['params'] = array();
|
||||||
}
|
}
|
||||||
if (!is_array($query['params'])) {
|
if (!\is_array($query['params'])) {
|
||||||
$query['params'] = array($query['params']);
|
$query['params'] = array($query['params']);
|
||||||
}
|
}
|
||||||
foreach ($query['params'] as $j => $param) {
|
foreach ($query['params'] as $j => $param) {
|
||||||
if (isset($query['types'][$j])) {
|
if (isset($query['types'][$j])) {
|
||||||
// Transform the param according to the type
|
// Transform the param according to the type
|
||||||
$type = $query['types'][$j];
|
$type = $query['types'][$j];
|
||||||
if (is_string($type)) {
|
if (\is_string($type)) {
|
||||||
$type = Type::getType($type);
|
$type = Type::getType($type);
|
||||||
}
|
}
|
||||||
if ($type instanceof Type) {
|
if ($type instanceof Type) {
|
||||||
@ -158,11 +158,11 @@ class DoctrineDataCollector extends DataCollector
|
|||||||
*/
|
*/
|
||||||
private function sanitizeParam($var)
|
private function sanitizeParam($var)
|
||||||
{
|
{
|
||||||
if (is_object($var)) {
|
if (\is_object($var)) {
|
||||||
return array(sprintf('Object(%s)', get_class($var)), false);
|
return array(sprintf('Object(%s)', \get_class($var)), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_array($var)) {
|
if (\is_array($var)) {
|
||||||
$a = array();
|
$a = array();
|
||||||
$original = true;
|
$original = true;
|
||||||
foreach ($var as $k => $v) {
|
foreach ($var as $k => $v) {
|
||||||
@ -174,7 +174,7 @@ class DoctrineDataCollector extends DataCollector
|
|||||||
return array($a, $original);
|
return array($a, $original);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_resource($var)) {
|
if (\is_resource($var)) {
|
||||||
return array(sprintf('Resource(%s)', get_resource_type($var)), false);
|
return array(sprintf('Resource(%s)', get_resource_type($var)), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,7 +142,7 @@ abstract class AbstractDoctrineExtension extends Extension
|
|||||||
*/
|
*/
|
||||||
protected function getMappingDriverBundleConfigDefaults(array $bundleConfig, \ReflectionClass $bundle, ContainerBuilder $container)
|
protected function getMappingDriverBundleConfigDefaults(array $bundleConfig, \ReflectionClass $bundle, ContainerBuilder $container)
|
||||||
{
|
{
|
||||||
$bundleDir = dirname($bundle->getFileName());
|
$bundleDir = \dirname($bundle->getFileName());
|
||||||
|
|
||||||
if (!$bundleConfig['type']) {
|
if (!$bundleConfig['type']) {
|
||||||
$bundleConfig['type'] = $this->detectMetadataDriver($bundleDir, $container);
|
$bundleConfig['type'] = $this->detectMetadataDriver($bundleDir, $container);
|
||||||
@ -154,7 +154,7 @@ abstract class AbstractDoctrineExtension extends Extension
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!$bundleConfig['dir']) {
|
if (!$bundleConfig['dir']) {
|
||||||
if (in_array($bundleConfig['type'], array('annotation', 'staticphp'))) {
|
if (\in_array($bundleConfig['type'], array('annotation', 'staticphp'))) {
|
||||||
$bundleConfig['dir'] = $bundleDir.'/'.$this->getMappingObjectDefaultName();
|
$bundleConfig['dir'] = $bundleDir.'/'.$this->getMappingObjectDefaultName();
|
||||||
} else {
|
} else {
|
||||||
$bundleConfig['dir'] = $bundleDir.'/'.$this->getMappingResourceConfigDirectory();
|
$bundleConfig['dir'] = $bundleDir.'/'.$this->getMappingResourceConfigDirectory();
|
||||||
@ -241,7 +241,7 @@ abstract class AbstractDoctrineExtension extends Extension
|
|||||||
throw new \InvalidArgumentException(sprintf('Specified non-existing directory "%s" as Doctrine mapping source.', $mappingConfig['dir']));
|
throw new \InvalidArgumentException(sprintf('Specified non-existing directory "%s" as Doctrine mapping source.', $mappingConfig['dir']));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!in_array($mappingConfig['type'], array('xml', 'yml', 'annotation', 'php', 'staticphp'))) {
|
if (!\in_array($mappingConfig['type'], array('xml', 'yml', 'annotation', 'php', 'staticphp'))) {
|
||||||
throw new \InvalidArgumentException(sprintf('Can only configure "xml", "yml", "annotation", "php" or '.
|
throw new \InvalidArgumentException(sprintf('Can only configure "xml", "yml", "annotation", "php" or '.
|
||||||
'"staticphp" through the DoctrineBundle. Use your own bundle to configure other metadata drivers. '.
|
'"staticphp" through the DoctrineBundle. Use your own bundle to configure other metadata drivers. '.
|
||||||
'You can register them by adding a new driver to the '.
|
'You can register them by adding a new driver to the '.
|
||||||
@ -264,17 +264,17 @@ abstract class AbstractDoctrineExtension extends Extension
|
|||||||
$configPath = $this->getMappingResourceConfigDirectory();
|
$configPath = $this->getMappingResourceConfigDirectory();
|
||||||
$resource = $dir.'/'.$configPath;
|
$resource = $dir.'/'.$configPath;
|
||||||
while (!is_dir($resource)) {
|
while (!is_dir($resource)) {
|
||||||
$resource = dirname($resource);
|
$resource = \dirname($resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
$container->addResource(new FileResource($resource));
|
$container->addResource(new FileResource($resource));
|
||||||
|
|
||||||
$extension = $this->getMappingResourceExtension();
|
$extension = $this->getMappingResourceExtension();
|
||||||
if (($files = glob($dir.'/'.$configPath.'/*.'.$extension.'.xml')) && count($files)) {
|
if (($files = glob($dir.'/'.$configPath.'/*.'.$extension.'.xml')) && \count($files)) {
|
||||||
return 'xml';
|
return 'xml';
|
||||||
} elseif (($files = glob($dir.'/'.$configPath.'/*.'.$extension.'.yml')) && count($files)) {
|
} elseif (($files = glob($dir.'/'.$configPath.'/*.'.$extension.'.yml')) && \count($files)) {
|
||||||
return 'yml';
|
return 'yml';
|
||||||
} elseif (($files = glob($dir.'/'.$configPath.'/*.'.$extension.'.php')) && count($files)) {
|
} elseif (($files = glob($dir.'/'.$configPath.'/*.'.$extension.'.php')) && \count($files)) {
|
||||||
return 'php';
|
return 'php';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ class DoctrineValidationPass implements CompilerPassInterface
|
|||||||
|
|
||||||
foreach ($container->getParameter('kernel.bundles') as $bundle) {
|
foreach ($container->getParameter('kernel.bundles') as $bundle) {
|
||||||
$reflection = new \ReflectionClass($bundle);
|
$reflection = new \ReflectionClass($bundle);
|
||||||
if (is_file($file = dirname($reflection->getFileName()).'/'.$validationPath)) {
|
if (is_file($file = \dirname($reflection->getFileName()).'/'.$validationPath)) {
|
||||||
$files[] = $file;
|
$files[] = $file;
|
||||||
$container->addResource(new FileResource($file));
|
$container->addResource(new FileResource($file));
|
||||||
}
|
}
|
||||||
|
@ -153,7 +153,7 @@ class RegisterEventListenersAndSubscribersPass implements CompilerPassInterface
|
|||||||
|
|
||||||
if ($sortedTags) {
|
if ($sortedTags) {
|
||||||
krsort($sortedTags);
|
krsort($sortedTags);
|
||||||
$sortedTags = call_user_func_array('array_merge', $sortedTags);
|
$sortedTags = \call_user_func_array('array_merge', $sortedTags);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $sortedTags;
|
return $sortedTags;
|
||||||
|
@ -124,7 +124,7 @@ abstract class RegisterMappingsPass implements CompilerPassInterface
|
|||||||
$this->managerParameters = $managerParameters;
|
$this->managerParameters = $managerParameters;
|
||||||
$this->driverPattern = $driverPattern;
|
$this->driverPattern = $driverPattern;
|
||||||
$this->enabledParameter = $enabledParameter;
|
$this->enabledParameter = $enabledParameter;
|
||||||
if (count($aliasMap) && (!$configurationPattern || !$registerAliasMethodName)) {
|
if (\count($aliasMap) && (!$configurationPattern || !$registerAliasMethodName)) {
|
||||||
throw new \InvalidArgumentException('configurationPattern and registerAliasMethodName are required to register namespace alias');
|
throw new \InvalidArgumentException('configurationPattern and registerAliasMethodName are required to register namespace alias');
|
||||||
}
|
}
|
||||||
$this->configurationPattern = $configurationPattern;
|
$this->configurationPattern = $configurationPattern;
|
||||||
@ -149,7 +149,7 @@ abstract class RegisterMappingsPass implements CompilerPassInterface
|
|||||||
$chainDriverDef->addMethodCall('addDriver', array($mappingDriverDef, $namespace));
|
$chainDriverDef->addMethodCall('addDriver', array($mappingDriverDef, $namespace));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!count($this->aliasMap)) {
|
if (!\count($this->aliasMap)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ class DoctrineChoiceLoader implements ChoiceLoaderInterface
|
|||||||
|
|
||||||
// Optimize performance for single-field identifiers. We already
|
// Optimize performance for single-field identifiers. We already
|
||||||
// know that the IDs are used as values
|
// know that the IDs are used as values
|
||||||
$optimize = null === $value || is_array($value) && $value[0] === $this->idReader;
|
$optimize = null === $value || \is_array($value) && $value[0] === $this->idReader;
|
||||||
|
|
||||||
// Attention: This optimization does not check choices for existence
|
// Attention: This optimization does not check choices for existence
|
||||||
if ($optimize && !$this->choiceList && $this->idReader->isSingleId()) {
|
if ($optimize && !$this->choiceList && $this->idReader->isSingleId()) {
|
||||||
@ -125,7 +125,7 @@ class DoctrineChoiceLoader implements ChoiceLoaderInterface
|
|||||||
|
|
||||||
// Optimize performance in case we have an object loader and
|
// Optimize performance in case we have an object loader and
|
||||||
// a single-field identifier
|
// a single-field identifier
|
||||||
$optimize = null === $value || is_array($value) && $value[0] === $this->idReader;
|
$optimize = null === $value || \is_array($value) && $value[0] === $this->idReader;
|
||||||
|
|
||||||
if ($optimize && !$this->choiceList && $this->objectLoader && $this->idReader->isSingleId()) {
|
if ($optimize && !$this->choiceList && $this->objectLoader && $this->idReader->isSingleId()) {
|
||||||
$unorderedObjects = $this->objectLoader->getEntitiesByIds($this->idReader->getIdField(), $values);
|
$unorderedObjects = $this->objectLoader->getEntitiesByIds($this->idReader->getIdField(), $values);
|
||||||
|
@ -117,7 +117,7 @@ class EntityChoiceList extends ObjectChoiceList
|
|||||||
$this->entityLoader = $entityLoader;
|
$this->entityLoader = $entityLoader;
|
||||||
$this->classMetadata = $manager->getClassMetadata($class);
|
$this->classMetadata = $manager->getClassMetadata($class);
|
||||||
$this->class = $this->classMetadata->getName();
|
$this->class = $this->classMetadata->getName();
|
||||||
$this->loaded = is_array($entities) || $entities instanceof \Traversable;
|
$this->loaded = \is_array($entities) || $entities instanceof \Traversable;
|
||||||
$this->preferredEntities = $preferredEntities;
|
$this->preferredEntities = $preferredEntities;
|
||||||
list(
|
list(
|
||||||
$this->idAsIndex,
|
$this->idAsIndex,
|
||||||
@ -449,13 +449,13 @@ class EntityChoiceList extends ObjectChoiceList
|
|||||||
|
|
||||||
$identifiers = $classMetadata->getIdentifierFieldNames();
|
$identifiers = $classMetadata->getIdentifierFieldNames();
|
||||||
|
|
||||||
if (1 === count($identifiers)) {
|
if (1 === \count($identifiers)) {
|
||||||
$identifier = $identifiers[0];
|
$identifier = $identifiers[0];
|
||||||
|
|
||||||
if (!$classMetadata->hasAssociation($identifier)) {
|
if (!$classMetadata->hasAssociation($identifier)) {
|
||||||
$idAsValue = true;
|
$idAsValue = true;
|
||||||
|
|
||||||
if (in_array($classMetadata->getTypeOfField($identifier), array('integer', 'smallint', 'bigint'))) {
|
if (\in_array($classMetadata->getTypeOfField($identifier), array('integer', 'smallint', 'bigint'))) {
|
||||||
$idAsIndex = true;
|
$idAsIndex = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,8 +42,8 @@ class IdReader
|
|||||||
|
|
||||||
$this->om = $om;
|
$this->om = $om;
|
||||||
$this->classMetadata = $classMetadata;
|
$this->classMetadata = $classMetadata;
|
||||||
$this->singleId = 1 === count($ids);
|
$this->singleId = 1 === \count($ids);
|
||||||
$this->intId = $this->singleId && in_array($idType, array('integer', 'smallint', 'bigint'));
|
$this->intId = $this->singleId && \in_array($idType, array('integer', 'smallint', 'bigint'));
|
||||||
$this->idField = current($ids);
|
$this->idField = current($ids);
|
||||||
|
|
||||||
// single field association are resolved, since the schema column could be an int
|
// single field association are resolved, since the schema column could be an int
|
||||||
@ -95,7 +95,7 @@ class IdReader
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!$this->om->contains($object)) {
|
if (!$this->om->contains($object)) {
|
||||||
throw new RuntimeException(sprintf('Entity of type "%s" passed to the choice field must be managed. Maybe you forget to persist it in the entity manager?', get_class($object)));
|
throw new RuntimeException(sprintf('Entity of type "%s" passed to the choice field must be managed. Maybe you forget to persist it in the entity manager?', \get_class($object)));
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->om->initializeObject($object);
|
$this->om->initializeObject($object);
|
||||||
|
@ -98,7 +98,7 @@ class ORMQueryBuilderLoader implements EntityLoaderInterface
|
|||||||
// Guess type
|
// Guess type
|
||||||
$entity = current($qb->getRootEntities());
|
$entity = current($qb->getRootEntities());
|
||||||
$metadata = $qb->getEntityManager()->getClassMetadata($entity);
|
$metadata = $qb->getEntityManager()->getClassMetadata($entity);
|
||||||
if (in_array($metadata->getTypeOfField($identifier), array('integer', 'bigint', 'smallint'))) {
|
if (\in_array($metadata->getTypeOfField($identifier), array('integer', 'bigint', 'smallint'))) {
|
||||||
$parameterType = Connection::PARAM_INT_ARRAY;
|
$parameterType = Connection::PARAM_INT_ARRAY;
|
||||||
|
|
||||||
// Filter out non-integer values (e.g. ""). If we don't, some
|
// Filter out non-integer values (e.g. ""). If we don't, some
|
||||||
@ -106,7 +106,7 @@ class ORMQueryBuilderLoader implements EntityLoaderInterface
|
|||||||
$values = array_values(array_filter($values, function ($v) {
|
$values = array_values(array_filter($values, function ($v) {
|
||||||
return (string) $v === (string) (int) $v || ctype_digit($v);
|
return (string) $v === (string) (int) $v || ctype_digit($v);
|
||||||
}));
|
}));
|
||||||
} elseif (in_array($metadata->getTypeOfField($identifier), array('uuid', 'guid'))) {
|
} elseif (\in_array($metadata->getTypeOfField($identifier), array('uuid', 'guid'))) {
|
||||||
$parameterType = Connection::PARAM_STR_ARRAY;
|
$parameterType = Connection::PARAM_STR_ARRAY;
|
||||||
|
|
||||||
// Like above, but we just filter out empty strings.
|
// Like above, but we just filter out empty strings.
|
||||||
|
@ -36,7 +36,7 @@ class CollectionToArrayTransformer implements DataTransformerInterface
|
|||||||
|
|
||||||
// For cases when the collection getter returns $collection->toArray()
|
// For cases when the collection getter returns $collection->toArray()
|
||||||
// in order to prevent modifications of the returned collection
|
// in order to prevent modifications of the returned collection
|
||||||
if (is_array($collection)) {
|
if (\is_array($collection)) {
|
||||||
return $collection;
|
return $collection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ class DoctrineOrmTypeGuesser implements FormTypeGuesserInterface
|
|||||||
return new ValueGuess($mapping['length'], Guess::HIGH_CONFIDENCE);
|
return new ValueGuess($mapping['length'], Guess::HIGH_CONFIDENCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (in_array($ret[0]->getTypeOfField($property), array(Type::DECIMAL, Type::FLOAT))) {
|
if (\in_array($ret[0]->getTypeOfField($property), array(Type::DECIMAL, Type::FLOAT))) {
|
||||||
return new ValueGuess(null, Guess::MEDIUM_CONFIDENCE);
|
return new ValueGuess(null, Guess::MEDIUM_CONFIDENCE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -144,7 +144,7 @@ class DoctrineOrmTypeGuesser implements FormTypeGuesserInterface
|
|||||||
{
|
{
|
||||||
$ret = $this->getMetadata($class);
|
$ret = $this->getMetadata($class);
|
||||||
if ($ret && isset($ret[0]->fieldMappings[$property]) && !$ret[0]->hasAssociation($property)) {
|
if ($ret && isset($ret[0]->fieldMappings[$property]) && !$ret[0]->hasAssociation($property)) {
|
||||||
if (in_array($ret[0]->getTypeOfField($property), array(Type::DECIMAL, Type::FLOAT))) {
|
if (\in_array($ret[0]->getTypeOfField($property), array(Type::DECIMAL, Type::FLOAT))) {
|
||||||
return new ValueGuess(null, Guess::MEDIUM_CONFIDENCE);
|
return new ValueGuess(null, Guess::MEDIUM_CONFIDENCE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ class MergeDoctrineCollectionListener implements EventSubscriberInterface
|
|||||||
|
|
||||||
// If all items were removed, call clear which has a higher
|
// If all items were removed, call clear which has a higher
|
||||||
// performance on persistent collections
|
// performance on persistent collections
|
||||||
if ($collection instanceof Collection && 0 === count($data)) {
|
if ($collection instanceof Collection && 0 === \count($data)) {
|
||||||
$collection->clear();
|
$collection->clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -259,8 +259,8 @@ abstract class DoctrineType extends AbstractType
|
|||||||
// Invoke the query builder closure so that we can cache choice lists
|
// Invoke the query builder closure so that we can cache choice lists
|
||||||
// for equal query builders
|
// for equal query builders
|
||||||
$queryBuilderNormalizer = function (Options $options, $queryBuilder) {
|
$queryBuilderNormalizer = function (Options $options, $queryBuilder) {
|
||||||
if (is_callable($queryBuilder)) {
|
if (\is_callable($queryBuilder)) {
|
||||||
$queryBuilder = call_user_func($queryBuilder, $options['em']->getRepository($options['class']));
|
$queryBuilder = \call_user_func($queryBuilder, $options['em']->getRepository($options['class']));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $queryBuilder;
|
return $queryBuilder;
|
||||||
|
@ -28,8 +28,8 @@ class EntityType extends DoctrineType
|
|||||||
// Invoke the query builder closure so that we can cache choice lists
|
// Invoke the query builder closure so that we can cache choice lists
|
||||||
// for equal query builders
|
// for equal query builders
|
||||||
$queryBuilderNormalizer = function (Options $options, $queryBuilder) {
|
$queryBuilderNormalizer = function (Options $options, $queryBuilder) {
|
||||||
if (is_callable($queryBuilder)) {
|
if (\is_callable($queryBuilder)) {
|
||||||
$queryBuilder = call_user_func($queryBuilder, $options['em']->getRepository($options['class']));
|
$queryBuilder = \call_user_func($queryBuilder, $options['em']->getRepository($options['class']));
|
||||||
|
|
||||||
if (null !== $queryBuilder && !$queryBuilder instanceof QueryBuilder) {
|
if (null !== $queryBuilder && !$queryBuilder instanceof QueryBuilder) {
|
||||||
throw new UnexpectedTypeException($queryBuilder, 'Doctrine\ORM\QueryBuilder');
|
throw new UnexpectedTypeException($queryBuilder, 'Doctrine\ORM\QueryBuilder');
|
||||||
|
@ -71,12 +71,12 @@ class DbalLogger implements SQLLogger
|
|||||||
{
|
{
|
||||||
foreach ($params as $index => $param) {
|
foreach ($params as $index => $param) {
|
||||||
// normalize recursively
|
// normalize recursively
|
||||||
if (is_array($param)) {
|
if (\is_array($param)) {
|
||||||
$params[$index] = $this->normalizeParams($param);
|
$params[$index] = $this->normalizeParams($param);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_string($params[$index])) {
|
if (!\is_string($params[$index])) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ class EntityUserProvider implements UserProviderInterface
|
|||||||
} else {
|
} else {
|
||||||
if (!$repository instanceof UserLoaderInterface) {
|
if (!$repository instanceof UserLoaderInterface) {
|
||||||
if (!$repository instanceof UserProviderInterface) {
|
if (!$repository instanceof UserProviderInterface) {
|
||||||
throw new \InvalidArgumentException(sprintf('You must either make the "%s" entity Doctrine Repository ("%s") implement "Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface" or set the "property" option in the corresponding entity provider configuration.', $this->classOrAlias, get_class($repository)));
|
throw new \InvalidArgumentException(sprintf('You must either make the "%s" entity Doctrine Repository ("%s") implement "Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface" or set the "property" option in the corresponding entity provider configuration.', $this->classOrAlias, \get_class($repository)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@trigger_error('Implementing Symfony\Component\Security\Core\User\UserProviderInterface in a Doctrine repository when using the entity provider is deprecated since Symfony 2.8 and will not be supported in 3.0. Make the repository implement Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface instead.', E_USER_DEPRECATED);
|
@trigger_error('Implementing Symfony\Component\Security\Core\User\UserProviderInterface in a Doctrine repository when using the entity provider is deprecated since Symfony 2.8 and will not be supported in 3.0. Make the repository implement Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface instead.', E_USER_DEPRECATED);
|
||||||
@ -75,7 +75,7 @@ class EntityUserProvider implements UserProviderInterface
|
|||||||
{
|
{
|
||||||
$class = $this->getClass();
|
$class = $this->getClass();
|
||||||
if (!$user instanceof $class) {
|
if (!$user instanceof $class) {
|
||||||
throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', get_class($user)));
|
throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', \get_class($user)));
|
||||||
}
|
}
|
||||||
|
|
||||||
$repository = $this->getRepository();
|
$repository = $this->getRepository();
|
||||||
|
@ -30,7 +30,7 @@ class DoctrineTestHelper
|
|||||||
*/
|
*/
|
||||||
public static function createTestEntityManager()
|
public static function createTestEntityManager()
|
||||||
{
|
{
|
||||||
if (!extension_loaded('pdo_sqlite')) {
|
if (!\extension_loaded('pdo_sqlite')) {
|
||||||
TestCase::markTestSkipped('Extension pdo_sqlite is required.');
|
TestCase::markTestSkipped('Extension pdo_sqlite is required.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ class DoctrineExtensionTest extends TestCase
|
|||||||
'SecondBundle' => 'My\SecondBundle',
|
'SecondBundle' => 'My\SecondBundle',
|
||||||
);
|
);
|
||||||
|
|
||||||
$reflection = new \ReflectionClass(get_class($this->extension));
|
$reflection = new \ReflectionClass(\get_class($this->extension));
|
||||||
$method = $reflection->getMethod('fixManagersAutoMappings');
|
$method = $reflection->getMethod('fixManagersAutoMappings');
|
||||||
$method->setAccessible(true);
|
$method->setAccessible(true);
|
||||||
|
|
||||||
@ -157,7 +157,7 @@ class DoctrineExtensionTest extends TestCase
|
|||||||
'SecondBundle' => 'My\SecondBundle',
|
'SecondBundle' => 'My\SecondBundle',
|
||||||
);
|
);
|
||||||
|
|
||||||
$reflection = new \ReflectionClass(get_class($this->extension));
|
$reflection = new \ReflectionClass(\get_class($this->extension));
|
||||||
$method = $reflection->getMethod('fixManagersAutoMappings');
|
$method = $reflection->getMethod('fixManagersAutoMappings');
|
||||||
$method->setAccessible(true);
|
$method->setAccessible(true);
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ class EntityTypePerformanceTest extends FormPerformanceTestCase
|
|||||||
$ids = range(1, 300);
|
$ids = range(1, 300);
|
||||||
|
|
||||||
foreach ($ids as $id) {
|
foreach ($ids as $id) {
|
||||||
$name = 65 + (int) chr($id % 57);
|
$name = 65 + (int) \chr($id % 57);
|
||||||
$this->em->persist(new SingleIntIdEntity($id, $name));
|
$this->em->persist(new SingleIntIdEntity($id, $name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,7 +145,7 @@ class DbalLoggerTest extends TestCase
|
|||||||
;
|
;
|
||||||
|
|
||||||
$testStringArray = array('é', 'á', 'ű', 'ő', 'ú', 'ö', 'ü', 'ó', 'í');
|
$testStringArray = array('é', 'á', 'ű', 'ő', 'ú', 'ö', 'ü', 'ó', 'í');
|
||||||
$testStringCount = count($testStringArray);
|
$testStringCount = \count($testStringArray);
|
||||||
|
|
||||||
$shortString = '';
|
$shortString = '';
|
||||||
$longString = '';
|
$longString = '';
|
||||||
|
@ -50,7 +50,7 @@ class DoctrineFooType extends Type
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!$value instanceof Foo) {
|
if (!$value instanceof Foo) {
|
||||||
throw new ConversionException(sprintf('Expected %s, got %s', 'Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\Foo', gettype($value)));
|
throw new ConversionException(sprintf('Expected %s, got %s', 'Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\Foo', \gettype($value)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $foo->bar;
|
return $foo->bar;
|
||||||
@ -64,7 +64,7 @@ class DoctrineFooType extends Type
|
|||||||
if (null === $value) {
|
if (null === $value) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!is_string($value)) {
|
if (!\is_string($value)) {
|
||||||
throw ConversionException::conversionFailed($value, self::NAME);
|
throw ConversionException::conversionFailed($value, self::NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,7 +176,7 @@ class EntityUserProviderTest extends TestCase
|
|||||||
$provider = new EntityUserProvider($this->getManager($em), 'Symfony\Bridge\Doctrine\Tests\Fixtures\User', 'name');
|
$provider = new EntityUserProvider($this->getManager($em), 'Symfony\Bridge\Doctrine\Tests\Fixtures\User', 'name');
|
||||||
|
|
||||||
$user2 = $em->getReference('Symfony\Bridge\Doctrine\Tests\Fixtures\User', array('id1' => 1, 'id2' => 1));
|
$user2 = $em->getReference('Symfony\Bridge\Doctrine\Tests\Fixtures\User', array('id1' => 1, 'id2' => 1));
|
||||||
$this->assertTrue($provider->supportsClass(get_class($user2)));
|
$this->assertTrue($provider->supportsClass(\get_class($user2)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testLoadUserByUserNameShouldLoadUserWhenProperInterfaceProvided()
|
public function testLoadUserByUserNameShouldLoadUserWhenProperInterfaceProvided()
|
||||||
|
@ -45,17 +45,17 @@ class UniqueEntityValidator extends ConstraintValidator
|
|||||||
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\UniqueEntity');
|
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\UniqueEntity');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_array($constraint->fields) && !is_string($constraint->fields)) {
|
if (!\is_array($constraint->fields) && !\is_string($constraint->fields)) {
|
||||||
throw new UnexpectedTypeException($constraint->fields, 'array');
|
throw new UnexpectedTypeException($constraint->fields, 'array');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null !== $constraint->errorPath && !is_string($constraint->errorPath)) {
|
if (null !== $constraint->errorPath && !\is_string($constraint->errorPath)) {
|
||||||
throw new UnexpectedTypeException($constraint->errorPath, 'string or null');
|
throw new UnexpectedTypeException($constraint->errorPath, 'string or null');
|
||||||
}
|
}
|
||||||
|
|
||||||
$fields = (array) $constraint->fields;
|
$fields = (array) $constraint->fields;
|
||||||
|
|
||||||
if (0 === count($fields)) {
|
if (0 === \count($fields)) {
|
||||||
throw new ConstraintDefinitionException('At least one field has to be specified.');
|
throw new ConstraintDefinitionException('At least one field has to be specified.');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,14 +70,14 @@ class UniqueEntityValidator extends ConstraintValidator
|
|||||||
throw new ConstraintDefinitionException(sprintf('Object manager "%s" does not exist.', $constraint->em));
|
throw new ConstraintDefinitionException(sprintf('Object manager "%s" does not exist.', $constraint->em));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$em = $this->registry->getManagerForClass(get_class($entity));
|
$em = $this->registry->getManagerForClass(\get_class($entity));
|
||||||
|
|
||||||
if (!$em) {
|
if (!$em) {
|
||||||
throw new ConstraintDefinitionException(sprintf('Unable to find the object manager associated with an entity of class "%s".', get_class($entity)));
|
throw new ConstraintDefinitionException(sprintf('Unable to find the object manager associated with an entity of class "%s".', \get_class($entity)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$class = $em->getClassMetadata(get_class($entity));
|
$class = $em->getClassMetadata(\get_class($entity));
|
||||||
/* @var $class \Doctrine\Common\Persistence\Mapping\ClassMetadata */
|
/* @var $class \Doctrine\Common\Persistence\Mapping\ClassMetadata */
|
||||||
|
|
||||||
$criteria = array();
|
$criteria = array();
|
||||||
@ -120,7 +120,7 @@ class UniqueEntityValidator extends ConstraintValidator
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$repository = $em->getRepository(get_class($entity));
|
$repository = $em->getRepository(\get_class($entity));
|
||||||
$result = $repository->{$constraint->repositoryMethod}($criteria);
|
$result = $repository->{$constraint->repositoryMethod}($criteria);
|
||||||
|
|
||||||
if ($result instanceof \IteratorAggregate) {
|
if ($result instanceof \IteratorAggregate) {
|
||||||
|
@ -30,7 +30,7 @@ class DoctrineInitializer implements ObjectInitializerInterface
|
|||||||
|
|
||||||
public function initialize($object)
|
public function initialize($object)
|
||||||
{
|
{
|
||||||
$manager = $this->registry->getManagerForClass(get_class($object));
|
$manager = $this->registry->getManagerForClass(\get_class($object));
|
||||||
if (null !== $manager) {
|
if (null !== $manager) {
|
||||||
$manager->initializeObject($object);
|
$manager->initializeObject($object);
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ class DebugHandler extends TestHandler implements DebugLoggerInterface
|
|||||||
$levels = array(Logger::ERROR, Logger::CRITICAL, Logger::ALERT, Logger::EMERGENCY);
|
$levels = array(Logger::ERROR, Logger::CRITICAL, Logger::ALERT, Logger::EMERGENCY);
|
||||||
foreach ($levels as $level) {
|
foreach ($levels as $level) {
|
||||||
if (isset($this->recordsByLevel[$level])) {
|
if (isset($this->recordsByLevel[$level])) {
|
||||||
$cnt += count($this->recordsByLevel[$level]);
|
$cnt += \count($this->recordsByLevel[$level]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ class ClockMock
|
|||||||
|
|
||||||
public static function register($class)
|
public static function register($class)
|
||||||
{
|
{
|
||||||
$self = get_called_class();
|
$self = \get_called_class();
|
||||||
|
|
||||||
$mockedNs = array(substr($class, 0, strrpos($class, '\\')));
|
$mockedNs = array(substr($class, 0, strrpos($class, '\\')));
|
||||||
if (strpos($class, '\\Tests\\')) {
|
if (strpos($class, '\\Tests\\')) {
|
||||||
@ -79,7 +79,7 @@ class ClockMock
|
|||||||
$mockedNs[] = substr($ns, 0, strrpos($ns, '\\'));
|
$mockedNs[] = substr($ns, 0, strrpos($ns, '\\'));
|
||||||
}
|
}
|
||||||
foreach ($mockedNs as $ns) {
|
foreach ($mockedNs as $ns) {
|
||||||
if (function_exists($ns.'\time')) {
|
if (\function_exists($ns.'\time')) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
eval(<<<EOPHP
|
eval(<<<EOPHP
|
||||||
|
@ -75,13 +75,13 @@ class DeprecationErrorHandler
|
|||||||
$trace = debug_backtrace(true);
|
$trace = debug_backtrace(true);
|
||||||
$group = 'other';
|
$group = 'other';
|
||||||
|
|
||||||
$i = count($trace);
|
$i = \count($trace);
|
||||||
while (1 < $i && (!isset($trace[--$i]['class']) || ('ReflectionMethod' === $trace[$i]['class'] || 0 === strpos($trace[$i]['class'], 'PHPUnit_')))) {
|
while (1 < $i && (!isset($trace[--$i]['class']) || ('ReflectionMethod' === $trace[$i]['class'] || 0 === strpos($trace[$i]['class'], 'PHPUnit_')))) {
|
||||||
// No-op
|
// No-op
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($trace[$i]['object']) || isset($trace[$i]['class'])) {
|
if (isset($trace[$i]['object']) || isset($trace[$i]['class'])) {
|
||||||
$class = isset($trace[$i]['object']) ? get_class($trace[$i]['object']) : $trace[$i]['class'];
|
$class = isset($trace[$i]['object']) ? \get_class($trace[$i]['object']) : $trace[$i]['class'];
|
||||||
$method = $trace[$i]['function'];
|
$method = $trace[$i]['function'];
|
||||||
|
|
||||||
if (0 !== error_reporting()) {
|
if (0 !== error_reporting()) {
|
||||||
@ -90,7 +90,7 @@ class DeprecationErrorHandler
|
|||||||
|| 0 === strpos($method, 'provideLegacy')
|
|| 0 === strpos($method, 'provideLegacy')
|
||||||
|| 0 === strpos($method, 'getLegacy')
|
|| 0 === strpos($method, 'getLegacy')
|
||||||
|| strpos($class, '\Legacy')
|
|| strpos($class, '\Legacy')
|
||||||
|| in_array('legacy', \PHPUnit_Util_Test::getGroups($class, $method), true)
|
|| \in_array('legacy', \PHPUnit_Util_Test::getGroups($class, $method), true)
|
||||||
) {
|
) {
|
||||||
$group = 'legacy';
|
$group = 'legacy';
|
||||||
} else {
|
} else {
|
||||||
@ -101,7 +101,7 @@ class DeprecationErrorHandler
|
|||||||
$e = new \Exception($msg);
|
$e = new \Exception($msg);
|
||||||
$r = new \ReflectionProperty($e, 'trace');
|
$r = new \ReflectionProperty($e, 'trace');
|
||||||
$r->setAccessible(true);
|
$r->setAccessible(true);
|
||||||
$r->setValue($e, array_slice($trace, 1, $i));
|
$r->setValue($e, \array_slice($trace, 1, $i));
|
||||||
|
|
||||||
echo "\n".ucfirst($group).' deprecation triggered by '.$class.'::'.$method.':';
|
echo "\n".ucfirst($group).' deprecation triggered by '.$class.'::'.$method.':';
|
||||||
echo "\n".$msg;
|
echo "\n".$msg;
|
||||||
@ -193,12 +193,12 @@ class DeprecationErrorHandler
|
|||||||
|
|
||||||
// reset deprecations array
|
// reset deprecations array
|
||||||
foreach ($deprecations as $group => $arrayOrInt) {
|
foreach ($deprecations as $group => $arrayOrInt) {
|
||||||
$deprecations[$group] = is_int($arrayOrInt) ? 0 : array();
|
$deprecations[$group] = \is_int($arrayOrInt) ? 0 : array();
|
||||||
}
|
}
|
||||||
|
|
||||||
register_shutdown_function(function () use (&$deprecations, $isFailing, $displayDeprecations, $mode) {
|
register_shutdown_function(function () use (&$deprecations, $isFailing, $displayDeprecations, $mode) {
|
||||||
foreach ($deprecations as $group => $arrayOrInt) {
|
foreach ($deprecations as $group => $arrayOrInt) {
|
||||||
if (0 < (is_int($arrayOrInt) ? $arrayOrInt : count($arrayOrInt))) {
|
if (0 < (\is_int($arrayOrInt) ? $arrayOrInt : \count($arrayOrInt))) {
|
||||||
echo "Shutdown-time deprecations:\n";
|
echo "Shutdown-time deprecations:\n";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -222,7 +222,7 @@ class DeprecationErrorHandler
|
|||||||
*/
|
*/
|
||||||
private static function hasColorSupport()
|
private static function hasColorSupport()
|
||||||
{
|
{
|
||||||
if (!defined('STDOUT')) {
|
if (!\defined('STDOUT')) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -231,18 +231,18 @@ class DeprecationErrorHandler
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (DIRECTORY_SEPARATOR === '\\') {
|
if (DIRECTORY_SEPARATOR === '\\') {
|
||||||
return (function_exists('sapi_windows_vt100_support')
|
return (\function_exists('sapi_windows_vt100_support')
|
||||||
&& sapi_windows_vt100_support(STDOUT))
|
&& sapi_windows_vt100_support(STDOUT))
|
||||||
|| false !== getenv('ANSICON')
|
|| false !== getenv('ANSICON')
|
||||||
|| 'ON' === getenv('ConEmuANSI')
|
|| 'ON' === getenv('ConEmuANSI')
|
||||||
|| 'xterm' === getenv('TERM');
|
|| 'xterm' === getenv('TERM');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (function_exists('stream_isatty')) {
|
if (\function_exists('stream_isatty')) {
|
||||||
return stream_isatty(STDOUT);
|
return stream_isatty(STDOUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (function_exists('posix_isatty')) {
|
if (\function_exists('posix_isatty')) {
|
||||||
return posix_isatty(STDOUT);
|
return posix_isatty(STDOUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ class Command extends \PHPUnit_TextUI_Command
|
|||||||
// By default, we want PHPUnit's autoloader before Symfony's one
|
// By default, we want PHPUnit's autoloader before Symfony's one
|
||||||
if (!getenv('SYMFONY_PHPUNIT_OVERLOAD')) {
|
if (!getenv('SYMFONY_PHPUNIT_OVERLOAD')) {
|
||||||
$filename = realpath(stream_resolve_include_path($filename));
|
$filename = realpath(stream_resolve_include_path($filename));
|
||||||
$symfonyLoader = realpath(dirname(PHPUNIT_COMPOSER_INSTALL).'/../../../vendor/autoload.php');
|
$symfonyLoader = realpath(\dirname(PHPUNIT_COMPOSER_INSTALL).'/../../../vendor/autoload.php');
|
||||||
|
|
||||||
if ($filename === $symfonyLoader) {
|
if ($filename === $symfonyLoader) {
|
||||||
$symfonyLoader = require $symfonyLoader;
|
$symfonyLoader = require $symfonyLoader;
|
||||||
|
@ -51,7 +51,7 @@ class RuntimeInstantiator implements InstantiatorInterface
|
|||||||
return $this->factory->createProxy(
|
return $this->factory->createProxy(
|
||||||
$definition->getClass(),
|
$definition->getClass(),
|
||||||
function (&$wrappedInstance, LazyLoadingInterface $proxy) use ($realInstantiator) {
|
function (&$wrappedInstance, LazyLoadingInterface $proxy) use ($realInstantiator) {
|
||||||
$wrappedInstance = call_user_func($realInstantiator);
|
$wrappedInstance = \call_user_func($realInstantiator);
|
||||||
|
|
||||||
$proxy->setProxyInitializer(null);
|
$proxy->setProxyInitializer(null);
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ class ProxyDumper implements DumperInterface
|
|||||||
if ($definition->isShared()) {
|
if ($definition->isShared()) {
|
||||||
$instantiation .= " \$this->services['$id'] =";
|
$instantiation .= " \$this->services['$id'] =";
|
||||||
|
|
||||||
if (defined('Symfony\Component\DependencyInjection\ContainerInterface::SCOPE_CONTAINER') && ContainerInterface::SCOPE_CONTAINER !== $scope = $definition->getScope(false)) {
|
if (\defined('Symfony\Component\DependencyInjection\ContainerInterface::SCOPE_CONTAINER') && ContainerInterface::SCOPE_CONTAINER !== $scope = $definition->getScope(false)) {
|
||||||
$instantiation .= " \$this->scopedServices['$scope']['$id'] =";
|
$instantiation .= " \$this->scopedServices['$scope']['$id'] =";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -103,7 +103,7 @@ class AppVariable
|
|||||||
}
|
}
|
||||||
|
|
||||||
$user = $token->getUser();
|
$user = $token->getUser();
|
||||||
if (is_object($user)) {
|
if (\is_object($user)) {
|
||||||
return $user;
|
return $user;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -139,16 +139,16 @@ EOF
|
|||||||
if (null === $cb) {
|
if (null === $cb) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (is_array($cb)) {
|
if (\is_array($cb)) {
|
||||||
if (!method_exists($cb[0], $cb[1])) {
|
if (!method_exists($cb[0], $cb[1])) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$refl = new \ReflectionMethod($cb[0], $cb[1]);
|
$refl = new \ReflectionMethod($cb[0], $cb[1]);
|
||||||
} elseif (is_object($cb) && method_exists($cb, '__invoke')) {
|
} elseif (\is_object($cb) && method_exists($cb, '__invoke')) {
|
||||||
$refl = new \ReflectionMethod($cb, '__invoke');
|
$refl = new \ReflectionMethod($cb, '__invoke');
|
||||||
} elseif (function_exists($cb)) {
|
} elseif (\function_exists($cb)) {
|
||||||
$refl = new \ReflectionFunction($cb);
|
$refl = new \ReflectionFunction($cb);
|
||||||
} elseif (is_string($cb) && preg_match('{^(.+)::(.+)$}', $cb, $m) && method_exists($m[1], $m[2])) {
|
} elseif (\is_string($cb) && preg_match('{^(.+)::(.+)$}', $cb, $m) && method_exists($m[1], $m[2])) {
|
||||||
$refl = new \ReflectionMethod($m[1], $m[2]);
|
$refl = new \ReflectionMethod($m[1], $m[2]);
|
||||||
} else {
|
} else {
|
||||||
throw new \UnexpectedValueException('Unsupported callback type');
|
throw new \UnexpectedValueException('Unsupported callback type');
|
||||||
@ -198,8 +198,8 @@ EOF
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ('globals' === $type) {
|
if ('globals' === $type) {
|
||||||
if (is_object($meta)) {
|
if (\is_object($meta)) {
|
||||||
return ' = object('.get_class($meta).')';
|
return ' = object('.\get_class($meta).')';
|
||||||
}
|
}
|
||||||
|
|
||||||
return ' = '.substr(@json_encode($meta), 0, 50);
|
return ' = '.substr(@json_encode($meta), 0, 50);
|
||||||
|
@ -99,7 +99,7 @@ EOF
|
|||||||
|
|
||||||
$filenames = $input->getArgument('filename');
|
$filenames = $input->getArgument('filename');
|
||||||
|
|
||||||
if (0 === count($filenames)) {
|
if (0 === \count($filenames)) {
|
||||||
if (0 !== ftell(STDIN)) {
|
if (0 !== ftell(STDIN)) {
|
||||||
throw new \RuntimeException('Please provide a filename or pipe template content to STDIN.');
|
throw new \RuntimeException('Please provide a filename or pipe template content to STDIN.');
|
||||||
}
|
}
|
||||||
@ -184,9 +184,9 @@ EOF
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (0 === $errors) {
|
if (0 === $errors) {
|
||||||
$io->success(sprintf('All %d Twig files contain valid syntax.', count($filesInfo)));
|
$io->success(sprintf('All %d Twig files contain valid syntax.', \count($filesInfo)));
|
||||||
} else {
|
} else {
|
||||||
$io->warning(sprintf('%d Twig files have valid syntax and %d contain errors.', count($filesInfo) - $errors, $errors));
|
$io->warning(sprintf('%d Twig files have valid syntax and %d contain errors.', \count($filesInfo) - $errors, $errors));
|
||||||
}
|
}
|
||||||
|
|
||||||
return min($errors, 1);
|
return min($errors, 1);
|
||||||
@ -206,7 +206,7 @@ EOF
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$output->writeln(json_encode($filesInfo, defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES : 0));
|
$output->writeln(json_encode($filesInfo, \defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES : 0));
|
||||||
|
|
||||||
return min($errors, 1);
|
return min($errors, 1);
|
||||||
}
|
}
|
||||||
@ -239,7 +239,7 @@ EOF
|
|||||||
$lines = explode("\n", $template);
|
$lines = explode("\n", $template);
|
||||||
|
|
||||||
$position = max(0, $line - $context);
|
$position = max(0, $line - $context);
|
||||||
$max = min(count($lines), $line - 1 + $context);
|
$max = min(\count($lines), $line - 1 + $context);
|
||||||
|
|
||||||
$result = array();
|
$result = array();
|
||||||
while ($position < $max) {
|
while ($position < $max) {
|
||||||
|
@ -62,13 +62,13 @@ class AssetExtension extends AbstractExtension
|
|||||||
public function getAssetUrl($path, $packageName = null, $absolute = false, $version = null)
|
public function getAssetUrl($path, $packageName = null, $absolute = false, $version = null)
|
||||||
{
|
{
|
||||||
// BC layer to be removed in 3.0
|
// BC layer to be removed in 3.0
|
||||||
if (2 < $count = func_num_args()) {
|
if (2 < $count = \func_num_args()) {
|
||||||
@trigger_error('Generating absolute URLs with the Twig asset() function was deprecated in 2.7 and will be removed in 3.0. Please use absolute_url() instead.', E_USER_DEPRECATED);
|
@trigger_error('Generating absolute URLs with the Twig asset() function was deprecated in 2.7 and will be removed in 3.0. Please use absolute_url() instead.', E_USER_DEPRECATED);
|
||||||
if (4 === $count) {
|
if (4 === $count) {
|
||||||
@trigger_error('Forcing a version with the Twig asset() function was deprecated in 2.7 and will be removed in 3.0.', E_USER_DEPRECATED);
|
@trigger_error('Forcing a version with the Twig asset() function was deprecated in 2.7 and will be removed in 3.0.', E_USER_DEPRECATED);
|
||||||
}
|
}
|
||||||
|
|
||||||
$args = func_get_args();
|
$args = \func_get_args();
|
||||||
|
|
||||||
return $this->getLegacyAssetUrl($path, $packageName, $args[2], isset($args[3]) ? $args[3] : null);
|
return $this->getLegacyAssetUrl($path, $packageName, $args[2], isset($args[3]) ? $args[3] : null);
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ class CodeExtension extends AbstractExtension
|
|||||||
public function __construct($fileLinkFormat, $rootDir, $charset)
|
public function __construct($fileLinkFormat, $rootDir, $charset)
|
||||||
{
|
{
|
||||||
$this->fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format');
|
$this->fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format');
|
||||||
$this->rootDir = str_replace('/', DIRECTORY_SEPARATOR, dirname($rootDir)).DIRECTORY_SEPARATOR;
|
$this->rootDir = str_replace('/', DIRECTORY_SEPARATOR, \dirname($rootDir)).DIRECTORY_SEPARATOR;
|
||||||
$this->charset = $charset;
|
$this->charset = $charset;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,7 +92,7 @@ class CodeExtension extends AbstractExtension
|
|||||||
$short = array_pop($parts);
|
$short = array_pop($parts);
|
||||||
$formattedValue = sprintf('<em>object</em>(<abbr title="%s">%s</abbr>)', $item[1], $short);
|
$formattedValue = sprintf('<em>object</em>(<abbr title="%s">%s</abbr>)', $item[1], $short);
|
||||||
} elseif ('array' === $item[0]) {
|
} elseif ('array' === $item[0]) {
|
||||||
$formattedValue = sprintf('<em>array</em>(%s)', is_array($item[1]) ? $this->formatArgs($item[1]) : $item[1]);
|
$formattedValue = sprintf('<em>array</em>(%s)', \is_array($item[1]) ? $this->formatArgs($item[1]) : $item[1]);
|
||||||
} elseif ('string' === $item[0]) {
|
} elseif ('string' === $item[0]) {
|
||||||
$formattedValue = sprintf("'%s'", htmlspecialchars($item[1], ENT_QUOTES, $this->charset));
|
$formattedValue = sprintf("'%s'", htmlspecialchars($item[1], ENT_QUOTES, $this->charset));
|
||||||
} elseif ('null' === $item[0]) {
|
} elseif ('null' === $item[0]) {
|
||||||
@ -105,7 +105,7 @@ class CodeExtension extends AbstractExtension
|
|||||||
$formattedValue = str_replace("\n", '', var_export(htmlspecialchars((string) $item[1], ENT_QUOTES, $this->charset), true));
|
$formattedValue = str_replace("\n", '', var_export(htmlspecialchars((string) $item[1], ENT_QUOTES, $this->charset), true));
|
||||||
}
|
}
|
||||||
|
|
||||||
$result[] = is_int($key) ? $formattedValue : sprintf("'%s' => %s", $key, $formattedValue);
|
$result[] = \is_int($key) ? $formattedValue : sprintf("'%s' => %s", $key, $formattedValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
return implode(', ', $result);
|
return implode(', ', $result);
|
||||||
@ -142,7 +142,7 @@ class CodeExtension extends AbstractExtension
|
|||||||
$content = explode('<br />', $code);
|
$content = explode('<br />', $code);
|
||||||
|
|
||||||
$lines = array();
|
$lines = array();
|
||||||
for ($i = max($line - 3, 1), $max = min($line + 3, count($content)); $i <= $max; ++$i) {
|
for ($i = max($line - 3, 1), $max = min($line + 3, \count($content)); $i <= $max; ++$i) {
|
||||||
$lines[] = '<li'.($i == $line ? ' class="selected"' : '').'><code>'.self::fixCodeMarkup($content[$i - 1]).'</code></li>';
|
$lines[] = '<li'.($i == $line ? ' class="selected"' : '').'><code>'.self::fixCodeMarkup($content[$i - 1]).'</code></li>';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,7 +166,7 @@ class CodeExtension extends AbstractExtension
|
|||||||
if (null === $text) {
|
if (null === $text) {
|
||||||
$text = str_replace('/', DIRECTORY_SEPARATOR, $file);
|
$text = str_replace('/', DIRECTORY_SEPARATOR, $file);
|
||||||
if (0 === strpos($text, $this->rootDir)) {
|
if (0 === strpos($text, $this->rootDir)) {
|
||||||
$text = substr($text, strlen($this->rootDir));
|
$text = substr($text, \strlen($this->rootDir));
|
||||||
$text = explode(DIRECTORY_SEPARATOR, $text, 2);
|
$text = explode(DIRECTORY_SEPARATOR, $text, 2);
|
||||||
$text = sprintf('<abbr title="%s%2$s">%s</abbr>%s', $this->rootDir, $text[0], isset($text[1]) ? DIRECTORY_SEPARATOR.$text[1] : '');
|
$text = sprintf('<abbr title="%s%2$s">%s</abbr>%s', $this->rootDir, $text[0], isset($text[1]) ? DIRECTORY_SEPARATOR.$text[1] : '');
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ class DumpExtension extends AbstractExtension
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (2 === func_num_args()) {
|
if (2 === \func_num_args()) {
|
||||||
$vars = array();
|
$vars = array();
|
||||||
foreach ($context as $key => $value) {
|
foreach ($context as $key => $value) {
|
||||||
if (!$value instanceof Template) {
|
if (!$value instanceof Template) {
|
||||||
@ -66,7 +66,7 @@ class DumpExtension extends AbstractExtension
|
|||||||
|
|
||||||
$vars = array($vars);
|
$vars = array($vars);
|
||||||
} else {
|
} else {
|
||||||
$vars = func_get_args();
|
$vars = \func_get_args();
|
||||||
unset($vars[0], $vars[1]);
|
unset($vars[0], $vars[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,8 +152,8 @@ class FormExtension extends AbstractExtension implements InitRuntimeInterface
|
|||||||
*/
|
*/
|
||||||
public function isSelectedChoice(ChoiceView $choice, $selectedValue)
|
public function isSelectedChoice(ChoiceView $choice, $selectedValue)
|
||||||
{
|
{
|
||||||
if (is_array($selectedValue)) {
|
if (\is_array($selectedValue)) {
|
||||||
return in_array($choice->value, $selectedValue, true);
|
return \in_array($choice->value, $selectedValue, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $choice->value === $selectedValue;
|
return $choice->value === $selectedValue;
|
||||||
|
@ -97,7 +97,7 @@ class HttpFoundationExtension extends AbstractExtension
|
|||||||
|
|
||||||
if (!$path || '/' !== $path[0]) {
|
if (!$path || '/' !== $path[0]) {
|
||||||
$prefix = $request->getPathInfo();
|
$prefix = $request->getPathInfo();
|
||||||
$last = strlen($prefix) - 1;
|
$last = \strlen($prefix) - 1;
|
||||||
if ($last !== $pos = strrpos($prefix, '/')) {
|
if ($last !== $pos = strrpos($prefix, '/')) {
|
||||||
$prefix = substr($prefix, 0, $pos).'/';
|
$prefix = substr($prefix, 0, $pos).'/';
|
||||||
}
|
}
|
||||||
|
@ -100,7 +100,7 @@ class RoutingExtension extends AbstractExtension
|
|||||||
$argsNode->hasNode(1) ? $argsNode->getNode(1) : null
|
$argsNode->hasNode(1) ? $argsNode->getNode(1) : null
|
||||||
);
|
);
|
||||||
|
|
||||||
if (null === $paramsNode || $paramsNode instanceof ArrayExpression && count($paramsNode) <= 2 &&
|
if (null === $paramsNode || $paramsNode instanceof ArrayExpression && \count($paramsNode) <= 2 &&
|
||||||
(!$paramsNode->hasNode(1) || $paramsNode->getNode(1) instanceof ConstantExpression)
|
(!$paramsNode->hasNode(1) || $paramsNode->getNode(1) instanceof ConstantExpression)
|
||||||
) {
|
) {
|
||||||
return array('html');
|
return array('html');
|
||||||
|
@ -42,8 +42,8 @@ class YamlExtension extends AbstractExtension
|
|||||||
$dumper = new YamlDumper();
|
$dumper = new YamlDumper();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (defined('Symfony\Component\Yaml\Yaml::DUMP_OBJECT')) {
|
if (\defined('Symfony\Component\Yaml\Yaml::DUMP_OBJECT')) {
|
||||||
return $dumper->dump($input, $inline, 0, is_bool($dumpObjects) ? Yaml::DUMP_OBJECT : 0);
|
return $dumper->dump($input, $inline, 0, \is_bool($dumpObjects) ? Yaml::DUMP_OBJECT : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $dumper->dump($input, $inline, 0, false, $dumpObjects);
|
return $dumper->dump($input, $inline, 0, false, $dumpObjects);
|
||||||
@ -51,12 +51,12 @@ class YamlExtension extends AbstractExtension
|
|||||||
|
|
||||||
public function dump($value, $inline = 0, $dumpObjects = false)
|
public function dump($value, $inline = 0, $dumpObjects = false)
|
||||||
{
|
{
|
||||||
if (is_resource($value)) {
|
if (\is_resource($value)) {
|
||||||
return '%Resource%';
|
return '%Resource%';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_array($value) || is_object($value)) {
|
if (\is_array($value) || \is_object($value)) {
|
||||||
return '%'.gettype($value).'% '.$this->encode($value, $inline, $dumpObjects);
|
return '%'.\gettype($value).'% '.$this->encode($value, $inline, $dumpObjects);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->encode($value, $inline, $dumpObjects);
|
return $this->encode($value, $inline, $dumpObjects);
|
||||||
|
@ -100,7 +100,7 @@ class TwigRendererEngine extends AbstractRendererEngine implements TwigRendererE
|
|||||||
|
|
||||||
// Check each theme whether it contains the searched block
|
// Check each theme whether it contains the searched block
|
||||||
if (isset($this->themes[$cacheKey])) {
|
if (isset($this->themes[$cacheKey])) {
|
||||||
for ($i = count($this->themes[$cacheKey]) - 1; $i >= 0; --$i) {
|
for ($i = \count($this->themes[$cacheKey]) - 1; $i >= 0; --$i) {
|
||||||
$this->loadResourcesFromTheme($cacheKey, $this->themes[$cacheKey][$i]);
|
$this->loadResourcesFromTheme($cacheKey, $this->themes[$cacheKey][$i]);
|
||||||
// CONTINUE LOADING (see doc comment)
|
// CONTINUE LOADING (see doc comment)
|
||||||
}
|
}
|
||||||
@ -108,7 +108,7 @@ class TwigRendererEngine extends AbstractRendererEngine implements TwigRendererE
|
|||||||
|
|
||||||
// Check the default themes once we reach the root view without success
|
// Check the default themes once we reach the root view without success
|
||||||
if (!$view->parent) {
|
if (!$view->parent) {
|
||||||
for ($i = count($this->defaultThemes) - 1; $i >= 0; --$i) {
|
for ($i = \count($this->defaultThemes) - 1; $i >= 0; --$i) {
|
||||||
$this->loadResourcesFromTheme($cacheKey, $this->defaultThemes[$i]);
|
$this->loadResourcesFromTheme($cacheKey, $this->defaultThemes[$i]);
|
||||||
// CONTINUE LOADING (see doc comment)
|
// CONTINUE LOADING (see doc comment)
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ class TranslationDefaultDomainNodeVisitor extends AbstractNodeVisitor
|
|||||||
return $node;
|
return $node;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($node instanceof FilterExpression && in_array($node->getNode('filter')->getAttribute('value'), array('trans', 'transchoice'))) {
|
if ($node instanceof FilterExpression && \in_array($node->getNode('filter')->getAttribute('value'), array('trans', 'transchoice'))) {
|
||||||
$arguments = $node->getNode('arguments');
|
$arguments = $node->getNode('arguments');
|
||||||
$ind = 'trans' === $node->getNode('filter')->getAttribute('value') ? 1 : 2;
|
$ind = 'trans' === $node->getNode('filter')->getAttribute('value') ? 1 : 2;
|
||||||
if ($this->isNamedArguments($arguments)) {
|
if ($this->isNamedArguments($arguments)) {
|
||||||
@ -119,7 +119,7 @@ class TranslationDefaultDomainNodeVisitor extends AbstractNodeVisitor
|
|||||||
private function isNamedArguments($arguments)
|
private function isNamedArguments($arguments)
|
||||||
{
|
{
|
||||||
foreach ($arguments as $name => $node) {
|
foreach ($arguments as $name => $node) {
|
||||||
if (!is_int($name)) {
|
if (!\is_int($name)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ class DumpExtensionTest extends TestCase
|
|||||||
array_unshift($args, $context);
|
array_unshift($args, $context);
|
||||||
array_unshift($args, $twig);
|
array_unshift($args, $twig);
|
||||||
|
|
||||||
$dump = call_user_func_array(array($extension, 'dump'), $args);
|
$dump = \call_user_func_array(array($extension, 'dump'), $args);
|
||||||
|
|
||||||
if ($debug) {
|
if ($debug) {
|
||||||
$this->assertStringStartsWith('<script>', $dump);
|
$this->assertStringStartsWith('<script>', $dump);
|
||||||
|
@ -56,7 +56,7 @@ class StopwatchExtensionTest extends TestCase
|
|||||||
|
|
||||||
protected function getStopwatch($events = array())
|
protected function getStopwatch($events = array())
|
||||||
{
|
{
|
||||||
$events = is_array($events) ? $events : array($events);
|
$events = \is_array($events) ? $events : array($events);
|
||||||
$stopwatch = $this->getMockBuilder('Symfony\Component\Stopwatch\Stopwatch')->getMock();
|
$stopwatch = $this->getMockBuilder('Symfony\Component\Stopwatch\Stopwatch')->getMock();
|
||||||
|
|
||||||
$i = -1;
|
$i = -1;
|
||||||
|
@ -207,7 +207,7 @@ class TranslationExtensionTest extends TestCase
|
|||||||
$translator = new Translator('en', new MessageSelector());
|
$translator = new Translator('en', new MessageSelector());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_array($template)) {
|
if (\is_array($template)) {
|
||||||
$loader = new TwigArrayLoader($template);
|
$loader = new TwigArrayLoader($template);
|
||||||
} else {
|
} else {
|
||||||
$loader = new TwigArrayLoader(array('index' => $template));
|
$loader = new TwigArrayLoader(array('index' => $template));
|
||||||
|
@ -90,7 +90,7 @@ class TwigExtractorTest extends TestCase
|
|||||||
$extractor->extract($resources, new MessageCatalogue('en'));
|
$extractor->extract($resources, new MessageCatalogue('en'));
|
||||||
} catch (Error $e) {
|
} catch (Error $e) {
|
||||||
if (method_exists($e, 'getSourceContext')) {
|
if (method_exists($e, 'getSourceContext')) {
|
||||||
$this->assertSame(dirname(__DIR__).strtr('/Fixtures/extractor/syntax_error.twig', '/', DIRECTORY_SEPARATOR), $e->getFile());
|
$this->assertSame(\dirname(__DIR__).strtr('/Fixtures/extractor/syntax_error.twig', '/', DIRECTORY_SEPARATOR), $e->getFile());
|
||||||
$this->assertSame(1, $e->getLine());
|
$this->assertSame(1, $e->getLine());
|
||||||
$this->assertSame('Unclosed "block".', $e->getMessage());
|
$this->assertSame('Unclosed "block".', $e->getMessage());
|
||||||
} else {
|
} else {
|
||||||
|
@ -166,7 +166,7 @@ class Client extends BaseClient
|
|||||||
|
|
||||||
$r = new \ReflectionObject($this->kernel);
|
$r = new \ReflectionObject($this->kernel);
|
||||||
|
|
||||||
$autoloader = dirname($r->getFileName()).'/autoload.php';
|
$autoloader = \dirname($r->getFileName()).'/autoload.php';
|
||||||
if (is_file($autoloader)) {
|
if (is_file($autoloader)) {
|
||||||
$autoloader = str_replace("'", "\\'", $autoloader);
|
$autoloader = str_replace("'", "\\'", $autoloader);
|
||||||
} else {
|
} else {
|
||||||
|
@ -83,7 +83,7 @@ abstract class AbstractConfigCommand extends ContainerDebugCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!$configuration instanceof ConfigurationInterface) {
|
if (!$configuration instanceof ConfigurationInterface) {
|
||||||
throw new \LogicException(sprintf('Configuration class "%s" should implement ConfigurationInterface in order to be dumpable', get_class($configuration)));
|
throw new \LogicException(sprintf('Configuration class "%s" should implement ConfigurationInterface in order to be dumpable', \get_class($configuration)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -227,7 +227,7 @@ EOT
|
|||||||
private function symlink($originDir, $targetDir, $relative = false)
|
private function symlink($originDir, $targetDir, $relative = false)
|
||||||
{
|
{
|
||||||
if ($relative) {
|
if ($relative) {
|
||||||
$originDir = $this->filesystem->makePathRelative($originDir, realpath(dirname($targetDir)));
|
$originDir = $this->filesystem->makePathRelative($originDir, realpath(\dirname($targetDir)));
|
||||||
}
|
}
|
||||||
$this->filesystem->symlink($originDir, $targetDir);
|
$this->filesystem->symlink($originDir, $targetDir);
|
||||||
if (!file_exists($targetDir)) {
|
if (!file_exists($targetDir)) {
|
||||||
|
@ -124,7 +124,7 @@ EOF
|
|||||||
{
|
{
|
||||||
// create a temporary kernel
|
// create a temporary kernel
|
||||||
$realKernel = $this->getContainer()->get('kernel');
|
$realKernel = $this->getContainer()->get('kernel');
|
||||||
$realKernelClass = get_class($realKernel);
|
$realKernelClass = \get_class($realKernel);
|
||||||
$namespace = '';
|
$namespace = '';
|
||||||
if (false !== $pos = strrpos($realKernelClass, '\\')) {
|
if (false !== $pos = strrpos($realKernelClass, '\\')) {
|
||||||
$namespace = substr($realKernelClass, 0, $pos);
|
$namespace = substr($realKernelClass, 0, $pos);
|
||||||
@ -144,8 +144,8 @@ EOF
|
|||||||
$warmer->warmUp($warmupDir);
|
$warmer->warmUp($warmupDir);
|
||||||
|
|
||||||
// fix references to the Kernel in .meta files
|
// fix references to the Kernel in .meta files
|
||||||
$safeTempKernel = str_replace('\\', '\\\\', get_class($tempKernel));
|
$safeTempKernel = str_replace('\\', '\\\\', \get_class($tempKernel));
|
||||||
$realKernelFQN = get_class($realKernel);
|
$realKernelFQN = \get_class($realKernel);
|
||||||
|
|
||||||
foreach (Finder::create()->files()->depth('<3')->name('*.meta')->in($warmupDir) as $file) {
|
foreach (Finder::create()->files()->depth('<3')->name('*.meta')->in($warmupDir) as $file) {
|
||||||
file_put_contents($file, preg_replace(
|
file_put_contents($file, preg_replace(
|
||||||
@ -166,8 +166,8 @@ EOF
|
|||||||
}
|
}
|
||||||
|
|
||||||
// fix references to container's class
|
// fix references to container's class
|
||||||
$tempContainerClass = get_class($tempKernel->getContainer());
|
$tempContainerClass = \get_class($tempKernel->getContainer());
|
||||||
$realContainerClass = get_class($realKernel->getContainer());
|
$realContainerClass = \get_class($realKernel->getContainer());
|
||||||
foreach (Finder::create()->files()->depth('<2')->name($tempContainerClass.'*')->in($warmupDir) as $file) {
|
foreach (Finder::create()->files()->depth('<2')->name($tempContainerClass.'*')->in($warmupDir) as $file) {
|
||||||
$content = str_replace($tempContainerClass, $realContainerClass, file_get_contents($file));
|
$content = str_replace($tempContainerClass, $realContainerClass, file_get_contents($file));
|
||||||
file_put_contents($file, $content);
|
file_put_contents($file, $content);
|
||||||
@ -195,7 +195,7 @@ EOF
|
|||||||
// to avoid the many problems in serialized resources files
|
// to avoid the many problems in serialized resources files
|
||||||
$class = substr($parentClass, 0, -1).'_';
|
$class = substr($parentClass, 0, -1).'_';
|
||||||
// the temp container class must be changed too
|
// the temp container class must be changed too
|
||||||
$containerClass = var_export(substr(get_class($parent->getContainer()), 0, -1).'_', true);
|
$containerClass = var_export(substr(\get_class($parent->getContainer()), 0, -1).'_', true);
|
||||||
$code = <<<EOF
|
$code = <<<EOF
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ abstract class ServerCommand extends ContainerAwareCommand
|
|||||||
*/
|
*/
|
||||||
public function isEnabled()
|
public function isEnabled()
|
||||||
{
|
{
|
||||||
if (\PHP_VERSION_ID < 50400 || defined('HHVM_VERSION')) {
|
if (\PHP_VERSION_ID < 50400 || \defined('HHVM_VERSION')) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ EOF
|
|||||||
{
|
{
|
||||||
$io = new SymfonyStyle($input, $cliOutput = $output);
|
$io = new SymfonyStyle($input, $cliOutput = $output);
|
||||||
|
|
||||||
if (!extension_loaded('pcntl')) {
|
if (!\extension_loaded('pcntl')) {
|
||||||
$io->error(array(
|
$io->error(array(
|
||||||
'This command needs the pcntl extension to run.',
|
'This command needs the pcntl extension to run.',
|
||||||
'You can either install it or use the "server:run" command instead to run the built-in web server.',
|
'You can either install it or use the "server:run" command instead to run the built-in web server.',
|
||||||
|
@ -181,8 +181,8 @@ EOF
|
|||||||
$states[] = self::MESSAGE_UNUSED;
|
$states[] = self::MESSAGE_UNUSED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!in_array(self::MESSAGE_UNUSED, $states) && true === $input->getOption('only-unused')
|
if (!\in_array(self::MESSAGE_UNUSED, $states) && true === $input->getOption('only-unused')
|
||||||
|| !in_array(self::MESSAGE_MISSING, $states) && true === $input->getOption('only-missing')) {
|
|| !\in_array(self::MESSAGE_MISSING, $states) && true === $input->getOption('only-missing')) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -246,7 +246,7 @@ EOF
|
|||||||
if (mb_strlen($string, $encoding) > $length) {
|
if (mb_strlen($string, $encoding) > $length) {
|
||||||
return mb_substr($string, 0, $length - 3, $encoding).'...';
|
return mb_substr($string, 0, $length - 3, $encoding).'...';
|
||||||
}
|
}
|
||||||
} elseif (strlen($string) > $length) {
|
} elseif (\strlen($string) > $length) {
|
||||||
return substr($string, 0, $length - 3).'...';
|
return substr($string, 0, $length - 3).'...';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ EOF
|
|||||||
// check format
|
// check format
|
||||||
$writer = $this->getContainer()->get('translation.writer');
|
$writer = $this->getContainer()->get('translation.writer');
|
||||||
$supportedFormats = $writer->getFormats();
|
$supportedFormats = $writer->getFormats();
|
||||||
if (!in_array($input->getOption('output-format'), $supportedFormats)) {
|
if (!\in_array($input->getOption('output-format'), $supportedFormats)) {
|
||||||
$io->error(array('Wrong output format', 'Supported formats are: '.implode(', ', $supportedFormats).'.'));
|
$io->error(array('Wrong output format', 'Supported formats are: '.implode(', ', $supportedFormats).'.'));
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
@ -145,7 +145,7 @@ EOF
|
|||||||
: new MergeOperation($currentCatalogue, $extractedCatalogue);
|
: new MergeOperation($currentCatalogue, $extractedCatalogue);
|
||||||
|
|
||||||
// Exit if no messages found.
|
// Exit if no messages found.
|
||||||
if (!count($operation->getDomains())) {
|
if (!\count($operation->getDomains())) {
|
||||||
$io->warning('No translation messages were found.');
|
$io->warning('No translation messages were found.');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -171,7 +171,7 @@ EOF
|
|||||||
}, array_keys($operation->getObsoleteMessages($domain)))
|
}, array_keys($operation->getObsoleteMessages($domain)))
|
||||||
);
|
);
|
||||||
|
|
||||||
$domainMessagesCount = count($list);
|
$domainMessagesCount = \count($list);
|
||||||
|
|
||||||
$io->section(sprintf('Messages extracted for domain "<info>%s</info>" (%d message%s)', $domain, $domainMessagesCount, $domainMessagesCount > 1 ? 's' : ''));
|
$io->section(sprintf('Messages extracted for domain "<info>%s</info>" (%d message%s)', $domain, $domainMessagesCount, $domainMessagesCount > 1 ? 's' : ''));
|
||||||
$io->listing($list);
|
$io->listing($list);
|
||||||
|
@ -143,9 +143,9 @@ EOF
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (0 === $errors) {
|
if (0 === $errors) {
|
||||||
$io->success(sprintf('All %d YAML files contain valid syntax.', count($filesInfo)));
|
$io->success(sprintf('All %d YAML files contain valid syntax.', \count($filesInfo)));
|
||||||
} else {
|
} else {
|
||||||
$io->warning(sprintf('%d YAML files have valid syntax and %d contain errors.', count($filesInfo) - $errors, $errors));
|
$io->warning(sprintf('%d YAML files have valid syntax and %d contain errors.', \count($filesInfo) - $errors, $errors));
|
||||||
}
|
}
|
||||||
|
|
||||||
return min($errors, 1);
|
return min($errors, 1);
|
||||||
@ -162,7 +162,7 @@ EOF
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$output->writeln(json_encode($filesInfo, defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES : 0));
|
$output->writeln(json_encode($filesInfo, \defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES : 0));
|
||||||
|
|
||||||
return min($errors, 1);
|
return min($errors, 1);
|
||||||
}
|
}
|
||||||
|
@ -72,11 +72,11 @@ abstract class Descriptor implements DescriptorInterface
|
|||||||
case $object instanceof EventDispatcherInterface:
|
case $object instanceof EventDispatcherInterface:
|
||||||
$this->describeEventDispatcherListeners($object, $options);
|
$this->describeEventDispatcherListeners($object, $options);
|
||||||
break;
|
break;
|
||||||
case is_callable($object):
|
case \is_callable($object):
|
||||||
$this->describeCallable($object, $options);
|
$this->describeCallable($object, $options);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new \InvalidArgumentException(sprintf('Object of type "%s" is not describable.', get_class($object)));
|
throw new \InvalidArgumentException(sprintf('Object of type "%s" is not describable.', \get_class($object)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,11 +198,11 @@ abstract class Descriptor implements DescriptorInterface
|
|||||||
*/
|
*/
|
||||||
protected function formatValue($value)
|
protected function formatValue($value)
|
||||||
{
|
{
|
||||||
if (is_object($value)) {
|
if (\is_object($value)) {
|
||||||
return sprintf('object(%s)', get_class($value));
|
return sprintf('object(%s)', \get_class($value));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_string($value)) {
|
if (\is_string($value)) {
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,7 +218,7 @@ abstract class Descriptor implements DescriptorInterface
|
|||||||
*/
|
*/
|
||||||
protected function formatParameter($value)
|
protected function formatParameter($value)
|
||||||
{
|
{
|
||||||
if (is_bool($value) || is_array($value) || (null === $value)) {
|
if (\is_bool($value) || \is_array($value) || (null === $value)) {
|
||||||
$jsonString = json_encode($value);
|
$jsonString = json_encode($value);
|
||||||
|
|
||||||
if (preg_match('/^(.{60})./us', $jsonString, $matches)) {
|
if (preg_match('/^(.{60})./us', $jsonString, $matches)) {
|
||||||
|
@ -88,7 +88,7 @@ class JsonDescriptor extends Descriptor
|
|||||||
} elseif ($service instanceof Definition) {
|
} elseif ($service instanceof Definition) {
|
||||||
$this->writeData($this->getContainerDefinitionData($service), $options);
|
$this->writeData($this->getContainerDefinitionData($service), $options);
|
||||||
} else {
|
} else {
|
||||||
$this->writeData(get_class($service), $options);
|
$this->writeData(\get_class($service), $options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,7 +111,7 @@ class JsonDescriptor extends Descriptor
|
|||||||
$data['definitions'][$serviceId] = $this->getContainerDefinitionData($service);
|
$data['definitions'][$serviceId] = $this->getContainerDefinitionData($service);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$data['services'][$serviceId] = get_class($service);
|
$data['services'][$serviceId] = \get_class($service);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,7 +169,7 @@ class JsonDescriptor extends Descriptor
|
|||||||
{
|
{
|
||||||
$flags = isset($options['json_encoding']) ? $options['json_encoding'] : 0;
|
$flags = isset($options['json_encoding']) ? $options['json_encoding'] : 0;
|
||||||
|
|
||||||
if (defined('JSON_PRETTY_PRINT')) {
|
if (\defined('JSON_PRETTY_PRINT')) {
|
||||||
$flags |= JSON_PRETTY_PRINT;
|
$flags |= JSON_PRETTY_PRINT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,7 +191,7 @@ class JsonDescriptor extends Descriptor
|
|||||||
'hostRegex' => '' !== $route->getHost() ? $route->compile()->getHostRegex() : '',
|
'hostRegex' => '' !== $route->getHost() ? $route->compile()->getHostRegex() : '',
|
||||||
'scheme' => $route->getSchemes() ? implode('|', $route->getSchemes()) : 'ANY',
|
'scheme' => $route->getSchemes() ? implode('|', $route->getSchemes()) : 'ANY',
|
||||||
'method' => $route->getMethods() ? implode('|', $route->getMethods()) : 'ANY',
|
'method' => $route->getMethods() ? implode('|', $route->getMethods()) : 'ANY',
|
||||||
'class' => get_class($route),
|
'class' => \get_class($route),
|
||||||
'defaults' => $route->getDefaults(),
|
'defaults' => $route->getDefaults(),
|
||||||
'requirements' => $requirements ?: 'NO CUSTOM',
|
'requirements' => $requirements ?: 'NO CUSTOM',
|
||||||
'options' => $route->getOptions(),
|
'options' => $route->getOptions(),
|
||||||
@ -237,7 +237,7 @@ class JsonDescriptor extends Descriptor
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($factory = $definition->getFactory()) {
|
if ($factory = $definition->getFactory()) {
|
||||||
if (is_array($factory)) {
|
if (\is_array($factory)) {
|
||||||
if ($factory[0] instanceof Reference) {
|
if ($factory[0] instanceof Reference) {
|
||||||
$data['factory_service'] = (string) $factory[0];
|
$data['factory_service'] = (string) $factory[0];
|
||||||
} elseif ($factory[0] instanceof Definition) {
|
} elseif ($factory[0] instanceof Definition) {
|
||||||
@ -316,12 +316,12 @@ class JsonDescriptor extends Descriptor
|
|||||||
{
|
{
|
||||||
$data = array();
|
$data = array();
|
||||||
|
|
||||||
if (is_array($callable)) {
|
if (\is_array($callable)) {
|
||||||
$data['type'] = 'function';
|
$data['type'] = 'function';
|
||||||
|
|
||||||
if (is_object($callable[0])) {
|
if (\is_object($callable[0])) {
|
||||||
$data['name'] = $callable[1];
|
$data['name'] = $callable[1];
|
||||||
$data['class'] = get_class($callable[0]);
|
$data['class'] = \get_class($callable[0]);
|
||||||
} else {
|
} else {
|
||||||
if (0 !== strpos($callable[1], 'parent::')) {
|
if (0 !== strpos($callable[1], 'parent::')) {
|
||||||
$data['name'] = $callable[1];
|
$data['name'] = $callable[1];
|
||||||
@ -338,7 +338,7 @@ class JsonDescriptor extends Descriptor
|
|||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_string($callable)) {
|
if (\is_string($callable)) {
|
||||||
$data['type'] = 'function';
|
$data['type'] = 'function';
|
||||||
|
|
||||||
if (false === strpos($callable, '::')) {
|
if (false === strpos($callable, '::')) {
|
||||||
@ -362,7 +362,7 @@ class JsonDescriptor extends Descriptor
|
|||||||
|
|
||||||
if (method_exists($callable, '__invoke')) {
|
if (method_exists($callable, '__invoke')) {
|
||||||
$data['type'] = 'object';
|
$data['type'] = 'object';
|
||||||
$data['name'] = get_class($callable);
|
$data['name'] = \get_class($callable);
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
@ -58,13 +58,13 @@ class MarkdownDescriptor extends Descriptor
|
|||||||
."\n".'- Host Regex: '.('' !== $route->getHost() ? $route->compile()->getHostRegex() : '')
|
."\n".'- Host Regex: '.('' !== $route->getHost() ? $route->compile()->getHostRegex() : '')
|
||||||
."\n".'- Scheme: '.($route->getSchemes() ? implode('|', $route->getSchemes()) : 'ANY')
|
."\n".'- Scheme: '.($route->getSchemes() ? implode('|', $route->getSchemes()) : 'ANY')
|
||||||
."\n".'- Method: '.($route->getMethods() ? implode('|', $route->getMethods()) : 'ANY')
|
."\n".'- Method: '.($route->getMethods() ? implode('|', $route->getMethods()) : 'ANY')
|
||||||
."\n".'- Class: '.get_class($route)
|
."\n".'- Class: '.\get_class($route)
|
||||||
."\n".'- Defaults: '.$this->formatRouterConfig($route->getDefaults())
|
."\n".'- Defaults: '.$this->formatRouterConfig($route->getDefaults())
|
||||||
."\n".'- Requirements: '.($requirements ? $this->formatRouterConfig($requirements) : 'NO CUSTOM')
|
."\n".'- Requirements: '.($requirements ? $this->formatRouterConfig($requirements) : 'NO CUSTOM')
|
||||||
."\n".'- Options: '.$this->formatRouterConfig($route->getOptions());
|
."\n".'- Options: '.$this->formatRouterConfig($route->getOptions());
|
||||||
|
|
||||||
$this->write(isset($options['name'])
|
$this->write(isset($options['name'])
|
||||||
? $options['name']."\n".str_repeat('-', strlen($options['name']))."\n\n".$output
|
? $options['name']."\n".str_repeat('-', \strlen($options['name']))."\n\n".$output
|
||||||
: $output);
|
: $output);
|
||||||
$this->write("\n");
|
$this->write("\n");
|
||||||
}
|
}
|
||||||
@ -89,7 +89,7 @@ class MarkdownDescriptor extends Descriptor
|
|||||||
$this->write("Container tags\n==============");
|
$this->write("Container tags\n==============");
|
||||||
|
|
||||||
foreach ($this->findDefinitionsByTag($builder, $showPrivate) as $tag => $definitions) {
|
foreach ($this->findDefinitionsByTag($builder, $showPrivate) as $tag => $definitions) {
|
||||||
$this->write("\n\n".$tag."\n".str_repeat('-', strlen($tag)));
|
$this->write("\n\n".$tag."\n".str_repeat('-', \strlen($tag)));
|
||||||
foreach ($definitions as $serviceId => $definition) {
|
foreach ($definitions as $serviceId => $definition) {
|
||||||
$this->write("\n\n");
|
$this->write("\n\n");
|
||||||
$this->describeContainerDefinition($definition, array('omit_tags' => true, 'id' => $serviceId));
|
$this->describeContainerDefinition($definition, array('omit_tags' => true, 'id' => $serviceId));
|
||||||
@ -113,7 +113,7 @@ class MarkdownDescriptor extends Descriptor
|
|||||||
} elseif ($service instanceof Definition) {
|
} elseif ($service instanceof Definition) {
|
||||||
$this->describeContainerDefinition($service, $childOptions);
|
$this->describeContainerDefinition($service, $childOptions);
|
||||||
} else {
|
} else {
|
||||||
$this->write(sprintf('**`%s`:** `%s`', $options['id'], get_class($service)));
|
$this->write(sprintf('**`%s`:** `%s`', $options['id'], \get_class($service)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,7 +128,7 @@ class MarkdownDescriptor extends Descriptor
|
|||||||
if (isset($options['tag'])) {
|
if (isset($options['tag'])) {
|
||||||
$title .= ' with tag `'.$options['tag'].'`';
|
$title .= ' with tag `'.$options['tag'].'`';
|
||||||
}
|
}
|
||||||
$this->write($title."\n".str_repeat('=', strlen($title)));
|
$this->write($title."\n".str_repeat('=', \strlen($title)));
|
||||||
|
|
||||||
$serviceIds = isset($options['tag']) && $options['tag'] ? array_keys($builder->findTaggedServiceIds($options['tag'])) : $builder->getServiceIds();
|
$serviceIds = isset($options['tag']) && $options['tag'] ? array_keys($builder->findTaggedServiceIds($options['tag'])) : $builder->getServiceIds();
|
||||||
$showPrivate = isset($options['show_private']) && $options['show_private'];
|
$showPrivate = isset($options['show_private']) && $options['show_private'];
|
||||||
@ -168,7 +168,7 @@ class MarkdownDescriptor extends Descriptor
|
|||||||
$this->write("\n\nServices\n--------\n");
|
$this->write("\n\nServices\n--------\n");
|
||||||
foreach ($services['services'] as $id => $service) {
|
foreach ($services['services'] as $id => $service) {
|
||||||
$this->write("\n");
|
$this->write("\n");
|
||||||
$this->write(sprintf('- `%s`: `%s`', $id, get_class($service)));
|
$this->write(sprintf('- `%s`: `%s`', $id, \get_class($service)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -210,7 +210,7 @@ class MarkdownDescriptor extends Descriptor
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($factory = $definition->getFactory()) {
|
if ($factory = $definition->getFactory()) {
|
||||||
if (is_array($factory)) {
|
if (\is_array($factory)) {
|
||||||
if ($factory[0] instanceof Reference) {
|
if ($factory[0] instanceof Reference) {
|
||||||
$output .= "\n".'- Factory Service: `'.$factory[0].'`';
|
$output .= "\n".'- Factory Service: `'.$factory[0].'`';
|
||||||
} elseif ($factory[0] instanceof Definition) {
|
} elseif ($factory[0] instanceof Definition) {
|
||||||
@ -254,7 +254,7 @@ class MarkdownDescriptor extends Descriptor
|
|||||||
*/
|
*/
|
||||||
protected function describeContainerParameter($parameter, array $options = array())
|
protected function describeContainerParameter($parameter, array $options = array())
|
||||||
{
|
{
|
||||||
$this->write(isset($options['parameter']) ? sprintf("%s\n%s\n\n%s", $options['parameter'], str_repeat('=', strlen($options['parameter'])), $this->formatParameter($parameter)) : $parameter);
|
$this->write(isset($options['parameter']) ? sprintf("%s\n%s\n\n%s", $options['parameter'], str_repeat('=', \strlen($options['parameter'])), $this->formatParameter($parameter)) : $parameter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -300,12 +300,12 @@ class MarkdownDescriptor extends Descriptor
|
|||||||
{
|
{
|
||||||
$string = '';
|
$string = '';
|
||||||
|
|
||||||
if (is_array($callable)) {
|
if (\is_array($callable)) {
|
||||||
$string .= "\n- Type: `function`";
|
$string .= "\n- Type: `function`";
|
||||||
|
|
||||||
if (is_object($callable[0])) {
|
if (\is_object($callable[0])) {
|
||||||
$string .= "\n".sprintf('- Name: `%s`', $callable[1]);
|
$string .= "\n".sprintf('- Name: `%s`', $callable[1]);
|
||||||
$string .= "\n".sprintf('- Class: `%s`', get_class($callable[0]));
|
$string .= "\n".sprintf('- Class: `%s`', \get_class($callable[0]));
|
||||||
} else {
|
} else {
|
||||||
if (0 !== strpos($callable[1], 'parent::')) {
|
if (0 !== strpos($callable[1], 'parent::')) {
|
||||||
$string .= "\n".sprintf('- Name: `%s`', $callable[1]);
|
$string .= "\n".sprintf('- Name: `%s`', $callable[1]);
|
||||||
@ -322,7 +322,7 @@ class MarkdownDescriptor extends Descriptor
|
|||||||
return $this->write($string."\n");
|
return $this->write($string."\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_string($callable)) {
|
if (\is_string($callable)) {
|
||||||
$string .= "\n- Type: `function`";
|
$string .= "\n- Type: `function`";
|
||||||
|
|
||||||
if (false === strpos($callable, '::')) {
|
if (false === strpos($callable, '::')) {
|
||||||
@ -346,7 +346,7 @@ class MarkdownDescriptor extends Descriptor
|
|||||||
|
|
||||||
if (method_exists($callable, '__invoke')) {
|
if (method_exists($callable, '__invoke')) {
|
||||||
$string .= "\n- Type: `object`";
|
$string .= "\n- Type: `object`";
|
||||||
$string .= "\n".sprintf('- Name: `%s`', get_class($callable));
|
$string .= "\n".sprintf('- Name: `%s`', \get_class($callable));
|
||||||
|
|
||||||
return $this->write($string."\n");
|
return $this->write($string."\n");
|
||||||
}
|
}
|
||||||
|
@ -55,8 +55,8 @@ class TextDescriptor extends Descriptor
|
|||||||
$controller = $route->getDefault('_controller');
|
$controller = $route->getDefault('_controller');
|
||||||
if ($controller instanceof \Closure) {
|
if ($controller instanceof \Closure) {
|
||||||
$controller = 'Closure';
|
$controller = 'Closure';
|
||||||
} elseif (is_object($controller)) {
|
} elseif (\is_object($controller)) {
|
||||||
$controller = get_class($controller);
|
$controller = \get_class($controller);
|
||||||
}
|
}
|
||||||
$row[] = $controller;
|
$row[] = $controller;
|
||||||
}
|
}
|
||||||
@ -91,7 +91,7 @@ class TextDescriptor extends Descriptor
|
|||||||
array('Scheme', ($route->getSchemes() ? implode('|', $route->getSchemes()) : 'ANY')),
|
array('Scheme', ($route->getSchemes() ? implode('|', $route->getSchemes()) : 'ANY')),
|
||||||
array('Method', ($route->getMethods() ? implode('|', $route->getMethods()) : 'ANY')),
|
array('Method', ($route->getMethods() ? implode('|', $route->getMethods()) : 'ANY')),
|
||||||
array('Requirements', ($requirements ? $this->formatRouterConfig($requirements) : 'NO CUSTOM')),
|
array('Requirements', ($requirements ? $this->formatRouterConfig($requirements) : 'NO CUSTOM')),
|
||||||
array('Class', get_class($route)),
|
array('Class', \get_class($route)),
|
||||||
array('Defaults', $this->formatRouterConfig($route->getDefaults())),
|
array('Defaults', $this->formatRouterConfig($route->getDefaults())),
|
||||||
array('Options', $this->formatRouterConfig($route->getOptions())),
|
array('Options', $this->formatRouterConfig($route->getOptions())),
|
||||||
);
|
);
|
||||||
@ -154,7 +154,7 @@ class TextDescriptor extends Descriptor
|
|||||||
$options['output']->table(
|
$options['output']->table(
|
||||||
array('Service ID', 'Class'),
|
array('Service ID', 'Class'),
|
||||||
array(
|
array(
|
||||||
array(isset($options['id']) ? $options['id'] : '-', get_class($service)),
|
array(isset($options['id']) ? $options['id'] : '-', \get_class($service)),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -196,10 +196,10 @@ class TextDescriptor extends Descriptor
|
|||||||
foreach ($tags as $tag) {
|
foreach ($tags as $tag) {
|
||||||
foreach ($tag as $key => $value) {
|
foreach ($tag as $key => $value) {
|
||||||
if (!isset($maxTags[$key])) {
|
if (!isset($maxTags[$key])) {
|
||||||
$maxTags[$key] = strlen($key);
|
$maxTags[$key] = \strlen($key);
|
||||||
}
|
}
|
||||||
if (strlen($value) > $maxTags[$key]) {
|
if (\strlen($value) > $maxTags[$key]) {
|
||||||
$maxTags[$key] = strlen($value);
|
$maxTags[$key] = \strlen($value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -207,7 +207,7 @@ class TextDescriptor extends Descriptor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$tagsCount = count($maxTags);
|
$tagsCount = \count($maxTags);
|
||||||
$tagsNames = array_keys($maxTags);
|
$tagsNames = array_keys($maxTags);
|
||||||
|
|
||||||
$tableHeaders = array_merge(array('Service ID'), $tagsNames, array('Class name'));
|
$tableHeaders = array_merge(array('Service ID'), $tagsNames, array('Class name'));
|
||||||
@ -234,7 +234,7 @@ class TextDescriptor extends Descriptor
|
|||||||
$alias = $definition;
|
$alias = $definition;
|
||||||
$tableRows[] = array_merge(array($serviceId, sprintf('alias for "%s"', $alias)), $tagsCount ? array_fill(0, $tagsCount, '') : array());
|
$tableRows[] = array_merge(array($serviceId, sprintf('alias for "%s"', $alias)), $tagsCount ? array_fill(0, $tagsCount, '') : array());
|
||||||
} else {
|
} else {
|
||||||
$tableRows[] = array_merge(array($serviceId, get_class($definition)), $tagsCount ? array_fill(0, $tagsCount, '') : array());
|
$tableRows[] = array_merge(array($serviceId, \get_class($definition)), $tagsCount ? array_fill(0, $tagsCount, '') : array());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -304,7 +304,7 @@ class TextDescriptor extends Descriptor
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($factory = $definition->getFactory()) {
|
if ($factory = $definition->getFactory()) {
|
||||||
if (is_array($factory)) {
|
if (\is_array($factory)) {
|
||||||
if ($factory[0] instanceof Reference) {
|
if ($factory[0] instanceof Reference) {
|
||||||
$tableRows[] = array('Factory Service', $factory[0]);
|
$tableRows[] = array('Factory Service', $factory[0]);
|
||||||
} elseif ($factory[0] instanceof Definition) {
|
} elseif ($factory[0] instanceof Definition) {
|
||||||
@ -418,15 +418,15 @@ class TextDescriptor extends Descriptor
|
|||||||
*/
|
*/
|
||||||
private function formatCallable($callable)
|
private function formatCallable($callable)
|
||||||
{
|
{
|
||||||
if (is_array($callable)) {
|
if (\is_array($callable)) {
|
||||||
if (is_object($callable[0])) {
|
if (\is_object($callable[0])) {
|
||||||
return sprintf('%s::%s()', get_class($callable[0]), $callable[1]);
|
return sprintf('%s::%s()', \get_class($callable[0]), $callable[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return sprintf('%s::%s()', $callable[0], $callable[1]);
|
return sprintf('%s::%s()', $callable[0], $callable[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_string($callable)) {
|
if (\is_string($callable)) {
|
||||||
return sprintf('%s()', $callable);
|
return sprintf('%s()', $callable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -435,7 +435,7 @@ class TextDescriptor extends Descriptor
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (method_exists($callable, '__invoke')) {
|
if (method_exists($callable, '__invoke')) {
|
||||||
return sprintf('%s::__invoke()', get_class($callable));
|
return sprintf('%s::__invoke()', \get_class($callable));
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new \InvalidArgumentException('Callable is not describable.');
|
throw new \InvalidArgumentException('Callable is not describable.');
|
||||||
|
@ -161,7 +161,7 @@ class XmlDescriptor extends Descriptor
|
|||||||
$routeXML->setAttribute('name', $name);
|
$routeXML->setAttribute('name', $name);
|
||||||
}
|
}
|
||||||
|
|
||||||
$routeXML->setAttribute('class', get_class($route));
|
$routeXML->setAttribute('class', \get_class($route));
|
||||||
|
|
||||||
$routeXML->appendChild($pathXML = $dom->createElement('path'));
|
$routeXML->appendChild($pathXML = $dom->createElement('path'));
|
||||||
$pathXML->setAttribute('regex', $route->compile()->getRegex());
|
$pathXML->setAttribute('regex', $route->compile()->getRegex());
|
||||||
@ -273,7 +273,7 @@ class XmlDescriptor extends Descriptor
|
|||||||
} else {
|
} else {
|
||||||
$dom->appendChild($serviceXML = $dom->createElement('service'));
|
$dom->appendChild($serviceXML = $dom->createElement('service'));
|
||||||
$serviceXML->setAttribute('id', $id);
|
$serviceXML->setAttribute('id', $id);
|
||||||
$serviceXML->setAttribute('class', get_class($service));
|
$serviceXML->setAttribute('class', \get_class($service));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $dom;
|
return $dom;
|
||||||
@ -340,7 +340,7 @@ class XmlDescriptor extends Descriptor
|
|||||||
if ($factory = $definition->getFactory()) {
|
if ($factory = $definition->getFactory()) {
|
||||||
$serviceXML->appendChild($factoryXML = $dom->createElement('factory'));
|
$serviceXML->appendChild($factoryXML = $dom->createElement('factory'));
|
||||||
|
|
||||||
if (is_array($factory)) {
|
if (\is_array($factory)) {
|
||||||
if ($factory[0] instanceof Reference) {
|
if ($factory[0] instanceof Reference) {
|
||||||
$factoryXML->setAttribute('service', (string) $factory[0]);
|
$factoryXML->setAttribute('service', (string) $factory[0]);
|
||||||
} elseif ($factory[0] instanceof Definition) {
|
} elseif ($factory[0] instanceof Definition) {
|
||||||
@ -474,12 +474,12 @@ class XmlDescriptor extends Descriptor
|
|||||||
$dom = new \DOMDocument('1.0', 'UTF-8');
|
$dom = new \DOMDocument('1.0', 'UTF-8');
|
||||||
$dom->appendChild($callableXML = $dom->createElement('callable'));
|
$dom->appendChild($callableXML = $dom->createElement('callable'));
|
||||||
|
|
||||||
if (is_array($callable)) {
|
if (\is_array($callable)) {
|
||||||
$callableXML->setAttribute('type', 'function');
|
$callableXML->setAttribute('type', 'function');
|
||||||
|
|
||||||
if (is_object($callable[0])) {
|
if (\is_object($callable[0])) {
|
||||||
$callableXML->setAttribute('name', $callable[1]);
|
$callableXML->setAttribute('name', $callable[1]);
|
||||||
$callableXML->setAttribute('class', get_class($callable[0]));
|
$callableXML->setAttribute('class', \get_class($callable[0]));
|
||||||
} else {
|
} else {
|
||||||
if (0 !== strpos($callable[1], 'parent::')) {
|
if (0 !== strpos($callable[1], 'parent::')) {
|
||||||
$callableXML->setAttribute('name', $callable[1]);
|
$callableXML->setAttribute('name', $callable[1]);
|
||||||
@ -496,7 +496,7 @@ class XmlDescriptor extends Descriptor
|
|||||||
return $dom;
|
return $dom;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_string($callable)) {
|
if (\is_string($callable)) {
|
||||||
$callableXML->setAttribute('type', 'function');
|
$callableXML->setAttribute('type', 'function');
|
||||||
|
|
||||||
if (false === strpos($callable, '::')) {
|
if (false === strpos($callable, '::')) {
|
||||||
@ -520,7 +520,7 @@ class XmlDescriptor extends Descriptor
|
|||||||
|
|
||||||
if (method_exists($callable, '__invoke')) {
|
if (method_exists($callable, '__invoke')) {
|
||||||
$callableXML->setAttribute('type', 'object');
|
$callableXML->setAttribute('type', 'object');
|
||||||
$callableXML->setAttribute('name', get_class($callable));
|
$callableXML->setAttribute('name', \get_class($callable));
|
||||||
|
|
||||||
return $dom;
|
return $dom;
|
||||||
}
|
}
|
||||||
|
@ -355,7 +355,7 @@ class Controller extends ContainerAware
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_object($user = $token->getUser())) {
|
if (!\is_object($user = $token->getUser())) {
|
||||||
// e.g. anonymous authentication
|
// e.g. anonymous authentication
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ class ControllerNameParser
|
|||||||
public function parse($controller)
|
public function parse($controller)
|
||||||
{
|
{
|
||||||
$parts = explode(':', $controller);
|
$parts = explode(':', $controller);
|
||||||
if (3 !== count($parts) || in_array('', $parts, true)) {
|
if (3 !== \count($parts) || \in_array('', $parts, true)) {
|
||||||
throw new \InvalidArgumentException(sprintf('The "%s" controller is not a valid "a:b:c" controller string.', $controller));
|
throw new \InvalidArgumentException(sprintf('The "%s" controller is not a valid "a:b:c" controller string.', $controller));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,7 +78,7 @@ class ControllerNameParser
|
|||||||
$msg = sprintf('The _controller value "%s:%s:%s" maps to a "%s" class, but this class was not found. Create this class or check the spelling of the class and its namespace.', $bundle, $controller, $action, $try);
|
$msg = sprintf('The _controller value "%s:%s:%s" maps to a "%s" class, but this class was not found. Create this class or check the spelling of the class and its namespace.', $bundle, $controller, $action, $try);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($bundles) > 1) {
|
if (\count($bundles) > 1) {
|
||||||
$msg = sprintf('Unable to find controller "%s:%s" in bundles %s.', $bundle, $controller, implode(', ', $bundles));
|
$msg = sprintf('Unable to find controller "%s:%s" in bundles %s.', $bundle, $controller, implode(', ', $bundles));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,7 +136,7 @@ class ControllerNameParser
|
|||||||
}
|
}
|
||||||
|
|
||||||
$lev = levenshtein($nonExistentBundleName, $bundleName);
|
$lev = levenshtein($nonExistentBundleName, $bundleName);
|
||||||
if ($lev <= strlen($nonExistentBundleName) / 3 && (null === $alternative || $lev < $shortest)) {
|
if ($lev <= \strlen($nonExistentBundleName) / 3 && (null === $alternative || $lev < $shortest)) {
|
||||||
$alternative = $bundleName;
|
$alternative = $bundleName;
|
||||||
$shortest = $lev;
|
$shortest = $lev;
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ class RedirectController extends ContainerAware
|
|||||||
}
|
}
|
||||||
|
|
||||||
$attributes = array();
|
$attributes = array();
|
||||||
if (false === $ignoreAttributes || is_array($ignoreAttributes)) {
|
if (false === $ignoreAttributes || \is_array($ignoreAttributes)) {
|
||||||
$attributes = $request->attributes->get('_route_params');
|
$attributes = $request->attributes->get('_route_params');
|
||||||
unset($attributes['route'], $attributes['permanent'], $attributes['ignoreAttributes']);
|
unset($attributes['route'], $attributes['permanent'], $attributes['ignoreAttributes']);
|
||||||
if ($ignoreAttributes) {
|
if ($ignoreAttributes) {
|
||||||
|
@ -24,7 +24,7 @@ class RouterDataCollector extends BaseRouterDataCollector
|
|||||||
{
|
{
|
||||||
public function guessRoute(Request $request, $controller)
|
public function guessRoute(Request $request, $controller)
|
||||||
{
|
{
|
||||||
if (is_array($controller)) {
|
if (\is_array($controller)) {
|
||||||
$controller = $controller[0];
|
$controller = $controller[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ class AddCacheWarmerPass implements CompilerPassInterface
|
|||||||
|
|
||||||
// sort by priority and flatten
|
// sort by priority and flatten
|
||||||
krsort($warmers);
|
krsort($warmers);
|
||||||
$warmers = call_user_func_array('array_merge', $warmers);
|
$warmers = \call_user_func_array('array_merge', $warmers);
|
||||||
|
|
||||||
$container->getDefinition('cache_warmer')->replaceArgument(0, $warmers);
|
$container->getDefinition('cache_warmer')->replaceArgument(0, $warmers);
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ class ConfigCachePass implements CompilerPassInterface
|
|||||||
|
|
||||||
// sort by priority and flatten
|
// sort by priority and flatten
|
||||||
krsort($resourceCheckers);
|
krsort($resourceCheckers);
|
||||||
$resourceCheckers = call_user_func_array('array_merge', $resourceCheckers);
|
$resourceCheckers = \call_user_func_array('array_merge', $resourceCheckers);
|
||||||
|
|
||||||
$container->getDefinition('config_cache_factory')->replaceArgument(0, $resourceCheckers);
|
$container->getDefinition('config_cache_factory')->replaceArgument(0, $resourceCheckers);
|
||||||
}
|
}
|
||||||
|
@ -69,6 +69,6 @@ class PropertyInfoPass implements CompilerPassInterface
|
|||||||
krsort($sortedServices);
|
krsort($sortedServices);
|
||||||
|
|
||||||
// Flatten the array
|
// Flatten the array
|
||||||
return call_user_func_array('array_merge', $sortedServices);
|
return \call_user_func_array('array_merge', $sortedServices);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,6 +65,6 @@ class SerializerPass implements CompilerPassInterface
|
|||||||
krsort($sortedServices);
|
krsort($sortedServices);
|
||||||
|
|
||||||
// Flatten the array
|
// Flatten the array
|
||||||
return call_user_func_array('array_merge', $sortedServices);
|
return \call_user_func_array('array_merge', $sortedServices);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ class TemplatingAssetHelperPass implements CompilerPassInterface
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_array($args[1])) {
|
if (!\is_array($args[1])) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ class TemplatingPass implements CompilerPassInterface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($helpers) > 0) {
|
if (\count($helpers) > 0) {
|
||||||
$definition = $container->getDefinition('templating.engine.php');
|
$definition = $container->getDefinition('templating.engine.php');
|
||||||
$definition->addMethodCall('setHelpers', array($helpers));
|
$definition->addMethodCall('setHelpers', array($helpers));
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ class UnusedTagsPass implements CompilerPassInterface
|
|||||||
|
|
||||||
foreach ($container->findUnusedTags() as $tag) {
|
foreach ($container->findUnusedTags() as $tag) {
|
||||||
// skip whitelisted tags
|
// skip whitelisted tags
|
||||||
if (in_array($tag, $this->whitelist)) {
|
if (\in_array($tag, $this->whitelist)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,7 +70,7 @@ class UnusedTagsPass implements CompilerPassInterface
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (false !== strpos($definedTag, $tag) || levenshtein($tag, $definedTag) <= strlen($tag) / 3) {
|
if (false !== strpos($definedTag, $tag) || levenshtein($tag, $definedTag) <= \strlen($tag) / 3) {
|
||||||
$candidates[] = $definedTag;
|
$candidates[] = $definedTag;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,9 +58,9 @@ class Configuration implements ConfigurationInterface
|
|||||||
->then(function ($v) {
|
->then(function ($v) {
|
||||||
if (!isset($v['templating'])
|
if (!isset($v['templating'])
|
||||||
|| !$v['templating']['assets_version']
|
|| !$v['templating']['assets_version']
|
||||||
&& !count($v['templating']['assets_base_urls']['http'])
|
&& !\count($v['templating']['assets_base_urls']['http'])
|
||||||
&& !count($v['templating']['assets_base_urls']['ssl'])
|
&& !\count($v['templating']['assets_base_urls']['ssl'])
|
||||||
&& !count($v['templating']['packages'])
|
&& !\count($v['templating']['packages'])
|
||||||
) {
|
) {
|
||||||
$v['assets'] = array(
|
$v['assets'] = array(
|
||||||
'version' => null,
|
'version' => null,
|
||||||
@ -78,9 +78,9 @@ class Configuration implements ConfigurationInterface
|
|||||||
->ifTrue(function ($v) { return isset($v['templating']); })
|
->ifTrue(function ($v) { return isset($v['templating']); })
|
||||||
->then(function ($v) {
|
->then(function ($v) {
|
||||||
if ($v['templating']['assets_version']
|
if ($v['templating']['assets_version']
|
||||||
|| count($v['templating']['assets_base_urls']['http'])
|
|| \count($v['templating']['assets_base_urls']['http'])
|
||||||
|| count($v['templating']['assets_base_urls']['ssl'])
|
|| \count($v['templating']['assets_base_urls']['ssl'])
|
||||||
|| count($v['templating']['packages'])
|
|| \count($v['templating']['packages'])
|
||||||
) {
|
) {
|
||||||
@trigger_error('The assets settings under framework.templating are deprecated since Symfony 2.7 and will be removed in 3.0. Use the framework.assets configuration key instead', E_USER_DEPRECATED);
|
@trigger_error('The assets settings under framework.templating are deprecated since Symfony 2.7 and will be removed in 3.0. Use the framework.assets configuration key instead', E_USER_DEPRECATED);
|
||||||
|
|
||||||
@ -128,8 +128,8 @@ class Configuration implements ConfigurationInterface
|
|||||||
->end()
|
->end()
|
||||||
->arrayNode('trusted_proxies')
|
->arrayNode('trusted_proxies')
|
||||||
->beforeNormalization()
|
->beforeNormalization()
|
||||||
->ifTrue(function ($v) { return !is_array($v) && null !== $v; })
|
->ifTrue(function ($v) { return !\is_array($v) && null !== $v; })
|
||||||
->then(function ($v) { return is_bool($v) ? array() : preg_split('/\s*,\s*/', $v); })
|
->then(function ($v) { return \is_bool($v) ? array() : preg_split('/\s*,\s*/', $v); })
|
||||||
->end()
|
->end()
|
||||||
->prototype('scalar')
|
->prototype('scalar')
|
||||||
->validate()
|
->validate()
|
||||||
@ -424,11 +424,11 @@ class Configuration implements ConfigurationInterface
|
|||||||
->useAttributeAsKey('name')
|
->useAttributeAsKey('name')
|
||||||
->prototype('array')
|
->prototype('array')
|
||||||
->beforeNormalization()
|
->beforeNormalization()
|
||||||
->ifTrue(function ($v) { return is_array($v) && isset($v['mime_type']); })
|
->ifTrue(function ($v) { return \is_array($v) && isset($v['mime_type']); })
|
||||||
->then(function ($v) { return $v['mime_type']; })
|
->then(function ($v) { return $v['mime_type']; })
|
||||||
->end()
|
->end()
|
||||||
->beforeNormalization()
|
->beforeNormalization()
|
||||||
->ifTrue(function ($v) { return !is_array($v); })
|
->ifTrue(function ($v) { return !\is_array($v); })
|
||||||
->then(function ($v) { return array($v); })
|
->then(function ($v) { return array($v); })
|
||||||
->end()
|
->end()
|
||||||
->prototype('scalar')->end()
|
->prototype('scalar')->end()
|
||||||
@ -449,7 +449,7 @@ class Configuration implements ConfigurationInterface
|
|||||||
);
|
);
|
||||||
|
|
||||||
foreach ($urls as $i => $url) {
|
foreach ($urls as $i => $url) {
|
||||||
if (is_int($i)) {
|
if (\is_int($i)) {
|
||||||
if (0 === strpos($url, 'https://') || 0 === strpos($url, '//')) {
|
if (0 === strpos($url, 'https://') || 0 === strpos($url, '//')) {
|
||||||
$urls['http'][] = $urls['ssl'][] = $url;
|
$urls['http'][] = $urls['ssl'][] = $url;
|
||||||
} else {
|
} else {
|
||||||
@ -479,7 +479,7 @@ class Configuration implements ConfigurationInterface
|
|||||||
->addDefaultChildrenIfNoneSet()
|
->addDefaultChildrenIfNoneSet()
|
||||||
->prototype('scalar')->defaultValue('FrameworkBundle:Form')->end()
|
->prototype('scalar')->defaultValue('FrameworkBundle:Form')->end()
|
||||||
->validate()
|
->validate()
|
||||||
->ifTrue(function ($v) {return !in_array('FrameworkBundle:Form', $v); })
|
->ifTrue(function ($v) {return !\in_array('FrameworkBundle:Form', $v); })
|
||||||
->then(function ($v) {
|
->then(function ($v) {
|
||||||
return array_merge(array('FrameworkBundle:Form'), $v);
|
return array_merge(array('FrameworkBundle:Form'), $v);
|
||||||
})
|
})
|
||||||
@ -495,7 +495,7 @@ class Configuration implements ConfigurationInterface
|
|||||||
->performNoDeepMerging()
|
->performNoDeepMerging()
|
||||||
->addDefaultsIfNotSet()
|
->addDefaultsIfNotSet()
|
||||||
->beforeNormalization()
|
->beforeNormalization()
|
||||||
->ifTrue(function ($v) { return !is_array($v); })
|
->ifTrue(function ($v) { return !\is_array($v); })
|
||||||
->then(function ($v) { return array($v); })
|
->then(function ($v) { return array($v); })
|
||||||
->end()
|
->end()
|
||||||
->beforeNormalization()
|
->beforeNormalization()
|
||||||
@ -520,7 +520,7 @@ class Configuration implements ConfigurationInterface
|
|||||||
->isRequired()
|
->isRequired()
|
||||||
->requiresAtLeastOneElement()
|
->requiresAtLeastOneElement()
|
||||||
->beforeNormalization()
|
->beforeNormalization()
|
||||||
->ifTrue(function ($v) { return !is_array($v); })
|
->ifTrue(function ($v) { return !\is_array($v); })
|
||||||
->then(function ($v) { return array($v); })
|
->then(function ($v) { return array($v); })
|
||||||
->end()
|
->end()
|
||||||
->prototype('scalar')->end()
|
->prototype('scalar')->end()
|
||||||
@ -530,7 +530,7 @@ class Configuration implements ConfigurationInterface
|
|||||||
->children()
|
->children()
|
||||||
->arrayNode('loaders')
|
->arrayNode('loaders')
|
||||||
->beforeNormalization()
|
->beforeNormalization()
|
||||||
->ifTrue(function ($v) { return !is_array($v); })
|
->ifTrue(function ($v) { return !\is_array($v); })
|
||||||
->then(function ($v) { return array($v); })
|
->then(function ($v) { return array($v); })
|
||||||
->end()
|
->end()
|
||||||
->prototype('scalar')->end()
|
->prototype('scalar')->end()
|
||||||
@ -556,7 +556,7 @@ class Configuration implements ConfigurationInterface
|
|||||||
->performNoDeepMerging()
|
->performNoDeepMerging()
|
||||||
->addDefaultsIfNotSet()
|
->addDefaultsIfNotSet()
|
||||||
->beforeNormalization()
|
->beforeNormalization()
|
||||||
->ifTrue(function ($v) { return !is_array($v); })
|
->ifTrue(function ($v) { return !\is_array($v); })
|
||||||
->then(function ($v) { return array($v); })
|
->then(function ($v) { return array($v); })
|
||||||
->end()
|
->end()
|
||||||
->beforeNormalization()
|
->beforeNormalization()
|
||||||
@ -596,7 +596,7 @@ class Configuration implements ConfigurationInterface
|
|||||||
->arrayNode('base_urls')
|
->arrayNode('base_urls')
|
||||||
->requiresAtLeastOneElement()
|
->requiresAtLeastOneElement()
|
||||||
->beforeNormalization()
|
->beforeNormalization()
|
||||||
->ifTrue(function ($v) { return !is_array($v); })
|
->ifTrue(function ($v) { return !\is_array($v); })
|
||||||
->then(function ($v) { return array($v); })
|
->then(function ($v) { return array($v); })
|
||||||
->end()
|
->end()
|
||||||
->prototype('scalar')->end()
|
->prototype('scalar')->end()
|
||||||
@ -620,7 +620,7 @@ class Configuration implements ConfigurationInterface
|
|||||||
->arrayNode('base_urls')
|
->arrayNode('base_urls')
|
||||||
->requiresAtLeastOneElement()
|
->requiresAtLeastOneElement()
|
||||||
->beforeNormalization()
|
->beforeNormalization()
|
||||||
->ifTrue(function ($v) { return !is_array($v); })
|
->ifTrue(function ($v) { return !\is_array($v); })
|
||||||
->then(function ($v) { return array($v); })
|
->then(function ($v) { return array($v); })
|
||||||
->end()
|
->end()
|
||||||
->prototype('scalar')->end()
|
->prototype('scalar')->end()
|
||||||
@ -687,7 +687,7 @@ class Configuration implements ConfigurationInterface
|
|||||||
->prototype('scalar')->end()
|
->prototype('scalar')->end()
|
||||||
->treatFalseLike(array())
|
->treatFalseLike(array())
|
||||||
->validate()
|
->validate()
|
||||||
->ifTrue(function ($v) { return !is_array($v); })
|
->ifTrue(function ($v) { return !\is_array($v); })
|
||||||
->then(function ($v) { return (array) $v; })
|
->then(function ($v) { return (array) $v; })
|
||||||
->end()
|
->end()
|
||||||
->end()
|
->end()
|
||||||
|
@ -49,7 +49,7 @@ class FrameworkExtension extends Extension
|
|||||||
*/
|
*/
|
||||||
public function load(array $configs, ContainerBuilder $container)
|
public function load(array $configs, ContainerBuilder $container)
|
||||||
{
|
{
|
||||||
$loader = new XmlFileLoader($container, new FileLocator(dirname(__DIR__).'/Resources/config'));
|
$loader = new XmlFileLoader($container, new FileLocator(\dirname(__DIR__).'/Resources/config'));
|
||||||
|
|
||||||
$loader->load('web.xml');
|
$loader->load('web.xml');
|
||||||
$loader->load('services.xml');
|
$loader->load('services.xml');
|
||||||
@ -439,7 +439,7 @@ class FrameworkExtension extends Extension
|
|||||||
$loaders = array_map(function ($loader) { return new Reference($loader); }, $config['loaders']);
|
$loaders = array_map(function ($loader) { return new Reference($loader); }, $config['loaders']);
|
||||||
|
|
||||||
// Use a delegation unless only a single loader was registered
|
// Use a delegation unless only a single loader was registered
|
||||||
if (1 === count($loaders)) {
|
if (1 === \count($loaders)) {
|
||||||
$container->setAlias('templating.loader', (string) reset($loaders));
|
$container->setAlias('templating.loader', (string) reset($loaders));
|
||||||
} else {
|
} else {
|
||||||
$container->getDefinition('templating.loader.chain')->addArgument($loaders);
|
$container->getDefinition('templating.loader.chain')->addArgument($loaders);
|
||||||
@ -468,7 +468,7 @@ class FrameworkExtension extends Extension
|
|||||||
$engines = array_map(function ($engine) { return new Reference('templating.engine.'.$engine); }, $config['engines']);
|
$engines = array_map(function ($engine) { return new Reference('templating.engine.'.$engine); }, $config['engines']);
|
||||||
|
|
||||||
// Use a delegation unless only a single engine was registered
|
// Use a delegation unless only a single engine was registered
|
||||||
if (1 === count($engines)) {
|
if (1 === \count($engines)) {
|
||||||
$container->setAlias('templating', (string) reset($engines));
|
$container->setAlias('templating', (string) reset($engines));
|
||||||
} else {
|
} else {
|
||||||
$templateEngineDefinition = $container->getDefinition('templating.engine.delegating');
|
$templateEngineDefinition = $container->getDefinition('templating.engine.delegating');
|
||||||
@ -484,7 +484,7 @@ class FrameworkExtension extends Extension
|
|||||||
;
|
;
|
||||||
|
|
||||||
// configure the PHP engine if needed
|
// configure the PHP engine if needed
|
||||||
if (in_array('php', $config['engines'], true)) {
|
if (\in_array('php', $config['engines'], true)) {
|
||||||
$loader->load('templating_php.xml');
|
$loader->load('templating_php.xml');
|
||||||
|
|
||||||
$container->setParameter('templating.helper.form.resources', $config['form']['resources']);
|
$container->setParameter('templating.helper.form.resources', $config['form']['resources']);
|
||||||
@ -592,17 +592,17 @@ class FrameworkExtension extends Extension
|
|||||||
if (class_exists('Symfony\Component\Validator\Validation')) {
|
if (class_exists('Symfony\Component\Validator\Validation')) {
|
||||||
$r = new \ReflectionClass('Symfony\Component\Validator\Validation');
|
$r = new \ReflectionClass('Symfony\Component\Validator\Validation');
|
||||||
|
|
||||||
$dirs[] = dirname($r->getFileName()).'/Resources/translations';
|
$dirs[] = \dirname($r->getFileName()).'/Resources/translations';
|
||||||
}
|
}
|
||||||
if (class_exists('Symfony\Component\Form\Form')) {
|
if (class_exists('Symfony\Component\Form\Form')) {
|
||||||
$r = new \ReflectionClass('Symfony\Component\Form\Form');
|
$r = new \ReflectionClass('Symfony\Component\Form\Form');
|
||||||
|
|
||||||
$dirs[] = dirname($r->getFileName()).'/Resources/translations';
|
$dirs[] = \dirname($r->getFileName()).'/Resources/translations';
|
||||||
}
|
}
|
||||||
if (class_exists('Symfony\Component\Security\Core\Exception\AuthenticationException')) {
|
if (class_exists('Symfony\Component\Security\Core\Exception\AuthenticationException')) {
|
||||||
$r = new \ReflectionClass('Symfony\Component\Security\Core\Exception\AuthenticationException');
|
$r = new \ReflectionClass('Symfony\Component\Security\Core\Exception\AuthenticationException');
|
||||||
|
|
||||||
$dirs[] = dirname(dirname($r->getFileName())).'/Resources/translations';
|
$dirs[] = \dirname(\dirname($r->getFileName())).'/Resources/translations';
|
||||||
}
|
}
|
||||||
$rootDir = $container->getParameter('kernel.root_dir');
|
$rootDir = $container->getParameter('kernel.root_dir');
|
||||||
foreach ($container->getParameter('kernel.bundles_metadata') as $name => $bundle) {
|
foreach ($container->getParameter('kernel.bundles_metadata') as $name => $bundle) {
|
||||||
@ -676,11 +676,11 @@ class FrameworkExtension extends Extension
|
|||||||
$container->setParameter('validator.translation_domain', $config['translation_domain']);
|
$container->setParameter('validator.translation_domain', $config['translation_domain']);
|
||||||
|
|
||||||
list($xmlMappings, $yamlMappings) = $this->getValidatorMappingFiles($container);
|
list($xmlMappings, $yamlMappings) = $this->getValidatorMappingFiles($container);
|
||||||
if (count($xmlMappings) > 0) {
|
if (\count($xmlMappings) > 0) {
|
||||||
$validatorBuilder->addMethodCall('addXmlMappings', array($xmlMappings));
|
$validatorBuilder->addMethodCall('addXmlMappings', array($xmlMappings));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($yamlMappings) > 0) {
|
if (\count($yamlMappings) > 0) {
|
||||||
$validatorBuilder->addMethodCall('addYamlMappings', array($yamlMappings));
|
$validatorBuilder->addMethodCall('addYamlMappings', array($yamlMappings));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -719,7 +719,7 @@ class FrameworkExtension extends Extension
|
|||||||
|
|
||||||
if (interface_exists('Symfony\Component\Form\FormInterface')) {
|
if (interface_exists('Symfony\Component\Form\FormInterface')) {
|
||||||
$reflClass = new \ReflectionClass('Symfony\Component\Form\FormInterface');
|
$reflClass = new \ReflectionClass('Symfony\Component\Form\FormInterface');
|
||||||
$files[0][] = dirname($reflClass->getFileName()).'/Resources/config/validation.xml';
|
$files[0][] = \dirname($reflClass->getFileName()).'/Resources/config/validation.xml';
|
||||||
$container->addResource(new FileResource($files[0][0]));
|
$container->addResource(new FileResource($files[0][0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -935,7 +935,7 @@ class FrameworkExtension extends Extension
|
|||||||
*/
|
*/
|
||||||
public function getXsdValidationBasePath()
|
public function getXsdValidationBasePath()
|
||||||
{
|
{
|
||||||
return dirname(__DIR__).'/Resources/config/schema';
|
return \dirname(__DIR__).'/Resources/config/schema';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getNamespace()
|
public function getNamespace()
|
||||||
|
@ -90,7 +90,7 @@ class DelegatingLoader extends BaseDelegatingLoader
|
|||||||
$this->loading = false;
|
$this->loading = false;
|
||||||
|
|
||||||
foreach ($collection->all() as $route) {
|
foreach ($collection->all() as $route) {
|
||||||
if (!is_string($controller = $route->getDefault('_controller')) || !$controller) {
|
if (!\is_string($controller = $route->getDefault('_controller')) || !$controller) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@ class Router extends BaseRouter implements WarmableInterface
|
|||||||
*/
|
*/
|
||||||
private function resolve($value)
|
private function resolve($value)
|
||||||
{
|
{
|
||||||
if (is_array($value)) {
|
if (\is_array($value)) {
|
||||||
foreach ($value as $key => $val) {
|
foreach ($value as $key => $val) {
|
||||||
$value[$key] = $this->resolve($val);
|
$value[$key] = $this->resolve($val);
|
||||||
}
|
}
|
||||||
@ -134,7 +134,7 @@ class Router extends BaseRouter implements WarmableInterface
|
|||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_string($value)) {
|
if (!\is_string($value)) {
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,7 +148,7 @@ class Router extends BaseRouter implements WarmableInterface
|
|||||||
|
|
||||||
$resolved = $container->getParameter($match[1]);
|
$resolved = $container->getParameter($match[1]);
|
||||||
|
|
||||||
if (is_string($resolved) || is_numeric($resolved)) {
|
if (\is_string($resolved) || is_numeric($resolved)) {
|
||||||
return (string) $resolved;
|
return (string) $resolved;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,7 +157,7 @@ class Router extends BaseRouter implements WarmableInterface
|
|||||||
'must be a string or numeric, but it is of type %s.',
|
'must be a string or numeric, but it is of type %s.',
|
||||||
$match[1],
|
$match[1],
|
||||||
$value,
|
$value,
|
||||||
gettype($resolved)
|
\gettype($resolved)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}, $value);
|
}, $value);
|
||||||
|
@ -66,7 +66,7 @@ class DelegatingEngine extends BaseDelegatingEngine implements EngineInterface
|
|||||||
private function resolveEngines()
|
private function resolveEngines()
|
||||||
{
|
{
|
||||||
foreach ($this->engines as $i => $engine) {
|
foreach ($this->engines as $i => $engine) {
|
||||||
if (is_string($engine)) {
|
if (\is_string($engine)) {
|
||||||
$this->engines[$i] = $this->container->get($engine);
|
$this->engines[$i] = $this->container->get($engine);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ class GlobalVariables
|
|||||||
}
|
}
|
||||||
|
|
||||||
$user = $token->getUser();
|
$user = $token->getUser();
|
||||||
if (!is_object($user)) {
|
if (!\is_object($user)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,10 +43,10 @@ class AssetsHelper extends Helper
|
|||||||
public function getUrl($path, $packageName = null, $version = null)
|
public function getUrl($path, $packageName = null, $version = null)
|
||||||
{
|
{
|
||||||
// BC layer to be removed in 3.0
|
// BC layer to be removed in 3.0
|
||||||
if (3 === func_num_args()) {
|
if (3 === \func_num_args()) {
|
||||||
@trigger_error('Forcing a version for an asset was deprecated in 2.7 and will be removed in 3.0.', E_USER_DEPRECATED);
|
@trigger_error('Forcing a version for an asset was deprecated in 2.7 and will be removed in 3.0.', E_USER_DEPRECATED);
|
||||||
|
|
||||||
$args = func_get_args();
|
$args = \func_get_args();
|
||||||
|
|
||||||
return $this->getLegacyAssetUrl($path, $packageName, $args[2]);
|
return $this->getLegacyAssetUrl($path, $packageName, $args[2]);
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,7 @@ class CodeHelper extends Helper
|
|||||||
$short = array_pop($parts);
|
$short = array_pop($parts);
|
||||||
$formattedValue = sprintf('<em>object</em>(<abbr title="%s">%s</abbr>)', $item[1], $short);
|
$formattedValue = sprintf('<em>object</em>(<abbr title="%s">%s</abbr>)', $item[1], $short);
|
||||||
} elseif ('array' === $item[0]) {
|
} elseif ('array' === $item[0]) {
|
||||||
$formattedValue = sprintf('<em>array</em>(%s)', is_array($item[1]) ? $this->formatArgs($item[1]) : $item[1]);
|
$formattedValue = sprintf('<em>array</em>(%s)', \is_array($item[1]) ? $this->formatArgs($item[1]) : $item[1]);
|
||||||
} elseif ('string' === $item[0]) {
|
} elseif ('string' === $item[0]) {
|
||||||
$formattedValue = sprintf("'%s'", htmlspecialchars($item[1], ENT_QUOTES, $this->getCharset()));
|
$formattedValue = sprintf("'%s'", htmlspecialchars($item[1], ENT_QUOTES, $this->getCharset()));
|
||||||
} elseif ('null' === $item[0]) {
|
} elseif ('null' === $item[0]) {
|
||||||
@ -97,7 +97,7 @@ class CodeHelper extends Helper
|
|||||||
$formattedValue = str_replace("\n", '', var_export(htmlspecialchars((string) $item[1], ENT_QUOTES, $this->getCharset()), true));
|
$formattedValue = str_replace("\n", '', var_export(htmlspecialchars((string) $item[1], ENT_QUOTES, $this->getCharset()), true));
|
||||||
}
|
}
|
||||||
|
|
||||||
$result[] = is_int($key) ? $formattedValue : sprintf("'%s' => %s", $key, $formattedValue);
|
$result[] = \is_int($key) ? $formattedValue : sprintf("'%s' => %s", $key, $formattedValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
return implode(', ', $result);
|
return implode(', ', $result);
|
||||||
@ -114,7 +114,7 @@ class CodeHelper extends Helper
|
|||||||
public function fileExcerpt($file, $line)
|
public function fileExcerpt($file, $line)
|
||||||
{
|
{
|
||||||
if (is_readable($file)) {
|
if (is_readable($file)) {
|
||||||
if (extension_loaded('fileinfo')) {
|
if (\extension_loaded('fileinfo')) {
|
||||||
$finfo = new \finfo();
|
$finfo = new \finfo();
|
||||||
|
|
||||||
// Check if the file is an application/octet-stream (eg. Phar file) because highlight_file cannot parse these files
|
// Check if the file is an application/octet-stream (eg. Phar file) because highlight_file cannot parse these files
|
||||||
@ -131,7 +131,7 @@ class CodeHelper extends Helper
|
|||||||
$content = explode('<br />', $code);
|
$content = explode('<br />', $code);
|
||||||
|
|
||||||
$lines = array();
|
$lines = array();
|
||||||
for ($i = max($line - 3, 1), $max = min($line + 3, count($content)); $i <= $max; ++$i) {
|
for ($i = max($line - 3, 1), $max = min($line + 3, \count($content)); $i <= $max; ++$i) {
|
||||||
$lines[] = '<li'.($i == $line ? ' class="selected"' : '').'><code>'.self::fixCodeMarkup($content[$i - 1]).'</code></li>';
|
$lines[] = '<li'.($i == $line ? ' class="selected"' : '').'><code>'.self::fixCodeMarkup($content[$i - 1]).'</code></li>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ class StopwatchHelper extends Helper
|
|||||||
{
|
{
|
||||||
if (null !== $this->stopwatch) {
|
if (null !== $this->stopwatch) {
|
||||||
if (method_exists($this->stopwatch, $method)) {
|
if (method_exists($this->stopwatch, $method)) {
|
||||||
return call_user_func_array(array($this->stopwatch, $method), $arguments);
|
return \call_user_func_array(array($this->stopwatch, $method), $arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new \BadMethodCallException(sprintf('Method "%s" of Stopwatch does not exist', $method));
|
throw new \BadMethodCallException(sprintf('Method "%s" of Stopwatch does not exist', $method));
|
||||||
|
@ -46,7 +46,7 @@ class PhpEngine extends BasePhpEngine implements EngineInterface
|
|||||||
throw new \InvalidArgumentException(sprintf('The helper "%s" is not defined.', $name));
|
throw new \InvalidArgumentException(sprintf('The helper "%s" is not defined.', $name));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_string($this->helpers[$name])) {
|
if (\is_string($this->helpers[$name])) {
|
||||||
$this->helpers[$name] = $this->container->get($this->helpers[$name]);
|
$this->helpers[$name] = $this->container->get($this->helpers[$name]);
|
||||||
$this->helpers[$name]->setCharset($this->charset);
|
$this->helpers[$name]->setCharset($this->charset);
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ class TemplateFilenameParser implements TemplateNameParserInterface
|
|||||||
$parts = explode('/', str_replace('\\', '/', $name));
|
$parts = explode('/', str_replace('\\', '/', $name));
|
||||||
|
|
||||||
$elements = explode('.', array_pop($parts));
|
$elements = explode('.', array_pop($parts));
|
||||||
if (3 > count($elements)) {
|
if (3 > \count($elements)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$engine = array_pop($elements);
|
$engine = array_pop($elements);
|
||||||
|
@ -59,7 +59,7 @@ abstract class KernelTestCase extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!is_dir($dir)) {
|
if (!is_dir($dir)) {
|
||||||
$dir = dirname($dir);
|
$dir = \dirname($dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $dir;
|
return $dir;
|
||||||
@ -82,11 +82,11 @@ abstract class KernelTestCase extends TestCase
|
|||||||
$dir = realpath($reversedArgs[$argIndex - 1]);
|
$dir = realpath($reversedArgs[$argIndex - 1]);
|
||||||
break;
|
break;
|
||||||
} elseif (0 === strpos($testArg, '--configuration=')) {
|
} elseif (0 === strpos($testArg, '--configuration=')) {
|
||||||
$argPath = substr($testArg, strlen('--configuration='));
|
$argPath = substr($testArg, \strlen('--configuration='));
|
||||||
$dir = realpath($argPath);
|
$dir = realpath($argPath);
|
||||||
break;
|
break;
|
||||||
} elseif (0 === strpos($testArg, '-c')) {
|
} elseif (0 === strpos($testArg, '-c')) {
|
||||||
$argPath = substr($testArg, strlen('-c'));
|
$argPath = substr($testArg, \strlen('-c'));
|
||||||
$dir = realpath($argPath);
|
$dir = realpath($argPath);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -122,7 +122,7 @@ abstract class KernelTestCase extends TestCase
|
|||||||
$finder = new Finder();
|
$finder = new Finder();
|
||||||
$finder->name('*Kernel.php')->depth(0)->in($dir);
|
$finder->name('*Kernel.php')->depth(0)->in($dir);
|
||||||
$results = iterator_to_array($finder);
|
$results = iterator_to_array($finder);
|
||||||
if (!count($results)) {
|
if (!\count($results)) {
|
||||||
throw new \RuntimeException('Either set KERNEL_DIR in your phpunit.xml according to https://symfony.com/doc/current/book/testing.html#your-first-functional-test or override the WebTestCase::createKernel() method.');
|
throw new \RuntimeException('Either set KERNEL_DIR in your phpunit.xml according to https://symfony.com/doc/current/book/testing.html#your-first-functional-test or override the WebTestCase::createKernel() method.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,6 +81,6 @@ class CacheClearCommandTest extends TestCase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->assertTrue($found, 'Kernel file should present as resource');
|
$this->assertTrue($found, 'Kernel file should present as resource');
|
||||||
$this->assertRegExp(sprintf('/\'kernel.container_class\'\s*=>\s*\'%s\'/', get_class($this->kernel->getContainer())), file_get_contents($containerFile), 'kernel.container_class is properly set on the dumped container');
|
$this->assertRegExp(sprintf('/\'kernel.container_class\'\s*=>\s*\'%s\'/', \get_class($this->kernel->getContainer())), file_get_contents($containerFile), 'kernel.container_class is properly set on the dumped container');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@ class ControllerResolverTest extends BaseControllerResolverTest
|
|||||||
|
|
||||||
$controller = $resolver->getController($request);
|
$controller = $resolver->getController($request);
|
||||||
|
|
||||||
$this->assertInstanceOf(get_class($this), $controller[0]);
|
$this->assertInstanceOf(\get_class($this), $controller[0]);
|
||||||
$this->assertSame('controllerMethod1', $controller[1]);
|
$this->assertSame('controllerMethod1', $controller[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -254,19 +254,19 @@ abstract class FrameworkExtensionTest extends TestCase
|
|||||||
$files = array_map('realpath', $options['resource_files']['en']);
|
$files = array_map('realpath', $options['resource_files']['en']);
|
||||||
$ref = new \ReflectionClass('Symfony\Component\Validator\Validation');
|
$ref = new \ReflectionClass('Symfony\Component\Validator\Validation');
|
||||||
$this->assertContains(
|
$this->assertContains(
|
||||||
strtr(dirname($ref->getFileName()).'/Resources/translations/validators.en.xlf', '/', DIRECTORY_SEPARATOR),
|
strtr(\dirname($ref->getFileName()).'/Resources/translations/validators.en.xlf', '/', DIRECTORY_SEPARATOR),
|
||||||
$files,
|
$files,
|
||||||
'->registerTranslatorConfiguration() finds Validator translation resources'
|
'->registerTranslatorConfiguration() finds Validator translation resources'
|
||||||
);
|
);
|
||||||
$ref = new \ReflectionClass('Symfony\Component\Form\Form');
|
$ref = new \ReflectionClass('Symfony\Component\Form\Form');
|
||||||
$this->assertContains(
|
$this->assertContains(
|
||||||
strtr(dirname($ref->getFileName()).'/Resources/translations/validators.en.xlf', '/', DIRECTORY_SEPARATOR),
|
strtr(\dirname($ref->getFileName()).'/Resources/translations/validators.en.xlf', '/', DIRECTORY_SEPARATOR),
|
||||||
$files,
|
$files,
|
||||||
'->registerTranslatorConfiguration() finds Form translation resources'
|
'->registerTranslatorConfiguration() finds Form translation resources'
|
||||||
);
|
);
|
||||||
$ref = new \ReflectionClass('Symfony\Component\Security\Core\Security');
|
$ref = new \ReflectionClass('Symfony\Component\Security\Core\Security');
|
||||||
$this->assertContains(
|
$this->assertContains(
|
||||||
strtr(dirname($ref->getFileName()).'/Resources/translations/security.en.xlf', '/', DIRECTORY_SEPARATOR),
|
strtr(\dirname($ref->getFileName()).'/Resources/translations/security.en.xlf', '/', DIRECTORY_SEPARATOR),
|
||||||
$files,
|
$files,
|
||||||
'->registerTranslatorConfiguration() finds Security translation resources'
|
'->registerTranslatorConfiguration() finds Security translation resources'
|
||||||
);
|
);
|
||||||
@ -303,7 +303,7 @@ abstract class FrameworkExtensionTest extends TestCase
|
|||||||
$container = $this->createContainerFromFile('full');
|
$container = $this->createContainerFromFile('full');
|
||||||
|
|
||||||
$ref = new \ReflectionClass('Symfony\Component\Form\Form');
|
$ref = new \ReflectionClass('Symfony\Component\Form\Form');
|
||||||
$xmlMappings = array(dirname($ref->getFileName()).'/Resources/config/validation.xml');
|
$xmlMappings = array(\dirname($ref->getFileName()).'/Resources/config/validation.xml');
|
||||||
|
|
||||||
$calls = $container->getDefinition('validator.builder')->getMethodCalls();
|
$calls = $container->getDefinition('validator.builder')->getMethodCalls();
|
||||||
|
|
||||||
@ -596,7 +596,7 @@ abstract class FrameworkExtensionTest extends TestCase
|
|||||||
|
|
||||||
protected function createContainerFromFile($file, $data = array())
|
protected function createContainerFromFile($file, $data = array())
|
||||||
{
|
{
|
||||||
$cacheKey = md5(get_class($this).$file.serialize($data));
|
$cacheKey = md5(\get_class($this).$file.serialize($data));
|
||||||
if (isset(self::$containerCache[$cacheKey])) {
|
if (isset(self::$containerCache[$cacheKey])) {
|
||||||
return self::$containerCache[$cacheKey];
|
return self::$containerCache[$cacheKey];
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ class AnnotatedController
|
|||||||
*/
|
*/
|
||||||
public function requestDefaultNullAction(Request $request = null)
|
public function requestDefaultNullAction(Request $request = null)
|
||||||
{
|
{
|
||||||
return new Response($request ? get_class($request) : null);
|
return new Response($request ? \get_class($request) : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -68,6 +68,6 @@ class WebTestCase extends BaseWebTestCase
|
|||||||
|
|
||||||
protected static function getVarDir()
|
protected static function getVarDir()
|
||||||
{
|
{
|
||||||
return substr(strrchr(get_called_class(), '\\'), 1);
|
return substr(strrchr(\get_called_class(), '\\'), 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ while ($dir !== $lastDir) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$dir = dirname($dir);
|
$dir = \dirname($dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
use Symfony\Component\Config\Loader\LoaderInterface;
|
use Symfony\Component\Config\Loader\LoaderInterface;
|
||||||
|
@ -36,7 +36,7 @@ class FormHelperDivLayoutTest extends AbstractDivLayoutTest
|
|||||||
// should be moved to the Form component once absolute file paths are supported
|
// should be moved to the Form component once absolute file paths are supported
|
||||||
// by the default name parser in the Templating component
|
// by the default name parser in the Templating component
|
||||||
$reflClass = new \ReflectionClass('Symfony\Bundle\FrameworkBundle\FrameworkBundle');
|
$reflClass = new \ReflectionClass('Symfony\Bundle\FrameworkBundle\FrameworkBundle');
|
||||||
$root = realpath(dirname($reflClass->getFileName()).'/Resources/views');
|
$root = realpath(\dirname($reflClass->getFileName()).'/Resources/views');
|
||||||
$rootTheme = realpath(__DIR__.'/Resources');
|
$rootTheme = realpath(__DIR__.'/Resources');
|
||||||
$templateNameParser = new StubTemplateNameParser($root, $rootTheme);
|
$templateNameParser = new StubTemplateNameParser($root, $rootTheme);
|
||||||
$loader = new FilesystemLoader(array());
|
$loader = new FilesystemLoader(array());
|
||||||
@ -105,7 +105,7 @@ class FormHelperDivLayoutTest extends AbstractDivLayoutTest
|
|||||||
protected function renderEnctype(FormView $view)
|
protected function renderEnctype(FormView $view)
|
||||||
{
|
{
|
||||||
if (!method_exists($form = $this->engine->get('form'), 'enctype')) {
|
if (!method_exists($form = $this->engine->get('form'), 'enctype')) {
|
||||||
$this->markTestSkipped(sprintf('Deprecated method %s->enctype() is not implemented.', get_class($form)));
|
$this->markTestSkipped(sprintf('Deprecated method %s->enctype() is not implemented.', \get_class($form)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return (string) $form->enctype($view);
|
return (string) $form->enctype($view);
|
||||||
|
@ -60,7 +60,7 @@ class FormHelperTableLayoutTest extends AbstractTableLayoutTest
|
|||||||
// should be moved to the Form component once absolute file paths are supported
|
// should be moved to the Form component once absolute file paths are supported
|
||||||
// by the default name parser in the Templating component
|
// by the default name parser in the Templating component
|
||||||
$reflClass = new \ReflectionClass('Symfony\Bundle\FrameworkBundle\FrameworkBundle');
|
$reflClass = new \ReflectionClass('Symfony\Bundle\FrameworkBundle\FrameworkBundle');
|
||||||
$root = realpath(dirname($reflClass->getFileName()).'/Resources/views');
|
$root = realpath(\dirname($reflClass->getFileName()).'/Resources/views');
|
||||||
$rootTheme = realpath(__DIR__.'/Resources');
|
$rootTheme = realpath(__DIR__.'/Resources');
|
||||||
$templateNameParser = new StubTemplateNameParser($root, $rootTheme);
|
$templateNameParser = new StubTemplateNameParser($root, $rootTheme);
|
||||||
$loader = new FilesystemLoader(array());
|
$loader = new FilesystemLoader(array());
|
||||||
@ -94,7 +94,7 @@ class FormHelperTableLayoutTest extends AbstractTableLayoutTest
|
|||||||
protected function renderEnctype(FormView $view)
|
protected function renderEnctype(FormView $view)
|
||||||
{
|
{
|
||||||
if (!method_exists($form = $this->engine->get('form'), 'enctype')) {
|
if (!method_exists($form = $this->engine->get('form'), 'enctype')) {
|
||||||
$this->markTestSkipped(sprintf('Deprecated method %s->enctype() is not implemented.', get_class($form)));
|
$this->markTestSkipped(sprintf('Deprecated method %s->enctype() is not implemented.', \get_class($form)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return (string) $form->enctype($view);
|
return (string) $form->enctype($view);
|
||||||
|
@ -27,7 +27,7 @@ class TemplateNameParserTest extends TestCase
|
|||||||
->expects($this->any())
|
->expects($this->any())
|
||||||
->method('getBundle')
|
->method('getBundle')
|
||||||
->will($this->returnCallback(function ($bundle) {
|
->will($this->returnCallback(function ($bundle) {
|
||||||
if (in_array($bundle, array('SensioFooBundle', 'SensioCmsFooBundle', 'FooBundle'))) {
|
if (\in_array($bundle, array('SensioFooBundle', 'SensioCmsFooBundle', 'FooBundle'))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ class ConstraintValidatorFactoryTest extends TestCase
|
|||||||
{
|
{
|
||||||
public function testGetInstanceCreatesValidator()
|
public function testGetInstanceCreatesValidator()
|
||||||
{
|
{
|
||||||
$class = get_class($this->getMockForAbstractClass('Symfony\\Component\\Validator\\ConstraintValidator'));
|
$class = \get_class($this->getMockForAbstractClass('Symfony\\Component\\Validator\\ConstraintValidator'));
|
||||||
|
|
||||||
$constraint = $this->getMockBuilder('Symfony\\Component\\Validator\\Constraint')->getMock();
|
$constraint = $this->getMockBuilder('Symfony\\Component\\Validator\\Constraint')->getMock();
|
||||||
$constraint
|
$constraint
|
||||||
|
@ -208,7 +208,7 @@ class PhpExtractor extends AbstractFileExtractor implements ExtractorInterface
|
|||||||
} elseif (self::MESSAGE_TOKEN === $item) {
|
} elseif (self::MESSAGE_TOKEN === $item) {
|
||||||
$message = $this->getValue($tokenIterator);
|
$message = $this->getValue($tokenIterator);
|
||||||
|
|
||||||
if (count($sequence) === ($sequenceKey + 1)) {
|
if (\count($sequence) === ($sequenceKey + 1)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} elseif (self::METHOD_ARGUMENTS_TOKEN === $item) {
|
} elseif (self::METHOD_ARGUMENTS_TOKEN === $item) {
|
||||||
|
@ -113,9 +113,9 @@ class PhpStringTokenParser
|
|||||||
if (isset(self::$replacements[$str])) {
|
if (isset(self::$replacements[$str])) {
|
||||||
return self::$replacements[$str];
|
return self::$replacements[$str];
|
||||||
} elseif ('x' === $str[0] || 'X' === $str[0]) {
|
} elseif ('x' === $str[0] || 'X' === $str[0]) {
|
||||||
return chr(hexdec($str));
|
return \chr(hexdec($str));
|
||||||
} else {
|
} else {
|
||||||
return chr(octdec($str));
|
return \chr(octdec($str));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ class TranslationLoader
|
|||||||
$extension = $catalogue->getLocale().'.'.$format;
|
$extension = $catalogue->getLocale().'.'.$format;
|
||||||
$files = $finder->files()->name('*.'.$extension)->in($directory);
|
$files = $finder->files()->name('*.'.$extension)->in($directory);
|
||||||
foreach ($files as $file) {
|
foreach ($files as $file) {
|
||||||
$domain = substr($file->getFilename(), 0, -1 * strlen($extension) - 1);
|
$domain = substr($file->getFilename(), 0, -1 * \strlen($extension) - 1);
|
||||||
$catalogue->addCatalogue($loader->load($file->getPathname(), $catalogue->getLocale(), $domain));
|
$catalogue->addCatalogue($loader->load($file->getPathname(), $catalogue->getLocale(), $domain));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,11 +67,11 @@ class ConstraintValidatorFactory implements ConstraintValidatorFactoryInterface
|
|||||||
|
|
||||||
if (!isset($this->validators[$name])) {
|
if (!isset($this->validators[$name])) {
|
||||||
if (!class_exists($name)) {
|
if (!class_exists($name)) {
|
||||||
throw new ValidatorException(sprintf('Constraint validator "%s" does not exist or it is not enabled. Check the "validatedBy" method in your constraint class "%s".', $name, get_class($constraint)));
|
throw new ValidatorException(sprintf('Constraint validator "%s" does not exist or it is not enabled. Check the "validatedBy" method in your constraint class "%s".', $name, \get_class($constraint)));
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->validators[$name] = new $name();
|
$this->validators[$name] = new $name();
|
||||||
} elseif (is_string($this->validators[$name])) {
|
} elseif (\is_string($this->validators[$name])) {
|
||||||
$this->validators[$name] = $this->container->get($this->validators[$name]);
|
$this->validators[$name] = $this->container->get($this->validators[$name]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ EOF
|
|||||||
foreach ($input->getArgument('arguments') as $argument) {
|
foreach ($input->getArgument('arguments') as $argument) {
|
||||||
$data = explode(':', $argument, 2);
|
$data = explode(':', $argument, 2);
|
||||||
|
|
||||||
if (count($data) > 1) {
|
if (\count($data) > 1) {
|
||||||
$objectIdentities[] = new ObjectIdentity($data[1], strtr($data[0], '/', '\\'));
|
$objectIdentities[] = new ObjectIdentity($data[1], strtr($data[0], '/', '\\'));
|
||||||
} else {
|
} else {
|
||||||
$maskBuilder->add($data[0]);
|
$maskBuilder->add($data[0]);
|
||||||
@ -120,7 +120,7 @@ EOF
|
|||||||
foreach ($userOption as $user) {
|
foreach ($userOption as $user) {
|
||||||
$data = explode(':', $user, 2);
|
$data = explode(':', $user, 2);
|
||||||
|
|
||||||
if (1 === count($data)) {
|
if (1 === \count($data)) {
|
||||||
throw new \InvalidArgumentException('The user must follow the format "Acme/MyUser:username".');
|
throw new \InvalidArgumentException('The user must follow the format "Acme/MyUser:username".');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user