diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md
index 426b55def0001..3d686194101c0 100644
--- a/.github/PULL_REQUEST_TEMPLATE.md
+++ b/.github/PULL_REQUEST_TEMPLATE.md
@@ -1,6 +1,6 @@
| Q | A
| ------------- | ---
-| Branch? | master for features / 3.4, 4.2 or 4.3 for bug fixes
+| Branch? | 4.4 for features / 3.4, 4.2 or 4.3 for bug fixes
| Bug fix? | yes/no
| New feature? | yes/no
| BC breaks? | no
@@ -17,5 +17,6 @@ understand your PR and can be used as a start for the documentation.
Additionally (see https://symfony.com/roadmap):
- Bug fixes must be submitted against the lowest maintained branch where they apply
(lowest branches are regularly merged to upper ones so they get the fixes too).
- - Features and deprecations must be submitted against the master branch.
+ - Features and deprecations must be submitted against branch 4.4.
+ - Legacy code removals go to the master branch.
-->
diff --git a/.php_cs.dist b/.php_cs.dist
index fd6832920b206..ac3e98528132c 100644
--- a/.php_cs.dist
+++ b/.php_cs.dist
@@ -15,7 +15,7 @@ return PhpCsFixer\Config::create()
'ordered_imports' => true,
'protected_to_private' => false,
// Part of @Symfony:risky in PHP-CS-Fixer 2.13.0. To be removed from the config file once upgrading
- 'native_function_invocation' => ['include' => ['@compiler_optimized'], 'scope' => 'namespaced'],
+ 'native_function_invocation' => ['include' => ['@compiler_optimized'], 'scope' => 'namespaced', 'strict' => true],
// Part of future @Symfony ruleset in PHP-CS-Fixer To be removed from the config file once upgrading
'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'],
])
diff --git a/.travis.yml b/.travis.yml
index ed27e7a505280..27621571c938e 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -235,12 +235,12 @@ install:
tfold 'composer update' $COMPOSER_UP
tfold 'phpunit install' ./phpunit install
if [[ $deps = high ]]; then
- echo "$COMPONENTS" | parallel --gnu -j10% "tfold {} 'cd {} && $COMPOSER_UP && $PHPUNIT_X$LEGACY'"
+ echo "$COMPONENTS" | parallel --gnu "tfold {} 'cd {} && $COMPOSER_UP && $PHPUNIT_X$LEGACY'"
elif [[ $deps = low ]]; then
[[ -e ~/php-ext/composer-lowest.lock.tar ]] && tar -xf ~/php-ext/composer-lowest.lock.tar
tar -cf ~/php-ext/composer-lowest.lock.tar --files-from /dev/null
php .github/rm-invalid-lowest-lock-files.php $COMPONENTS
- echo "$COMPONENTS" | parallel --gnu -j10% "tfold {} 'cd {} && ([ -e composer.lock ] && ${COMPOSER_UP/update/install} || $COMPOSER_UP --prefer-lowest --prefer-stable) && $PHPUNIT_X'"
+ echo "$COMPONENTS" | parallel --gnu "tfold {} 'cd {} && ([ -e composer.lock ] && ${COMPOSER_UP/update/install} || $COMPOSER_UP --prefer-lowest --prefer-stable) && $PHPUNIT_X'"
echo "$COMPONENTS" | xargs -n1 -I{} tar --append -f ~/php-ext/composer-lowest.lock.tar {}/composer.lock
else
echo "$COMPONENTS" | parallel --gnu "tfold {} $PHPUNIT_X {}"
diff --git a/CHANGELOG-4.2.md b/CHANGELOG-4.2.md
index 7c7c018037c6d..40e3209d1d568 100644
--- a/CHANGELOG-4.2.md
+++ b/CHANGELOG-4.2.md
@@ -7,6 +7,41 @@ in 4.2 minor versions.
To get the diff for a specific change, go to https://github.com/symfony/symfony/commit/XXX where XXX is the change hash
To get the diff between two versions, go to https://github.com/symfony/symfony/compare/v4.2.0...v4.2.1
+* 4.2.10 (2019-06-26)
+
+ * bug #31972 Add missing rendering of form help block. (alexsegura)
+ * bug #32137 [HttpFoundation] fix accessing session bags (xabbuh)
+ * bug #32164 [EventDispatcher] collect called listeners information only once (xabbuh)
+ * bug #32173 [FrameworkBundle] Fix calling Client::getProfile() before sending a request (dunglas)
+ * bug #32163 [DoctrineBridge] Fix type error (norkunas)
+ * bug #32170 [Security/Core] Don't use ParagonIE_Sodium_Compat (nicolas-grekas)
+ * bug #32094 [Validator] Use LogicException for missing Property Access Component in comparison constraints (Lctrs)
+ * bug #32123 [Form] fix translation domain (xabbuh)
+ * bug #32116 [FrameworkBundle] tag the FileType service as a form type (xabbuh)
+ * bug #32090 [Debug] workaround BC break in PHP 7.3 (nicolas-grekas)
+ * bug #32076 [Lock] Fix PDO prune not called (jderusse)
+ * bug #32071 Fix expired lock not cleaned (jderusse)
+ * bug #32057 [HttpFoundation] Fix SA/phpdoc JsonResponse (ro0NL)
+ * bug #32025 SimpleCacheAdapter fails to cache any item if a namespace is used (moufmouf)
+ * bug #32037 [Form] validate composite constraints in all groups (xabbuh)
+ * bug #32007 [Serializer] Handle true and false appropriately in CSV encoder (battye)
+ * bug #32000 [Routing] fix absolute url generation when scheme is not known (Tobion)
+ * bug #32024 [VarDumper] fix dumping objects that implement __debugInfo() (nicolas-grekas)
+ * bug #31962 Fix reporting unsilenced deprecations from insulated tests (nicolas-grekas)
+ * bug #31925 [Form] fix usage of legacy TranslatorInterface (nicolas-grekas)
+ * bug #31908 [Validator] fix deprecation layer of ValidatorBuilder (nicolas-grekas)
+ * bug #31894 Fix wrong requirements for ocramius/proxy-manager in root composer.json (henrikvolmer)
+ * bug #31865 [Form] Fix wrong DateTime on outdated ICU library (aweelex)
+ * bug #31879 [Cache] Pass arg to get callback everywhere (fancyweb)
+ * bug #31863 [HttpFoundation] Fixed case-sensitive handling of cache-control header in RedirectResponse constructor (Ivo)
+ * bug #31869 Fix json-encoding when JSON_THROW_ON_ERROR is used (nicolas-grekas)
+ * bug #31868 [HttpKernel] Fix handling non-catchable fatal errors (nicolas-grekas)
+ * bug #31860 [HttpFoundation] work around PHP 7.3 bug related to json_encode() (nicolas-grekas)
+ * bug #31407 [Security] added support for updated "distinguished name" format in x509 authentication (Robert Kopera)
+ * bug #31786 [Translation] Fixed case sensitivity of lint:xliff command (javiereguiluz)
+ * bug #31757 [DomCrawler] Fix type error with null Form::$currentUri (chalasr)
+ * bug #31654 [HttpFoundation] Do not set X-Accel-Redirect for paths outside of X-Accel-Mapping (vilius-g)
+
* 4.2.9 (2019-05-28)
* bug #31584 [Workflow] Do not trigger extra guards (lyrixx)
diff --git a/UPGRADE-4.0.md b/UPGRADE-4.0.md
index 8947744a9f180..30a3805bc8a50 100644
--- a/UPGRADE-4.0.md
+++ b/UPGRADE-4.0.md
@@ -297,19 +297,17 @@ Form
`ArrayAccess` in `ResizeFormListener::preSubmit` method has been removed.
* Using callable strings as choice options in ChoiceType is not supported
- anymore in favor of passing PropertyPath instances.
+ anymore.
Before:
```php
- 'choice_value' => new PropertyPath('range'),
'choice_label' => 'strtoupper',
```
After:
```php
- 'choice_value' => 'range',
'choice_label' => function ($choice) {
return strtoupper($choice);
},
diff --git a/UPGRADE-4.2.md b/UPGRADE-4.2.md
index 90cd04d01e69a..3b1f238fa6f84 100644
--- a/UPGRADE-4.2.md
+++ b/UPGRADE-4.2.md
@@ -385,7 +385,7 @@ Validator
* The `symfony/translation` dependency has been removed - run `composer require symfony/translation` if you need the component
* The `checkMX` and `checkHost` options of the `Email` constraint are deprecated
* The component is now decoupled from `symfony/translation` and uses `Symfony\Contracts\Translation\TranslatorInterface` instead
- * The `ValidatorBuilderInterface` has been deprecated and `ValidatorBuilder` made final
+ * The `ValidatorBuilderInterface` has been deprecated and `ValidatorBuilder::setTranslator()` has been made final
* Deprecated validating instances of `\DateTimeInterface` in `DateTimeValidator`, `DateValidator` and `TimeValidator`. Use `Type` instead or remove the constraint if the underlying model is type hinted to `\DateTimeInterface` already.
* Using the `Bic`, `Country`, `Currency`, `Language` and `Locale` constraints without `symfony/intl` is deprecated
* Using the `Email` constraint in strict mode without `egulias/email-validator` is deprecated
diff --git a/UPGRADE-5.0.md b/UPGRADE-5.0.md
index 4ec9e24f4f0ce..a8e7d0aec3f91 100644
--- a/UPGRADE-5.0.md
+++ b/UPGRADE-5.0.md
@@ -259,7 +259,7 @@ Validator
* Calling `EmailValidator::__construct()` method with a boolean parameter has been removed, use `EmailValidator("strict")` instead.
* Removed the `checkDNS` and `dnsMessage` options from the `Url` constraint.
* The component is now decoupled from `symfony/translation` and uses `Symfony\Contracts\Translation\TranslatorInterface` instead
- * The `ValidatorBuilderInterface` has been removed and `ValidatorBuilder` is now final
+ * The `ValidatorBuilderInterface` has been removed
* Removed support for validating instances of `\DateTimeInterface` in `DateTimeValidator`, `DateValidator` and `TimeValidator`. Use `Type` instead or remove the constraint if the underlying model is type hinted to `\DateTimeInterface` already.
* The `symfony/intl` component is now required for using the `Bic`, `Country`, `Currency`, `Language` and `Locale` constraints
* The `egulias/email-validator` component is now required for using the `Email` constraint in strict mode
diff --git a/composer.json b/composer.json
index 71c597d122df6..8e3afd0e41511 100644
--- a/composer.json
+++ b/composer.json
@@ -98,16 +98,17 @@
"doctrine/reflection": "~1.0",
"doctrine/doctrine-bundle": "~1.4",
"monolog/monolog": "~1.11",
- "ocramius/proxy-manager": "~0.4|~1.0|~2.0",
+ "ocramius/proxy-manager": "^2.1",
"predis/predis": "~1.1",
"egulias/email-validator": "~1.2,>=1.2.8|~2.0",
- "symfony/phpunit-bridge": "~3.4|~4.0",
+ "symfony/phpunit-bridge": "~3.4|~4.0|~5.0",
"symfony/security-acl": "~2.8|~3.0",
"phpdocumentor/reflection-docblock": "^3.0|^4.0"
},
"conflict": {
"phpdocumentor/reflection-docblock": "<3.0||>=3.2.0,<3.2.2",
"phpdocumentor/type-resolver": "<0.3.0",
+ "ocramius/proxy-manager": "<2.1",
"phpunit/phpunit": "<5.4.3"
},
"provide": {
diff --git a/phpunit b/phpunit
index 5bbbf0ded1863..dc9e127b78fb7 100755
--- a/phpunit
+++ b/phpunit
@@ -1,7 +1,7 @@
#!/usr/bin/env php
$param) {
if (isset($query['types'][$j])) {
// Transform the param according to the type
diff --git a/src/Symfony/Bridge/Doctrine/Test/DoctrineTestHelper.php b/src/Symfony/Bridge/Doctrine/Test/DoctrineTestHelper.php
index 3f6ffeebb6e2d..24da0b8deec02 100644
--- a/src/Symfony/Bridge/Doctrine/Test/DoctrineTestHelper.php
+++ b/src/Symfony/Bridge/Doctrine/Test/DoctrineTestHelper.php
@@ -58,7 +58,7 @@ public static function createTestConfiguration()
$config = new Configuration();
$config->setEntityNamespaces(['SymfonyTestsDoctrine' => 'Symfony\Bridge\Doctrine\Tests\Fixtures']);
$config->setAutoGenerateProxyClasses(true);
- $config->setProxyDir(\sys_get_temp_dir());
+ $config->setProxyDir(sys_get_temp_dir());
$config->setProxyNamespace('SymfonyTests\Doctrine');
$config->setMetadataDriverImpl(new AnnotationDriver(new AnnotationReader()));
$config->setQueryCacheImpl(new ArrayCache());
diff --git a/src/Symfony/Bridge/Doctrine/Tests/DataCollector/DoctrineDataCollectorTest.php b/src/Symfony/Bridge/Doctrine/Tests/DataCollector/DoctrineDataCollectorTest.php
index 259532879016e..6a33f0680a7a3 100644
--- a/src/Symfony/Bridge/Doctrine/Tests/DataCollector/DoctrineDataCollectorTest.php
+++ b/src/Symfony/Bridge/Doctrine/Tests/DataCollector/DoctrineDataCollectorTest.php
@@ -102,6 +102,18 @@ public function testCollectQueryWithNoParams()
$this->assertTrue($collectedQueries['default'][1]['explainable']);
}
+ public function testCollectQueryWithNoTypes()
+ {
+ $queries = [
+ ['sql' => 'SET sql_mode=(SELECT REPLACE(@@sql_mode, \'ONLY_FULL_GROUP_BY\', \'\'))', 'params' => [], 'types' => null, 'executionMS' => 1],
+ ];
+ $c = $this->createCollector($queries);
+ $c->collect(new Request(), new Response());
+
+ $collectedQueries = $c->getQueries();
+ $this->assertSame([], $collectedQueries['default'][0]['types']);
+ }
+
public function testReset()
{
$queries = [
@@ -166,20 +178,20 @@ private function createCollector($queries)
->getMock();
$connection->expects($this->any())
->method('getDatabasePlatform')
- ->will($this->returnValue(new MySqlPlatform()));
+ ->willReturn(new MySqlPlatform());
$registry = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')->getMock();
$registry
->expects($this->any())
->method('getConnectionNames')
- ->will($this->returnValue(['default' => 'doctrine.dbal.default_connection']));
+ ->willReturn(['default' => 'doctrine.dbal.default_connection']);
$registry
->expects($this->any())
->method('getManagerNames')
- ->will($this->returnValue(['default' => 'doctrine.orm.default_entity_manager']));
+ ->willReturn(['default' => 'doctrine.orm.default_entity_manager']);
$registry->expects($this->any())
->method('getConnection')
- ->will($this->returnValue($connection));
+ ->willReturn($connection);
$logger = $this->getMockBuilder('Doctrine\DBAL\Logging\DebugStack')->getMock();
$logger->queries = $queries;
diff --git a/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/DoctrineExtensionTest.php b/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/DoctrineExtensionTest.php
index 638e47ef3dffa..7e1cef511f6a9 100644
--- a/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/DoctrineExtensionTest.php
+++ b/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/DoctrineExtensionTest.php
@@ -44,9 +44,9 @@ protected function setUp()
$this->extension->expects($this->any())
->method('getObjectManagerElementName')
- ->will($this->returnCallback(function ($name) {
+ ->willReturnCallback(function ($name) {
return 'doctrine.orm.'.$name;
- }));
+ });
}
/**
diff --git a/src/Symfony/Bridge/Doctrine/Tests/Form/DoctrineOrmTypeGuesserTest.php b/src/Symfony/Bridge/Doctrine/Tests/Form/DoctrineOrmTypeGuesserTest.php
index c323385ff1929..d2e101b4cdc58 100644
--- a/src/Symfony/Bridge/Doctrine/Tests/Form/DoctrineOrmTypeGuesserTest.php
+++ b/src/Symfony/Bridge/Doctrine/Tests/Form/DoctrineOrmTypeGuesserTest.php
@@ -34,47 +34,47 @@ public function requiredProvider()
// Simple field, not nullable
$classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock();
$classMetadata->fieldMappings['field'] = true;
- $classMetadata->expects($this->once())->method('isNullable')->with('field')->will($this->returnValue(false));
+ $classMetadata->expects($this->once())->method('isNullable')->with('field')->willReturn(false);
$return[] = [$classMetadata, new ValueGuess(true, Guess::HIGH_CONFIDENCE)];
// Simple field, nullable
$classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock();
$classMetadata->fieldMappings['field'] = true;
- $classMetadata->expects($this->once())->method('isNullable')->with('field')->will($this->returnValue(true));
+ $classMetadata->expects($this->once())->method('isNullable')->with('field')->willReturn(true);
$return[] = [$classMetadata, new ValueGuess(false, Guess::MEDIUM_CONFIDENCE)];
// One-to-one, nullable (by default)
$classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock();
- $classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->will($this->returnValue(true));
+ $classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->willReturn(true);
$mapping = ['joinColumns' => [[]]];
- $classMetadata->expects($this->once())->method('getAssociationMapping')->with('field')->will($this->returnValue($mapping));
+ $classMetadata->expects($this->once())->method('getAssociationMapping')->with('field')->willReturn($mapping);
$return[] = [$classMetadata, new ValueGuess(false, Guess::HIGH_CONFIDENCE)];
// One-to-one, nullable (explicit)
$classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock();
- $classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->will($this->returnValue(true));
+ $classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->willReturn(true);
$mapping = ['joinColumns' => [['nullable' => true]]];
- $classMetadata->expects($this->once())->method('getAssociationMapping')->with('field')->will($this->returnValue($mapping));
+ $classMetadata->expects($this->once())->method('getAssociationMapping')->with('field')->willReturn($mapping);
$return[] = [$classMetadata, new ValueGuess(false, Guess::HIGH_CONFIDENCE)];
// One-to-one, not nullable
$classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock();
- $classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->will($this->returnValue(true));
+ $classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->willReturn(true);
$mapping = ['joinColumns' => [['nullable' => false]]];
- $classMetadata->expects($this->once())->method('getAssociationMapping')->with('field')->will($this->returnValue($mapping));
+ $classMetadata->expects($this->once())->method('getAssociationMapping')->with('field')->willReturn($mapping);
$return[] = [$classMetadata, new ValueGuess(true, Guess::HIGH_CONFIDENCE)];
// One-to-many, no clue
$classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock();
- $classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->will($this->returnValue(false));
+ $classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->willReturn(false);
$return[] = [$classMetadata, null];
@@ -84,10 +84,10 @@ public function requiredProvider()
private function getGuesser(ClassMetadata $classMetadata)
{
$em = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectManager')->getMock();
- $em->expects($this->once())->method('getClassMetaData')->with('TestEntity')->will($this->returnValue($classMetadata));
+ $em->expects($this->once())->method('getClassMetaData')->with('TestEntity')->willReturn($classMetadata);
$registry = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')->getMock();
- $registry->expects($this->once())->method('getManagers')->will($this->returnValue([$em]));
+ $registry->expects($this->once())->method('getManagers')->willReturn([$em]);
return new DoctrineOrmTypeGuesser($registry);
}
diff --git a/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypePerformanceTest.php b/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypePerformanceTest.php
index 5012171542f7b..5dc184fb91009 100644
--- a/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypePerformanceTest.php
+++ b/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypePerformanceTest.php
@@ -38,11 +38,11 @@ protected function getExtensions()
$manager->expects($this->any())
->method('getManager')
- ->will($this->returnValue($this->em));
+ ->willReturn($this->em);
$manager->expects($this->any())
->method('getManagerForClass')
- ->will($this->returnValue($this->em));
+ ->willReturn($this->em);
return [
new CoreExtension(),
diff --git a/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php b/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php
index 1cb59c38436ef..7a806d76cd7fa 100644
--- a/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php
+++ b/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php
@@ -1087,7 +1087,7 @@ public function testGetManagerForClassIfNoEm()
$this->emRegistry->expects($this->once())
->method('getManagerForClass')
->with(self::SINGLE_IDENT_CLASS)
- ->will($this->returnValue($this->em));
+ ->willReturn($this->em);
$this->factory->createNamed('name', static::TESTED_TYPE, null, [
'class' => self::SINGLE_IDENT_CLASS,
@@ -1237,7 +1237,7 @@ protected function createRegistryMock($name, $em)
$registry->expects($this->any())
->method('getManager')
->with($this->equalTo($name))
- ->will($this->returnValue($em));
+ ->willReturn($em);
return $registry;
}
diff --git a/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php b/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php
index 7188a3abc1a75..e88a0a715c391 100644
--- a/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php
+++ b/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php
@@ -188,7 +188,7 @@ private function getManager($em, $name = null)
$manager->expects($this->any())
->method('getManager')
->with($this->equalTo($name))
- ->will($this->returnValue($em));
+ ->willReturn($em);
return $manager;
}
diff --git a/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php b/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php
index 60007eb8a3ba8..24a7f555f4f67 100644
--- a/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php
+++ b/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php
@@ -82,7 +82,7 @@ protected function createRegistryMock(ObjectManager $em = null)
$registry->expects($this->any())
->method('getManager')
->with($this->equalTo(self::EM_NAME))
- ->will($this->returnValue($em));
+ ->willReturn($em);
return $registry;
}
@@ -104,14 +104,14 @@ protected function createEntityManagerMock($repositoryMock)
;
$em->expects($this->any())
->method('getRepository')
- ->will($this->returnValue($repositoryMock))
+ ->willReturn($repositoryMock)
;
$classMetadata = $this->getMockBuilder('Doctrine\Common\Persistence\Mapping\ClassMetadata')->getMock();
$classMetadata
->expects($this->any())
->method('hasField')
- ->will($this->returnValue(true))
+ ->willReturn(true)
;
$reflParser = $this->getMockBuilder('Doctrine\Common\Reflection\StaticReflectionParser')
->disableOriginalConstructor()
@@ -125,12 +125,12 @@ protected function createEntityManagerMock($repositoryMock)
$refl
->expects($this->any())
->method('getValue')
- ->will($this->returnValue(true))
+ ->willReturn(true)
;
$classMetadata->reflFields = ['name' => $refl];
$em->expects($this->any())
->method('getClassMetadata')
- ->will($this->returnValue($classMetadata))
+ ->willReturn($classMetadata)
;
return $em;
@@ -366,7 +366,7 @@ public function testValidateUniquenessUsingCustomRepositoryMethod()
$repository = $this->createRepositoryMock();
$repository->expects($this->once())
->method('findByCustom')
- ->will($this->returnValue([]))
+ ->willReturn([])
;
$this->em = $this->createEntityManagerMock($repository);
$this->registry = $this->createRegistryMock($this->em);
@@ -394,15 +394,15 @@ public function testValidateUniquenessWithUnrewoundArray()
$repository = $this->createRepositoryMock();
$repository->expects($this->once())
->method('findByCustom')
- ->will(
- $this->returnCallback(function () use ($entity) {
+ ->willReturnCallback(
+ function () use ($entity) {
$returnValue = [
$entity,
];
next($returnValue);
return $returnValue;
- })
+ }
)
;
$this->em = $this->createEntityManagerMock($repository);
@@ -430,7 +430,7 @@ public function testValidateResultTypes($entity1, $result)
$repository = $this->createRepositoryMock();
$repository->expects($this->once())
->method('findByCustom')
- ->will($this->returnValue($result))
+ ->willReturn($result)
;
$this->em = $this->createEntityManagerMock($repository);
$this->registry = $this->createRegistryMock($this->em);
@@ -564,7 +564,7 @@ public function testValidateUniquenessWithArrayValue()
$repository->expects($this->once())
->method('findByCustom')
- ->will($this->returnValue([$entity1]))
+ ->willReturn([$entity1])
;
$this->em->persist($entity1);
@@ -635,7 +635,7 @@ public function testValidateUniquenessOnNullResult()
$repository = $this->createRepositoryMock();
$repository
->method('find')
- ->will($this->returnValue(null))
+ ->willReturn(null)
;
$this->em = $this->createEntityManagerMock($repository);
diff --git a/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php b/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php
index 47cb2bd730317..cf0ed8c962101 100644
--- a/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php
+++ b/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php
@@ -186,7 +186,7 @@ private function formatWithIdentifiers(ObjectManager $em, ClassMetadata $class,
return $this->formatValue($value, self::PRETTY_DATE);
}
- if (\method_exists($value, '__toString')) {
+ if (method_exists($value, '__toString')) {
return (string) $value;
}
diff --git a/src/Symfony/Bridge/Monolog/Processor/DebugProcessor.php b/src/Symfony/Bridge/Monolog/Processor/DebugProcessor.php
index 24a670de79630..f4e37ff44e739 100644
--- a/src/Symfony/Bridge/Monolog/Processor/DebugProcessor.php
+++ b/src/Symfony/Bridge/Monolog/Processor/DebugProcessor.php
@@ -67,7 +67,7 @@ public function getLogs(/* Request $request = null */)
@trigger_error(sprintf('The "%s()" method will have a new "Request $request = null" argument in version 5.0, not defining it is deprecated since Symfony 4.2.', __METHOD__), E_USER_DEPRECATED);
}
- if (1 <= \func_num_args() && null !== $request = \func_get_arg(0)) {
+ if (1 <= \func_num_args() && null !== $request = func_get_arg(0)) {
return $this->records[spl_object_hash($request)] ?? [];
}
@@ -89,7 +89,7 @@ public function countErrors(/* Request $request = null */)
@trigger_error(sprintf('The "%s()" method will have a new "Request $request = null" argument in version 5.0, not defining it is deprecated since Symfony 4.2.', __METHOD__), E_USER_DEPRECATED);
}
- if (1 <= \func_num_args() && null !== $request = \func_get_arg(0)) {
+ if (1 <= \func_num_args() && null !== $request = func_get_arg(0)) {
return $this->errorCount[spl_object_hash($request)] ?? 0;
}
diff --git a/src/Symfony/Bridge/Monolog/Tests/Handler/ConsoleHandlerTest.php b/src/Symfony/Bridge/Monolog/Tests/Handler/ConsoleHandlerTest.php
index 00106c54e162d..4ccffbe14b3f9 100644
--- a/src/Symfony/Bridge/Monolog/Tests/Handler/ConsoleHandlerTest.php
+++ b/src/Symfony/Bridge/Monolog/Tests/Handler/ConsoleHandlerTest.php
@@ -50,7 +50,7 @@ public function testVerbosityMapping($verbosity, $level, $isHandling, array $map
$output
->expects($this->atLeastOnce())
->method('getVerbosity')
- ->will($this->returnValue($verbosity))
+ ->willReturn($verbosity)
;
$handler = new ConsoleHandler($output, true, $map);
$this->assertSame($isHandling, $handler->isHandling(['level' => $level]),
@@ -114,12 +114,12 @@ public function testVerbosityChanged()
$output
->expects($this->at(0))
->method('getVerbosity')
- ->will($this->returnValue(OutputInterface::VERBOSITY_QUIET))
+ ->willReturn(OutputInterface::VERBOSITY_QUIET)
;
$output
->expects($this->at(1))
->method('getVerbosity')
- ->will($this->returnValue(OutputInterface::VERBOSITY_DEBUG))
+ ->willReturn(OutputInterface::VERBOSITY_DEBUG)
;
$handler = new ConsoleHandler($output);
$this->assertFalse($handler->isHandling(['level' => Logger::NOTICE]),
@@ -144,7 +144,7 @@ public function testWritingAndFormatting()
$output
->expects($this->any())
->method('getVerbosity')
- ->will($this->returnValue(OutputInterface::VERBOSITY_DEBUG))
+ ->willReturn(OutputInterface::VERBOSITY_DEBUG)
;
$output
->expects($this->once())
diff --git a/src/Symfony/Bridge/Monolog/Tests/Processor/WebProcessorTest.php b/src/Symfony/Bridge/Monolog/Tests/Processor/WebProcessorTest.php
index 6b61b5c986fc1..eb6b6449a3609 100644
--- a/src/Symfony/Bridge/Monolog/Tests/Processor/WebProcessorTest.php
+++ b/src/Symfony/Bridge/Monolog/Tests/Processor/WebProcessorTest.php
@@ -92,10 +92,10 @@ private function createRequestEvent($additionalServerParameters = []): array
->getMock();
$event->expects($this->any())
->method('isMasterRequest')
- ->will($this->returnValue(true));
+ ->willReturn(true);
$event->expects($this->any())
->method('getRequest')
- ->will($this->returnValue($request));
+ ->willReturn($request);
return [$event, $server];
}
diff --git a/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php b/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php
index cf2723796106e..bb1e8ab4c2f0a 100644
--- a/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php
+++ b/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php
@@ -53,7 +53,7 @@ public function __construct(array $mockedNamespaces = array())
Blacklist::$blacklistedClassNames['\Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerTrait'] = 2;
}
- $enableDebugClassLoader = \class_exists('Symfony\Component\Debug\DebugClassLoader');
+ $enableDebugClassLoader = class_exists('Symfony\Component\Debug\DebugClassLoader');
foreach ($mockedNamespaces as $type => $namespaces) {
if (!\is_array($namespaces)) {
@@ -284,7 +284,8 @@ public function endTest($test, $time)
foreach ($deprecations ? unserialize($deprecations) : array() as $deprecation) {
$error = serialize(array('deprecation' => $deprecation[1], 'class' => $className, 'method' => $test->getName(false), 'triggering_file' => isset($deprecation[2]) ? $deprecation[2] : null));
if ($deprecation[0]) {
- @trigger_error($error, E_USER_DEPRECATED);
+ // unsilenced on purpose
+ trigger_error($error, E_USER_DEPRECATED);
} else {
@trigger_error($error, E_USER_DEPRECATED);
}
diff --git a/src/Symfony/Bridge/PhpUnit/bin/simple-phpunit b/src/Symfony/Bridge/PhpUnit/bin/simple-phpunit
index 399866eb86d90..794984b1fc0e6 100755
--- a/src/Symfony/Bridge/PhpUnit/bin/simple-phpunit
+++ b/src/Symfony/Bridge/PhpUnit/bin/simple-phpunit
@@ -11,7 +11,7 @@
*/
// Please update when phpunit needs to be reinstalled with fresh deps:
-// Cache-Id-Version: 2018-11-20 15:30 UTC
+// Cache-Id-Version: 2019-06-26 11:00 UTC
error_reporting(-1);
diff --git a/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php b/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php
index 70ca302affeb4..e09d54074862d 100644
--- a/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php
+++ b/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php
@@ -99,7 +99,7 @@ public function getProxyCode(Definition $definition)
private static function getProxyManagerVersion(): string
{
- if (!\class_exists(Version::class)) {
+ if (!class_exists(Version::class)) {
return '0.0.1';
}
diff --git a/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_layout.html.twig b/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_layout.html.twig
index 11e8f3f70b590..09d21809940cf 100644
--- a/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_layout.html.twig
+++ b/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_layout.html.twig
@@ -114,6 +114,7 @@
{{- form_label(form) }} {# -#}
{{ form_widget(form, widget_attr) }} {# -#}
+ {{- form_help(form) -}}
{{ form_errors(form) }} {# -#}
{# -#}
{%- endblock form_row %}
diff --git a/src/Symfony/Bridge/Twig/Tests/Command/DebugCommandTest.php b/src/Symfony/Bridge/Twig/Tests/Command/DebugCommandTest.php
index cf46c8e620069..ed76f2e380d2c 100644
--- a/src/Symfony/Bridge/Twig/Tests/Command/DebugCommandTest.php
+++ b/src/Symfony/Bridge/Twig/Tests/Command/DebugCommandTest.php
@@ -295,7 +295,7 @@ public function testWithGlobals()
$tester = $this->createCommandTester([], [], null, null, false, ['message' => $message]);
$tester->execute([], ['decorated' => true]);
$display = $tester->getDisplay();
- $this->assertContains(\json_encode($message), $display);
+ $this->assertContains(json_encode($message), $display);
}
public function testWithGlobalsJson()
@@ -304,7 +304,7 @@ public function testWithGlobalsJson()
$tester = $this->createCommandTester([], [], null, null, false, $globals);
$tester->execute(['--format' => 'json'], ['decorated' => true]);
$display = $tester->getDisplay();
- $display = \json_decode($display, true);
+ $display = json_decode($display, true);
$this->assertSame($globals, $display['globals']);
}
@@ -313,10 +313,10 @@ public function testWithFilter()
$tester = $this->createCommandTester();
$tester->execute(['--format' => 'json'], ['decorated' => false]);
$display = $tester->getDisplay();
- $display1 = \json_decode($display, true);
+ $display1 = json_decode($display, true);
$tester->execute(['--filter' => 'date', '--format' => 'json'], ['decorated' => false]);
$display = $tester->getDisplay();
- $display2 = \json_decode($display, true);
+ $display2 = json_decode($display, true);
$this->assertNotSame($display1, $display2);
}
diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/HttpKernelExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/HttpKernelExtensionTest.php
index 9fe36b40c9063..22084ec1ae616 100644
--- a/src/Symfony/Bridge/Twig/Tests/Extension/HttpKernelExtensionTest.php
+++ b/src/Symfony/Bridge/Twig/Tests/Extension/HttpKernelExtensionTest.php
@@ -62,7 +62,7 @@ public function testUnknownFragmentRenderer()
protected function getFragmentHandler($return)
{
$strategy = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Fragment\\FragmentRendererInterface')->getMock();
- $strategy->expects($this->once())->method('getName')->will($this->returnValue('inline'));
+ $strategy->expects($this->once())->method('getName')->willReturn('inline');
$strategy->expects($this->once())->method('render')->will($return);
$context = $this->getMockBuilder('Symfony\\Component\\HttpFoundation\\RequestStack')
@@ -70,7 +70,7 @@ protected function getFragmentHandler($return)
->getMock()
;
- $context->expects($this->any())->method('getCurrentRequest')->will($this->returnValue(Request::create('/')));
+ $context->expects($this->any())->method('getCurrentRequest')->willReturn(Request::create('/'));
return new FragmentHandler($context, [$strategy], false);
}
@@ -82,9 +82,9 @@ protected function renderTemplate(FragmentHandler $renderer, $template = '{{ ren
$twig->addExtension(new HttpKernelExtension());
$loader = $this->getMockBuilder('Twig\RuntimeLoader\RuntimeLoaderInterface')->getMock();
- $loader->expects($this->any())->method('load')->will($this->returnValueMap([
+ $loader->expects($this->any())->method('load')->willReturnMap([
['Symfony\Bridge\Twig\Extension\HttpKernelRuntime', new HttpKernelRuntime($renderer)],
- ]));
+ ]);
$twig->addRuntimeLoader($loader);
return $twig->render('index');
diff --git a/src/Symfony/Bridge/Twig/UndefinedCallableHandler.php b/src/Symfony/Bridge/Twig/UndefinedCallableHandler.php
index ff88c69852570..8c6253ef2b222 100644
--- a/src/Symfony/Bridge/Twig/UndefinedCallableHandler.php
+++ b/src/Symfony/Bridge/Twig/UndefinedCallableHandler.php
@@ -85,7 +85,7 @@ public static function onUndefinedFunction($name)
private static function onUndefined($name, $type, $component)
{
- if (\class_exists(FullStack::class) && isset(self::$fullStackEnable[$component])) {
+ if (class_exists(FullStack::class) && isset(self::$fullStackEnable[$component])) {
throw new SyntaxError(sprintf('Did you forget to %s? Unknown %s "%s".', self::$fullStackEnable[$component], $type, $name));
}
diff --git a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AnnotationsCacheWarmer.php b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AnnotationsCacheWarmer.php
index f3d6a875e0274..340198e5e2c1b 100644
--- a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AnnotationsCacheWarmer.php
+++ b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AnnotationsCacheWarmer.php
@@ -40,7 +40,7 @@ public function __construct(Reader $annotationReader, string $phpArrayFile, $exc
if ($excludeRegexp instanceof CacheItemPoolInterface) {
@trigger_error(sprintf('The CacheItemPoolInterface $fallbackPool argument of "%s()" is deprecated since Symfony 4.2, you should not pass it anymore.', __METHOD__), E_USER_DEPRECATED);
$excludeRegexp = $debug;
- $debug = 4 < \func_num_args() && \func_get_arg(4);
+ $debug = 4 < \func_num_args() && func_get_arg(4);
}
parent::__construct($phpArrayFile);
$this->annotationReader = $annotationReader;
diff --git a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/SerializerCacheWarmer.php b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/SerializerCacheWarmer.php
index 535161b1197e1..41a8aaa04de2a 100644
--- a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/SerializerCacheWarmer.php
+++ b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/SerializerCacheWarmer.php
@@ -36,7 +36,7 @@ class SerializerCacheWarmer extends AbstractPhpFileCacheWarmer
*/
public function __construct(array $loaders, string $phpArrayFile)
{
- if (2 < \func_num_args() && \func_get_arg(2) instanceof CacheItemPoolInterface) {
+ if (2 < \func_num_args() && func_get_arg(2) instanceof CacheItemPoolInterface) {
@trigger_error(sprintf('The CacheItemPoolInterface $fallbackPool argument of "%s()" is deprecated since Symfony 4.2, you should not pass it anymore.', __METHOD__), E_USER_DEPRECATED);
}
parent::__construct($phpArrayFile);
diff --git a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/ValidatorCacheWarmer.php b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/ValidatorCacheWarmer.php
index d617f7df9d1d1..bd1e559a361d0 100644
--- a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/ValidatorCacheWarmer.php
+++ b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/ValidatorCacheWarmer.php
@@ -37,7 +37,7 @@ class ValidatorCacheWarmer extends AbstractPhpFileCacheWarmer
*/
public function __construct(ValidatorBuilderInterface $validatorBuilder, string $phpArrayFile)
{
- if (2 < \func_num_args() && \func_get_arg(2) instanceof CacheItemPoolInterface) {
+ if (2 < \func_num_args() && func_get_arg(2) instanceof CacheItemPoolInterface) {
@trigger_error(sprintf('The CacheItemPoolInterface $fallbackPool argument of "%s()" is deprecated since Symfony 4.2, you should not pass it anymore.', __METHOD__), E_USER_DEPRECATED);
}
parent::__construct($phpArrayFile);
diff --git a/src/Symfony/Bundle/FrameworkBundle/Client.php b/src/Symfony/Bundle/FrameworkBundle/Client.php
index 6473f97584f39..6c75b5ab14029 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Client.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Client.php
@@ -66,7 +66,7 @@ public function getKernel()
*/
public function getProfile()
{
- if (!$this->kernel->getContainer()->has('profiler')) {
+ if (null === $this->response || !$this->kernel->getContainer()->has('profiler')) {
return false;
}
diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php
index 53cb18910525f..4cf1dc028bf11 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php
@@ -185,6 +185,7 @@ protected function describeContainerParameter($parameter, array $options = [])
private function writeData(array $data, array $options)
{
$flags = isset($options['json_encoding']) ? $options['json_encoding'] : 0;
+
$this->write(json_encode($data, $flags | JSON_PRETTY_PRINT)."\n");
}
diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
index 755566f45bdfa..4688c192a05cb 100644
--- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
+++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
@@ -721,9 +721,6 @@ private function registerDebugConfiguration(array $config, ContainerBuilder $con
$container->setParameter('debug.error_handler.throw_at', 0);
}
- $definition->replaceArgument(4, $debug);
- $definition->replaceArgument(6, $debug);
-
if ($debug && class_exists(DebugProcessor::class)) {
$definition = new Definition(DebugProcessor::class);
$definition->setPublic(false);
diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/debug_prod.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/debug_prod.xml
index 6810eadabe0e3..e19d453d36acf 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/debug_prod.xml
+++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/debug_prod.xml
@@ -18,9 +18,10 @@
null
%debug.error_handler.throw_at%
- true
+ %kernel.debug%
- true
+ %kernel.debug%
+ %kernel.charset%
diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/form.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/form.xml
index 36d80501bd70e..17598fa95815c 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/form.xml
+++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/form.xml
@@ -71,6 +71,7 @@
+
diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/web.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/web.xml
index 41c682c2111c7..fb797ff96b9e2 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/web.xml
+++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/web.xml
@@ -67,16 +67,6 @@
-
-
-
- null
- null
- %kernel.debug%
- %kernel.charset%
- %debug.file_link_format%
-
-
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/TemplateFinderTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/TemplateFinderTest.php
index 94b5432c3ab9b..c1b49c34f992c 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/TemplateFinderTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/TemplateFinderTest.php
@@ -34,7 +34,7 @@ public function testFindAllTemplates()
$kernel
->expects($this->once())
->method('getBundles')
- ->will($this->returnValue(['BaseBundle' => new BaseBundle()]))
+ ->willReturn(['BaseBundle' => new BaseBundle()])
;
$parser = new TemplateFilenameParser();
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/TemplatePathsCacheWarmerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/TemplatePathsCacheWarmerTest.php
index 30d0242663723..b63c746eb60ca 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/TemplatePathsCacheWarmerTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/TemplatePathsCacheWarmerTest.php
@@ -68,13 +68,13 @@ public function testWarmUp()
$this->templateFinder
->expects($this->once())
->method('findAllTemplates')
- ->will($this->returnValue([$template]));
+ ->willReturn([$template]);
$this->fileLocator
->expects($this->once())
->method('locate')
->with($template->getPath())
- ->will($this->returnValue(\dirname($this->tmpDir).'/path/to/template.html.twig'));
+ ->willReturn(\dirname($this->tmpDir).'/path/to/template.html.twig');
$warmer = new TemplatePathsCacheWarmer($this->templateFinder, $this->templateLocator);
$warmer->warmUp($this->tmpDir);
@@ -87,7 +87,7 @@ public function testWarmUpEmpty()
$this->templateFinder
->expects($this->once())
->method('findAllTemplates')
- ->will($this->returnValue([]));
+ ->willReturn([]);
$this->fileLocator
->expects($this->never())
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/RouterMatchCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/RouterMatchCommandTest.php
index d6da5b61510ac..497511f62908d 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/RouterMatchCommandTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/RouterMatchCommandTest.php
@@ -62,11 +62,11 @@ private function getRouter()
$router
->expects($this->any())
->method('getRouteCollection')
- ->will($this->returnValue($routeCollection));
+ ->willReturn($routeCollection);
$router
->expects($this->any())
->method('getContext')
- ->will($this->returnValue($requestContext));
+ ->willReturn($requestContext);
return $router;
}
@@ -77,9 +77,9 @@ private function getKernel()
$container
->expects($this->atLeastOnce())
->method('has')
- ->will($this->returnCallback(function ($id) {
+ ->willReturnCallback(function ($id) {
return 'console.command_loader' !== $id;
- }))
+ })
;
$container
->expects($this->any())
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationDebugCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationDebugCommandTest.php
index cf44257d34a51..138488d227ff3 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationDebugCommandTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationDebugCommandTest.php
@@ -154,26 +154,26 @@ private function createCommandTester($extractedMessages = [], $loadedMessages =
$translator
->expects($this->any())
->method('getFallbackLocales')
- ->will($this->returnValue(['en']));
+ ->willReturn(['en']);
$extractor = $this->getMockBuilder('Symfony\Component\Translation\Extractor\ExtractorInterface')->getMock();
$extractor
->expects($this->any())
->method('extract')
- ->will(
- $this->returnCallback(function ($path, $catalogue) use ($extractedMessages) {
+ ->willReturnCallback(
+ function ($path, $catalogue) use ($extractedMessages) {
$catalogue->add($extractedMessages);
- })
+ }
);
$loader = $this->getMockBuilder('Symfony\Component\Translation\Reader\TranslationReader')->getMock();
$loader
->expects($this->any())
->method('read')
- ->will(
- $this->returnCallback(function ($path, $catalogue) use ($loadedMessages) {
+ ->willReturnCallback(
+ function ($path, $catalogue) use ($loadedMessages) {
$catalogue->add($loadedMessages);
- })
+ }
);
if (null === $kernel) {
@@ -191,13 +191,13 @@ private function createCommandTester($extractedMessages = [], $loadedMessages =
$kernel
->expects($this->any())
->method('getBundle')
- ->will($this->returnValueMap($returnValues));
+ ->willReturnMap($returnValues);
}
$kernel
->expects($this->any())
->method('getBundles')
- ->will($this->returnValue([]));
+ ->willReturn([]);
$container = new Container();
$container->setParameter('kernel.root_dir', $this->translationDir);
@@ -205,7 +205,7 @@ private function createCommandTester($extractedMessages = [], $loadedMessages =
$kernel
->expects($this->any())
->method('getContainer')
- ->will($this->returnValue($container));
+ ->willReturn($container);
$command = new TranslationDebugCommand($translator, $loader, $extractor, $this->translationDir.'/translations', $this->translationDir.'/templates');
@@ -221,7 +221,7 @@ private function getBundle($path)
$bundle
->expects($this->any())
->method('getPath')
- ->will($this->returnValue($path))
+ ->willReturn($path)
;
return $bundle;
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php
index 0b2c341c47b54..82c555bd40567 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php
@@ -130,36 +130,36 @@ private function createCommandTester($extractedMessages = [], $loadedMessages =
$translator
->expects($this->any())
->method('getFallbackLocales')
- ->will($this->returnValue(['en']));
+ ->willReturn(['en']);
$extractor = $this->getMockBuilder('Symfony\Component\Translation\Extractor\ExtractorInterface')->getMock();
$extractor
->expects($this->any())
->method('extract')
- ->will(
- $this->returnCallback(function ($path, $catalogue) use ($extractedMessages) {
+ ->willReturnCallback(
+ function ($path, $catalogue) use ($extractedMessages) {
foreach ($extractedMessages as $domain => $messages) {
$catalogue->add($messages, $domain);
}
- })
+ }
);
$loader = $this->getMockBuilder('Symfony\Component\Translation\Reader\TranslationReader')->getMock();
$loader
->expects($this->any())
->method('read')
- ->will(
- $this->returnCallback(function ($path, $catalogue) use ($loadedMessages) {
+ ->willReturnCallback(
+ function ($path, $catalogue) use ($loadedMessages) {
$catalogue->add($loadedMessages);
- })
+ }
);
$writer = $this->getMockBuilder('Symfony\Component\Translation\Writer\TranslationWriter')->getMock();
$writer
->expects($this->any())
->method('getFormats')
- ->will(
- $this->returnValue(['xlf', 'yml', 'yaml'])
+ ->willReturn(
+ ['xlf', 'yml', 'yaml']
);
if (null === $kernel) {
@@ -177,25 +177,25 @@ private function createCommandTester($extractedMessages = [], $loadedMessages =
$kernel
->expects($this->any())
->method('getBundle')
- ->will($this->returnValueMap($returnValues));
+ ->willReturnMap($returnValues);
}
$kernel
->expects($this->any())
->method('getRootDir')
- ->will($this->returnValue($this->translationDir));
+ ->willReturn($this->translationDir);
$kernel
->expects($this->any())
->method('getBundles')
- ->will($this->returnValue([]));
+ ->willReturn([]);
$container = new Container();
$container->setParameter('kernel.root_dir', $this->translationDir);
$kernel
->expects($this->any())
->method('getContainer')
- ->will($this->returnValue($container));
+ ->willReturn($container);
$command = new TranslationUpdateCommand($writer, $loader, $extractor, 'en', $this->translationDir.'/translations', $this->translationDir.'/templates');
@@ -211,7 +211,7 @@ private function getBundle($path)
$bundle
->expects($this->any())
->method('getPath')
- ->will($this->returnValue($path))
+ ->willReturn($path)
;
return $bundle;
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/ApplicationTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/ApplicationTest.php
index 35060971f2112..b0967265a0b61 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/ApplicationTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/ApplicationTest.php
@@ -239,7 +239,7 @@ private function getKernel(array $bundles, $useDispatcher = false)
->expects($this->atLeastOnce())
->method('get')
->with($this->equalTo('event_dispatcher'))
- ->will($this->returnValue($dispatcher));
+ ->willReturn($dispatcher);
}
$container
@@ -259,12 +259,12 @@ private function getKernel(array $bundles, $useDispatcher = false)
$kernel
->expects($this->any())
->method('getBundles')
- ->will($this->returnValue($bundles))
+ ->willReturn($bundles)
;
$kernel
->expects($this->any())
->method('getContainer')
- ->will($this->returnValue($container))
+ ->willReturn($container)
;
return $kernel;
@@ -276,9 +276,9 @@ private function createBundleMock(array $commands)
$bundle
->expects($this->once())
->method('registerCommands')
- ->will($this->returnCallback(function (Application $application) use ($commands) {
+ ->willReturnCallback(function (Application $application) use ($commands) {
$application->addCommands($commands);
- }))
+ })
;
return $bundle;
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerNameParserTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerNameParserTest.php
index 5e65ae5f13ac0..1805fa074b231 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerNameParserTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerNameParserTest.php
@@ -155,13 +155,13 @@ private function createParser()
$kernel
->expects($this->any())
->method('getBundle')
- ->will($this->returnCallback(function ($bundle) use ($bundles) {
+ ->willReturnCallback(function ($bundle) use ($bundles) {
if (!isset($bundles[$bundle])) {
throw new \InvalidArgumentException(sprintf('Invalid bundle name "%s"', $bundle));
}
return $bundles[$bundle];
- }))
+ })
;
$bundles = [
@@ -172,7 +172,7 @@ private function createParser()
$kernel
->expects($this->any())
->method('getBundles')
- ->will($this->returnValue($bundles))
+ ->willReturn($bundles)
;
return new ControllerNameParser($kernel);
@@ -181,8 +181,8 @@ private function createParser()
private function getBundle($namespace, $name)
{
$bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface')->getMock();
- $bundle->expects($this->any())->method('getName')->will($this->returnValue($name));
- $bundle->expects($this->any())->method('getNamespace')->will($this->returnValue($namespace));
+ $bundle->expects($this->any())->method('getName')->willReturn($name);
+ $bundle->expects($this->any())->method('getNamespace')->willReturn($namespace);
return $bundle;
}
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerResolverTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerResolverTest.php
index 02f09a4fb3c14..d73f5765689f7 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerResolverTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerResolverTest.php
@@ -60,7 +60,7 @@ public function testGetControllerWithBundleNotation()
$parser->expects($this->once())
->method('parse')
->with($shortName)
- ->will($this->returnValue('Symfony\Bundle\FrameworkBundle\Tests\Controller\ContainerAwareController::testAction'))
+ ->willReturn('Symfony\Bundle\FrameworkBundle\Tests\Controller\ContainerAwareController::testAction')
;
$resolver = $this->createControllerResolver(null, null, $parser);
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTraitTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTraitTest.php
index 8bd22bed79cae..885aa21767f10 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTraitTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTraitTest.php
@@ -44,9 +44,9 @@ public function testForward()
$requestStack->push($request);
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
- $kernel->expects($this->once())->method('handle')->will($this->returnCallback(function (Request $request) {
+ $kernel->expects($this->once())->method('handle')->willReturnCallback(function (Request $request) {
return new Response($request->getRequestFormat().'--'.$request->getLocale());
- }));
+ });
$container = new Container();
$container->set('request_stack', $requestStack);
@@ -111,7 +111,7 @@ private function getContainerWithTokenStorage($token = null)
$tokenStorage
->expects($this->once())
->method('getToken')
- ->will($this->returnValue($token));
+ ->willReturn($token);
$container = new Container();
$container->set('security.token_storage', $tokenStorage);
@@ -138,7 +138,7 @@ public function testJsonWithSerializer()
->expects($this->once())
->method('serialize')
->with([], 'json', ['json_encode_options' => JsonResponse::DEFAULT_ENCODING_OPTIONS])
- ->will($this->returnValue('[]'));
+ ->willReturn('[]');
$container->set('serializer', $serializer);
@@ -159,7 +159,7 @@ public function testJsonWithSerializerContextOverride()
->expects($this->once())
->method('serialize')
->with([], 'json', ['json_encode_options' => 0, 'other' => 'context'])
- ->will($this->returnValue('[]'));
+ ->willReturn('[]');
$container->set('serializer', $serializer);
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/RedirectControllerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/RedirectControllerTest.php
index 1d8f899894da4..1c76d0366c626 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/RedirectControllerTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/RedirectControllerTest.php
@@ -74,7 +74,7 @@ public function testRoute($permanent, $keepRequestMethod, $keepQueryParams, $ign
->expects($this->once())
->method('generate')
->with($this->equalTo($route), $this->equalTo($expectedAttributes))
- ->will($this->returnValue($url));
+ ->willReturn($url);
$controller = new RedirectController($router);
@@ -247,7 +247,7 @@ public function testRedirectWithQuery()
$request->query = new ParameterBag(['base' => 'zaza']);
$request->attributes = new ParameterBag(['_route_params' => ['base2' => 'zaza']]);
$urlGenerator = $this->getMockBuilder(UrlGeneratorInterface::class)->getMock();
- $urlGenerator->expects($this->once())->method('generate')->will($this->returnValue('/test?base=zaza&base2=zaza'))->with('/test', ['base' => 'zaza', 'base2' => 'zaza'], UrlGeneratorInterface::ABSOLUTE_URL);
+ $urlGenerator->expects($this->once())->method('generate')->willReturn('/test?base=zaza&base2=zaza')->with('/test', ['base' => 'zaza', 'base2' => 'zaza'], UrlGeneratorInterface::ABSOLUTE_URL);
$controller = new RedirectController($urlGenerator);
$this->assertRedirectUrl($controller->redirectAction($request, '/test', false, false, false, true), '/test?base=zaza&base2=zaza');
@@ -264,7 +264,7 @@ public function testRedirectWithQueryWithRouteParamsOveriding()
$request->query = new ParameterBag(['base' => 'zaza']);
$request->attributes = new ParameterBag(['_route_params' => ['base' => 'zouzou']]);
$urlGenerator = $this->getMockBuilder(UrlGeneratorInterface::class)->getMock();
- $urlGenerator->expects($this->once())->method('generate')->will($this->returnValue('/test?base=zouzou'))->with('/test', ['base' => 'zouzou'], UrlGeneratorInterface::ABSOLUTE_URL);
+ $urlGenerator->expects($this->once())->method('generate')->willReturn('/test?base=zouzou')->with('/test', ['base' => 'zouzou'], UrlGeneratorInterface::ABSOLUTE_URL);
$controller = new RedirectController($urlGenerator);
$this->assertRedirectUrl($controller->redirectAction($request, '/test', false, false, false, true), '/test?base=zouzou');
@@ -276,23 +276,23 @@ private function createRequestObject($scheme, $host, $port, $baseUrl, $queryStri
$request
->expects($this->any())
->method('getScheme')
- ->will($this->returnValue($scheme));
+ ->willReturn($scheme);
$request
->expects($this->any())
->method('getHost')
- ->will($this->returnValue($host));
+ ->willReturn($host);
$request
->expects($this->any())
->method('getPort')
- ->will($this->returnValue($port));
+ ->willReturn($port);
$request
->expects($this->any())
->method('getBaseUrl')
- ->will($this->returnValue($baseUrl));
+ ->willReturn($baseUrl);
$request
->expects($this->any())
->method('getQueryString')
- ->will($this->returnValue($queryString));
+ ->willReturn($queryString);
return $request;
}
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ProfilerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ProfilerTest.php
index c5252c0d5892e..2768b59a1c3f5 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ProfilerTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ProfilerTest.php
@@ -28,9 +28,9 @@ public function testProfilerIsDisabled($insulate)
// enable the profiler for the next request
$client->enableProfiler();
- $crawler = $client->request('GET', '/profiler');
- $profile = $client->getProfile();
- $this->assertInternalType('object', $profile);
+ $this->assertFalse($client->getProfile());
+ $client->request('GET', '/profiler');
+ $this->assertInternalType('object', $client->getProfile());
$client->request('GET', '/profiler');
$this->assertFalse($client->getProfile());
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/SessionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/SessionTest.php
index aad3d77949ba4..bf1b76cdc743c 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/SessionTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/SessionTest.php
@@ -71,7 +71,7 @@ public function testFlash($config, $insulate)
/**
* See if two separate insulated clients can run without
- * polluting eachother's session data.
+ * polluting each other's session data.
*
* @dataProvider getConfigs
*/
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php
index 3f04e46dd57e7..ab5648ea08ea3 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php
@@ -488,7 +488,7 @@ private function getServiceContainer(RouteCollection $routes)
$loader
->expects($this->any())
->method('load')
- ->will($this->returnValue($routes))
+ ->willReturn($routes)
;
$sc = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\Container')->setMethods(['get'])->getMock();
@@ -496,7 +496,7 @@ private function getServiceContainer(RouteCollection $routes)
$sc
->expects($this->once())
->method('get')
- ->will($this->returnValue($loader))
+ ->willReturn($loader)
;
return $sc;
@@ -509,7 +509,7 @@ private function getPsr11ServiceContainer(RouteCollection $routes): ContainerInt
$loader
->expects($this->any())
->method('load')
- ->will($this->returnValue($routes))
+ ->willReturn($routes)
;
$sc = $this->getMockBuilder(ContainerInterface::class)->getMock();
@@ -517,7 +517,7 @@ private function getPsr11ServiceContainer(RouteCollection $routes): ContainerInt
$sc
->expects($this->once())
->method('get')
- ->will($this->returnValue($loader))
+ ->willReturn($loader)
;
return $sc;
@@ -529,9 +529,9 @@ private function getParameterBag(array $params = []): ContainerInterface
$bag
->expects($this->any())
->method('get')
- ->will($this->returnCallback(function ($key) use ($params) {
+ ->willReturnCallback(function ($key) use ($params) {
return isset($params[$key]) ? $params[$key] : null;
- }))
+ })
;
return $bag;
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/DelegatingEngineTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/DelegatingEngineTest.php
index 73983e47ce363..1fae0526d5d1b 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/DelegatingEngineTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/DelegatingEngineTest.php
@@ -67,7 +67,7 @@ public function testRenderResponseWithFrameworkEngine()
$engine->expects($this->once())
->method('renderResponse')
->with('template.php', ['foo' => 'bar'])
- ->will($this->returnValue($response));
+ ->willReturn($response);
$container = $this->getContainerMock(['engine' => $engine]);
$delegatingEngine = new DelegatingEngine($container, ['engine']);
@@ -91,7 +91,7 @@ private function getEngineMock($template, $supports)
$engine->expects($this->once())
->method('supports')
->with($template)
- ->will($this->returnValue($supports));
+ ->willReturn($supports);
return $engine;
}
@@ -103,7 +103,7 @@ private function getFrameworkEngineMock($template, $supports)
$engine->expects($this->once())
->method('supports')
->with($template)
- ->will($this->returnValue($supports));
+ ->willReturn($supports);
return $engine;
}
@@ -117,7 +117,7 @@ private function getContainerMock($services)
$container->expects($this->at($i++))
->method('get')
->with($id)
- ->will($this->returnValue($service));
+ ->willReturn($service);
}
return $container;
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/GlobalVariablesTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/GlobalVariablesTest.php
index d6c6b299ebc62..46a581b9442e4 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/GlobalVariablesTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/GlobalVariablesTest.php
@@ -47,7 +47,7 @@ public function testGetToken()
$tokenStorage
->expects($this->once())
->method('getToken')
- ->will($this->returnValue('token'));
+ ->willReturn('token');
$this->assertSame('token', $this->globals->getToken());
}
@@ -77,12 +77,12 @@ public function testGetUser($user, $expectedUser)
$token
->expects($this->once())
->method('getUser')
- ->will($this->returnValue($user));
+ ->willReturn($user);
$tokenStorage
->expects($this->once())
->method('getToken')
- ->will($this->returnValue($token));
+ ->willReturn($token);
$this->assertSame($expectedUser, $this->globals->getUser());
}
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Loader/TemplateLocatorTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Loader/TemplateLocatorTest.php
index 3317b15d90914..c78b7e5b2910f 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Loader/TemplateLocatorTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Loader/TemplateLocatorTest.php
@@ -27,7 +27,7 @@ public function testLocateATemplate()
->expects($this->once())
->method('locate')
->with($template->getPath())
- ->will($this->returnValue('/path/to/template'))
+ ->willReturn('/path/to/template')
;
$locator = new TemplateLocator($fileLocator);
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateNameParserTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateNameParserTest.php
index 9b4db5101a0c9..3f6b27c38e78d 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateNameParserTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateNameParserTest.php
@@ -26,13 +26,13 @@ protected function setUp()
$kernel
->expects($this->any())
->method('getBundle')
- ->will($this->returnCallback(function ($bundle) {
+ ->willReturnCallback(function ($bundle) {
if (\in_array($bundle, ['SensioFooBundle', 'SensioCmsFooBundle', 'FooBundle'])) {
return true;
}
throw new \InvalidArgumentException();
- }))
+ })
;
$this->parser = new TemplateNameParser($kernel);
}
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TimedPhpEngineTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TimedPhpEngineTest.php
index bd02809dc0173..f3684529f24c4 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TimedPhpEngineTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TimedPhpEngineTest.php
@@ -31,7 +31,7 @@ public function testThatRenderLogsTime()
$stopwatch->expects($this->once())
->method('start')
->with('template.php (index.php)', 'template')
- ->will($this->returnValue($stopwatchEvent));
+ ->willReturn($stopwatchEvent);
$stopwatchEvent->expects($this->once())->method('stop');
@@ -56,7 +56,7 @@ private function getTemplateNameParser()
$templateNameParser = $this->getMockBuilder('Symfony\Component\Templating\TemplateNameParserInterface')->getMock();
$templateNameParser->expects($this->any())
->method('parse')
- ->will($this->returnValue($templateReference));
+ ->willReturn($templateReference);
return $templateNameParser;
}
@@ -91,7 +91,7 @@ private function getLoader($storage)
$loader = $this->getMockForAbstractClass('Symfony\Component\Templating\Loader\Loader');
$loader->expects($this->once())
->method('load')
- ->will($this->returnValue($storage));
+ ->willReturn($storage);
return $loader;
}
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php
index 6b276ca0b9b02..b1109d542c69b 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php
@@ -242,53 +242,53 @@ protected function getLoader()
$loader
->expects($this->at(0))
->method('load')
- ->will($this->returnValue($this->getCatalogue('fr', [
+ ->willReturn($this->getCatalogue('fr', [
'foo' => 'foo (FR)',
- ])))
+ ]))
;
$loader
->expects($this->at(1))
->method('load')
- ->will($this->returnValue($this->getCatalogue('en', [
+ ->willReturn($this->getCatalogue('en', [
'foo' => 'foo (EN)',
'bar' => 'bar (EN)',
'choice' => '{0} choice 0 (EN)|{1} choice 1 (EN)|]1,Inf] choice inf (EN)',
- ])))
+ ]))
;
$loader
->expects($this->at(2))
->method('load')
- ->will($this->returnValue($this->getCatalogue('es', [
+ ->willReturn($this->getCatalogue('es', [
'foobar' => 'foobar (ES)',
- ])))
+ ]))
;
$loader
->expects($this->at(3))
->method('load')
- ->will($this->returnValue($this->getCatalogue('pt-PT', [
+ ->willReturn($this->getCatalogue('pt-PT', [
'foobarfoo' => 'foobarfoo (PT-PT)',
- ])))
+ ]))
;
$loader
->expects($this->at(4))
->method('load')
- ->will($this->returnValue($this->getCatalogue('pt_BR', [
+ ->willReturn($this->getCatalogue('pt_BR', [
'other choice' => '{0} other choice 0 (PT-BR)|{1} other choice 1 (PT-BR)|]1,Inf] other choice inf (PT-BR)',
- ])))
+ ]))
;
$loader
->expects($this->at(5))
->method('load')
- ->will($this->returnValue($this->getCatalogue('fr.UTF-8', [
+ ->willReturn($this->getCatalogue('fr.UTF-8', [
'foobarbaz' => 'foobarbaz (fr.UTF-8)',
- ])))
+ ]))
;
$loader
->expects($this->at(6))
->method('load')
- ->will($this->returnValue($this->getCatalogue('sr@latin', [
+ ->willReturn($this->getCatalogue('sr@latin', [
'foobarbax' => 'foobarbax (sr@latin)',
- ])))
+ ]))
;
return $loader;
@@ -300,7 +300,7 @@ protected function getContainer($loader)
$container
->expects($this->any())
->method('get')
- ->will($this->returnValue($loader))
+ ->willReturn($loader)
;
return $container;
diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Security/Factory/AbstractFactoryTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Security/Factory/AbstractFactoryTest.php
index ca82e805c3cd1..9eb9a08177700 100644
--- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Security/Factory/AbstractFactoryTest.php
+++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Security/Factory/AbstractFactoryTest.php
@@ -132,17 +132,17 @@ protected function callFactory($id, $config, $userProviderId, $defaultEntryPoint
$factory
->expects($this->once())
->method('createAuthProvider')
- ->will($this->returnValue('auth_provider'))
+ ->willReturn('auth_provider')
;
$factory
->expects($this->atLeastOnce())
->method('getListenerId')
- ->will($this->returnValue('abstract_listener'))
+ ->willReturn('abstract_listener')
;
$factory
->expects($this->any())
->method('getKey')
- ->will($this->returnValue('abstract_factory'))
+ ->willReturn('abstract_factory')
;
$container = new ContainerBuilder();
diff --git a/src/Symfony/Bundle/TwigBundle/Tests/Controller/PreviewErrorControllerTest.php b/src/Symfony/Bundle/TwigBundle/Tests/Controller/PreviewErrorControllerTest.php
index 1ca5015a49fcd..ae740e1ab2f20 100644
--- a/src/Symfony/Bundle/TwigBundle/Tests/Controller/PreviewErrorControllerTest.php
+++ b/src/Symfony/Bundle/TwigBundle/Tests/Controller/PreviewErrorControllerTest.php
@@ -44,7 +44,7 @@ public function testForwardRequestToConfiguredController()
}),
$this->equalTo(HttpKernelInterface::SUB_REQUEST)
)
- ->will($this->returnValue($response));
+ ->willReturn($response);
$controller = new PreviewErrorController($kernel, $logicalControllerName);
diff --git a/src/Symfony/Bundle/TwigBundle/Tests/Loader/FilesystemLoaderTest.php b/src/Symfony/Bundle/TwigBundle/Tests/Loader/FilesystemLoaderTest.php
index 2989cb6bdd745..697e6ceb66711 100644
--- a/src/Symfony/Bundle/TwigBundle/Tests/Loader/FilesystemLoaderTest.php
+++ b/src/Symfony/Bundle/TwigBundle/Tests/Loader/FilesystemLoaderTest.php
@@ -24,7 +24,7 @@ public function testGetSourceContext()
$locator
->expects($this->once())
->method('locate')
- ->will($this->returnValue(__DIR__.'/../DependencyInjection/Fixtures/templates/layout.html.twig'))
+ ->willReturn(__DIR__.'/../DependencyInjection/Fixtures/templates/layout.html.twig')
;
$loader = new FilesystemLoader($locator, $parser);
$loader->addPath(__DIR__.'/../DependencyInjection/Fixtures/templates', 'namespace');
@@ -44,7 +44,7 @@ public function testExists()
$locator
->expects($this->once())
->method('locate')
- ->will($this->returnValue($template = __DIR__.'/../DependencyInjection/Fixtures/templates/layout.html.twig'))
+ ->willReturn($template = __DIR__.'/../DependencyInjection/Fixtures/templates/layout.html.twig')
;
$loader = new FilesystemLoader($locator, $parser);
@@ -61,7 +61,7 @@ public function testTwigErrorIfLocatorThrowsInvalid()
->expects($this->once())
->method('parse')
->with('name.format.engine')
- ->will($this->returnValue(new TemplateReference('', '', 'name', 'format', 'engine')))
+ ->willReturn(new TemplateReference('', '', 'name', 'format', 'engine'))
;
$locator = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock();
@@ -85,14 +85,14 @@ public function testTwigErrorIfLocatorReturnsFalse()
->expects($this->once())
->method('parse')
->with('name.format.engine')
- ->will($this->returnValue(new TemplateReference('', '', 'name', 'format', 'engine')))
+ ->willReturn(new TemplateReference('', '', 'name', 'format', 'engine'))
;
$locator = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock();
$locator
->expects($this->once())
->method('locate')
- ->will($this->returnValue(false))
+ ->willReturn(false)
;
$loader = new FilesystemLoader($locator, $parser);
diff --git a/src/Symfony/Bundle/TwigBundle/Tests/TemplateIteratorTest.php b/src/Symfony/Bundle/TwigBundle/Tests/TemplateIteratorTest.php
index 33a873dba88d7..b9092af3ebd0c 100644
--- a/src/Symfony/Bundle/TwigBundle/Tests/TemplateIteratorTest.php
+++ b/src/Symfony/Bundle/TwigBundle/Tests/TemplateIteratorTest.php
@@ -18,13 +18,13 @@ class TemplateIteratorTest extends TestCase
public function testGetIterator()
{
$bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface')->getMock();
- $bundle->expects($this->any())->method('getName')->will($this->returnValue('BarBundle'));
- $bundle->expects($this->any())->method('getPath')->will($this->returnValue(__DIR__.'/Fixtures/templates/BarBundle'));
+ $bundle->expects($this->any())->method('getName')->willReturn('BarBundle');
+ $bundle->expects($this->any())->method('getPath')->willReturn(__DIR__.'/Fixtures/templates/BarBundle');
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Kernel')->disableOriginalConstructor()->getMock();
- $kernel->expects($this->any())->method('getBundles')->will($this->returnValue([
+ $kernel->expects($this->any())->method('getBundles')->willReturn([
$bundle,
- ]));
+ ]);
$iterator = new TemplateIterator($kernel, __DIR__.'/Fixtures/templates', [__DIR__.'/Fixtures/templates/Foo' => 'Foo'], __DIR__.'/DependencyInjection/Fixtures/templates');
$sorted = iterator_to_array($iterator);
diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php
index 880d611fa689f..79b289e5a1e64 100644
--- a/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php
+++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php
@@ -97,11 +97,11 @@ public function testReturns404onTokenNotFound($withCsp)
$profiler
->expects($this->exactly(2))
->method('loadProfile')
- ->will($this->returnCallback(function ($token) {
+ ->willReturnCallback(function ($token) {
if ('found' == $token) {
return new Profile($token);
}
- }))
+ })
;
$controller = $this->createController($profiler, $twig, $withCsp);
@@ -149,7 +149,7 @@ public function testSearchResult($withCsp)
$profiler
->expects($this->once())
->method('find')
- ->will($this->returnValue($tokens));
+ ->willReturn($tokens);
$request = Request::create('/_profiler/empty/search/results', 'GET', [
'limit' => 2,
diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/Csp/ContentSecurityPolicyHandlerTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/Csp/ContentSecurityPolicyHandlerTest.php
index bbf96c3b2b344..acccc7cbfb6d2 100644
--- a/src/Symfony/Bundle/WebProfilerBundle/Tests/Csp/ContentSecurityPolicyHandlerTest.php
+++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/Csp/ContentSecurityPolicyHandlerTest.php
@@ -200,7 +200,7 @@ private function mockNonceGenerator($value)
$generator->expects($this->any())
->method('generate')
- ->will($this->returnValue($value));
+ ->willReturn($value);
return $generator;
}
diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/EventListener/WebDebugToolbarListenerTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/EventListener/WebDebugToolbarListenerTest.php
index 6dde6e413ad19..81474c21f05e8 100644
--- a/src/Symfony/Bundle/WebProfilerBundle/Tests/EventListener/WebDebugToolbarListenerTest.php
+++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/EventListener/WebDebugToolbarListenerTest.php
@@ -244,7 +244,7 @@ public function testXDebugUrlHeader()
->expects($this->once())
->method('generate')
->with('_profiler', ['token' => 'xxxxxxxx'], UrlGeneratorInterface::ABSOLUTE_URL)
- ->will($this->returnValue('http://mydomain.com/_profiler/xxxxxxxx'))
+ ->willReturn('http://mydomain.com/_profiler/xxxxxxxx')
;
$event = new FilterResponseEvent($this->getKernelMock(), $this->getRequestMock(), HttpKernelInterface::MASTER_REQUEST, $response);
@@ -302,10 +302,10 @@ protected function getRequestMock($isXmlHttpRequest = false, $requestFormat = 'h
$request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->setMethods(['getSession', 'isXmlHttpRequest', 'getRequestFormat'])->disableOriginalConstructor()->getMock();
$request->expects($this->any())
->method('isXmlHttpRequest')
- ->will($this->returnValue($isXmlHttpRequest));
+ ->willReturn($isXmlHttpRequest);
$request->expects($this->any())
->method('getRequestFormat')
- ->will($this->returnValue($requestFormat));
+ ->willReturn($requestFormat);
$request->headers = new HeaderBag();
@@ -313,7 +313,7 @@ protected function getRequestMock($isXmlHttpRequest = false, $requestFormat = 'h
$session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\Session')->disableOriginalConstructor()->getMock();
$request->expects($this->any())
->method('getSession')
- ->will($this->returnValue($session));
+ ->willReturn($session);
}
return $request;
@@ -324,7 +324,7 @@ protected function getTwigMock($render = 'WDT')
$templating = $this->getMockBuilder('Twig\Environment')->disableOriginalConstructor()->getMock();
$templating->expects($this->any())
->method('render')
- ->will($this->returnValue($render));
+ ->willReturn($render);
return $templating;
}
diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/Profiler/TemplateManagerTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/Profiler/TemplateManagerTest.php
index 927ee0dba94d0..33142dbf06659 100644
--- a/src/Symfony/Bundle/WebProfilerBundle/Tests/Profiler/TemplateManagerTest.php
+++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/Profiler/TemplateManagerTest.php
@@ -69,7 +69,7 @@ public function testGetNameValidTemplate()
$this->profiler->expects($this->any())
->method('has')
->withAnyParameters()
- ->will($this->returnCallback([$this, 'profilerHasCallback']));
+ ->willReturnCallback([$this, 'profilerHasCallback']);
$this->assertEquals('FooBundle:Collector:foo.html.twig', $this->templateManager->getName(new ProfileDummy(), 'foo'));
}
@@ -107,14 +107,14 @@ protected function mockTwigEnvironment()
$this->twigEnvironment->expects($this->any())
->method('loadTemplate')
- ->will($this->returnValue('loadedTemplate'));
+ ->willReturn('loadedTemplate');
if (interface_exists('Twig\Loader\SourceContextLoaderInterface')) {
$loader = $this->getMockBuilder('Twig\Loader\SourceContextLoaderInterface')->getMock();
} else {
$loader = $this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock();
}
- $this->twigEnvironment->expects($this->any())->method('getLoader')->will($this->returnValue($loader));
+ $this->twigEnvironment->expects($this->any())->method('getLoader')->willReturn($loader);
return $this->twigEnvironment;
}
diff --git a/src/Symfony/Component/Asset/Tests/PathPackageTest.php b/src/Symfony/Component/Asset/Tests/PathPackageTest.php
index c6edc8de61a7d..d00cc76c2a943 100644
--- a/src/Symfony/Component/Asset/Tests/PathPackageTest.php
+++ b/src/Symfony/Component/Asset/Tests/PathPackageTest.php
@@ -89,7 +89,7 @@ public function testVersionStrategyGivesAbsoluteURL()
private function getContext($basePath)
{
$context = $this->getMockBuilder('Symfony\Component\Asset\Context\ContextInterface')->getMock();
- $context->expects($this->any())->method('getBasePath')->will($this->returnValue($basePath));
+ $context->expects($this->any())->method('getBasePath')->willReturn($basePath);
return $context;
}
diff --git a/src/Symfony/Component/Asset/Tests/UrlPackageTest.php b/src/Symfony/Component/Asset/Tests/UrlPackageTest.php
index 097c1a891d363..3bb06633d32a6 100644
--- a/src/Symfony/Component/Asset/Tests/UrlPackageTest.php
+++ b/src/Symfony/Component/Asset/Tests/UrlPackageTest.php
@@ -124,7 +124,7 @@ public function getWrongBaseUrlConfig()
private function getContext($secure)
{
$context = $this->getMockBuilder('Symfony\Component\Asset\Context\ContextInterface')->getMock();
- $context->expects($this->any())->method('isSecure')->will($this->returnValue($secure));
+ $context->expects($this->any())->method('isSecure')->willReturn($secure);
return $context;
}
diff --git a/src/Symfony/Component/BrowserKit/Client.php b/src/Symfony/Component/BrowserKit/Client.php
index d6c033d57245f..871cb7b64326d 100644
--- a/src/Symfony/Component/BrowserKit/Client.php
+++ b/src/Symfony/Component/BrowserKit/Client.php
@@ -457,7 +457,8 @@ protected function doRequestInProcess($request)
unlink($deprecationsFile);
foreach ($deprecations ? unserialize($deprecations) : [] as $deprecation) {
if ($deprecation[0]) {
- @trigger_error($deprecation[1], E_USER_DEPRECATED);
+ // unsilenced on purpose
+ trigger_error($deprecation[1], E_USER_DEPRECATED);
} else {
@trigger_error($deprecation[1], E_USER_DEPRECATED);
}
diff --git a/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php b/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php
index 6897fbceee530..51b2bbd6c560e 100644
--- a/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php
+++ b/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php
@@ -27,6 +27,11 @@
*/
abstract class AbstractAdapter implements AdapterInterface, CacheInterface, LoggerAwareInterface, ResettableInterface
{
+ /**
+ * @internal
+ */
+ protected const NS_SEPARATOR = ':';
+
use AbstractTrait;
use ContractsTrait;
@@ -38,7 +43,7 @@ abstract class AbstractAdapter implements AdapterInterface, CacheInterface, Logg
protected function __construct(string $namespace = '', int $defaultLifetime = 0)
{
- $this->namespace = '' === $namespace ? '' : CacheItem::validateKey($namespace).':';
+ $this->namespace = '' === $namespace ? '' : CacheItem::validateKey($namespace).static::NS_SEPARATOR;
if (null !== $this->maxIdLength && \strlen($namespace) > $this->maxIdLength - 24) {
throw new InvalidArgumentException(sprintf('Namespace must be %d chars max, %d given ("%s")', $this->maxIdLength - 24, \strlen($namespace), $namespace));
}
@@ -52,9 +57,9 @@ function ($key, $value, $isHit) use ($defaultLifetime) {
// Detect wrapped values that encode for their expiry and creation duration
// For compactness, these values are packed in the key of an array using
// magic numbers in the form 9D-..-..-..-..-00-..-..-..-5F
- if (\is_array($v) && 1 === \count($v) && 10 === \strlen($k = \key($v)) && "\x9D" === $k[0] && "\0" === $k[5] && "\x5F" === $k[9]) {
+ if (\is_array($v) && 1 === \count($v) && 10 === \strlen($k = key($v)) && "\x9D" === $k[0] && "\0" === $k[5] && "\x5F" === $k[9]) {
$item->value = $v[$k];
- $v = \unpack('Ve/Nc', \substr($k, 1, -1));
+ $v = unpack('Ve/Nc', substr($k, 1, -1));
$item->metadata[CacheItem::METADATA_EXPIRY] = $v['e'] + CacheItem::METADATA_EXPIRY_OFFSET;
$item->metadata[CacheItem::METADATA_CTIME] = $v['c'];
}
diff --git a/src/Symfony/Component/Cache/Adapter/ArrayAdapter.php b/src/Symfony/Component/Cache/Adapter/ArrayAdapter.php
index bbb1f846e4cf5..defa48eed96ad 100644
--- a/src/Symfony/Component/Cache/Adapter/ArrayAdapter.php
+++ b/src/Symfony/Component/Cache/Adapter/ArrayAdapter.php
@@ -59,7 +59,8 @@ public function get(string $key, callable $callback, float $beta = null, array &
// ArrayAdapter works in memory, we don't care about stampede protection
if (INF === $beta || !$item->isHit()) {
- $this->save($item->set($callback($item)));
+ $save = true;
+ $this->save($item->set($callback($item, $save)));
}
return $item->get();
diff --git a/src/Symfony/Component/Cache/Adapter/NullAdapter.php b/src/Symfony/Component/Cache/Adapter/NullAdapter.php
index f1bdd2bf71916..54cd453565907 100644
--- a/src/Symfony/Component/Cache/Adapter/NullAdapter.php
+++ b/src/Symfony/Component/Cache/Adapter/NullAdapter.php
@@ -42,7 +42,9 @@ function ($key) {
*/
public function get(string $key, callable $callback, float $beta = null, array &$metadata = null)
{
- return $callback(($this->createCacheItem)($key));
+ $save = true;
+
+ return $callback(($this->createCacheItem)($key), $save);
}
/**
diff --git a/src/Symfony/Component/Cache/Adapter/ProxyAdapter.php b/src/Symfony/Component/Cache/Adapter/ProxyAdapter.php
index 8340bdf034177..bccafcf47ef1b 100644
--- a/src/Symfony/Component/Cache/Adapter/ProxyAdapter.php
+++ b/src/Symfony/Component/Cache/Adapter/ProxyAdapter.php
@@ -58,9 +58,9 @@ function ($key, $innerItem) use ($defaultLifetime, $poolHash) {
// Detect wrapped values that encode for their expiry and creation duration
// For compactness, these values are packed in the key of an array using
// magic numbers in the form 9D-..-..-..-..-00-..-..-..-5F
- if (\is_array($v) && 1 === \count($v) && 10 === \strlen($k = \key($v)) && "\x9D" === $k[0] && "\0" === $k[5] && "\x5F" === $k[9]) {
+ if (\is_array($v) && 1 === \count($v) && 10 === \strlen($k = key($v)) && "\x9D" === $k[0] && "\0" === $k[5] && "\x5F" === $k[9]) {
$item->value = $v[$k];
- $v = \unpack('Ve/Nc', \substr($k, 1, -1));
+ $v = unpack('Ve/Nc', substr($k, 1, -1));
$item->metadata[CacheItem::METADATA_EXPIRY] = $v['e'] + CacheItem::METADATA_EXPIRY_OFFSET;
$item->metadata[CacheItem::METADATA_CTIME] = $v['c'];
} elseif ($innerItem instanceof CacheItem) {
@@ -103,9 +103,9 @@ public function get(string $key, callable $callback, float $beta = null, array &
return $this->doGet($this, $key, $callback, $beta, $metadata);
}
- return $this->pool->get($this->getId($key), function ($innerItem) use ($key, $callback) {
+ return $this->pool->get($this->getId($key), function ($innerItem, bool &$save) use ($key, $callback) {
$item = ($this->createCacheItem)($key, $innerItem);
- $item->set($value = $callback($item));
+ $item->set($value = $callback($item, $save));
($this->setInnerItem)($innerItem, (array) $item);
return $value;
diff --git a/src/Symfony/Component/Cache/Adapter/SimpleCacheAdapter.php b/src/Symfony/Component/Cache/Adapter/SimpleCacheAdapter.php
index 5a836a3dbf8be..cc48e531c6552 100644
--- a/src/Symfony/Component/Cache/Adapter/SimpleCacheAdapter.php
+++ b/src/Symfony/Component/Cache/Adapter/SimpleCacheAdapter.php
@@ -20,6 +20,11 @@
*/
class SimpleCacheAdapter extends AbstractAdapter implements PruneableInterface
{
+ /**
+ * @internal
+ */
+ protected const NS_SEPARATOR = '_';
+
use ProxyTrait;
private $miss;
diff --git a/src/Symfony/Component/Cache/Adapter/TraceableAdapter.php b/src/Symfony/Component/Cache/Adapter/TraceableAdapter.php
index 5c294d03fd530..660acf54d7bdb 100644
--- a/src/Symfony/Component/Cache/Adapter/TraceableAdapter.php
+++ b/src/Symfony/Component/Cache/Adapter/TraceableAdapter.php
@@ -45,10 +45,10 @@ public function get(string $key, callable $callback, float $beta = null, array &
}
$isHit = true;
- $callback = function (CacheItem $item) use ($callback, &$isHit) {
+ $callback = function (CacheItem $item, bool &$save) use ($callback, &$isHit) {
$isHit = $item->isHit();
- return $callback($item);
+ return $callback($item, $save);
};
$event = $this->start(__FUNCTION__);
diff --git a/src/Symfony/Component/Cache/CacheItem.php b/src/Symfony/Component/Cache/CacheItem.php
index 92eb9c39dfa32..3cc3fb8f2e477 100644
--- a/src/Symfony/Component/Cache/CacheItem.php
+++ b/src/Symfony/Component/Cache/CacheItem.php
@@ -110,7 +110,7 @@ public function tag($tags): ItemInterface
if (!$this->isTaggable) {
throw new LogicException(sprintf('Cache item "%s" comes from a non tag-aware pool: you cannot tag it.', $this->key));
}
- if (!\is_iterable($tags)) {
+ if (!is_iterable($tags)) {
$tags = [$tags];
}
foreach ($tags as $tag) {
diff --git a/src/Symfony/Component/Cache/Simple/AbstractCache.php b/src/Symfony/Component/Cache/Simple/AbstractCache.php
index 7a2a3cb36e996..cb9e44c859cc3 100644
--- a/src/Symfony/Component/Cache/Simple/AbstractCache.php
+++ b/src/Symfony/Component/Cache/Simple/AbstractCache.php
@@ -23,6 +23,11 @@
*/
abstract class AbstractCache implements CacheInterface, LoggerAwareInterface, ResettableInterface
{
+ /**
+ * @internal
+ */
+ protected const NS_SEPARATOR = ':';
+
use AbstractTrait {
deleteItems as private;
AbstractTrait::deleteItem as delete;
diff --git a/src/Symfony/Component/Cache/Tests/Adapter/AdapterTestCase.php b/src/Symfony/Component/Cache/Tests/Adapter/AdapterTestCase.php
index 498c00ca643a4..2b4c9e95bf854 100644
--- a/src/Symfony/Component/Cache/Tests/Adapter/AdapterTestCase.php
+++ b/src/Symfony/Component/Cache/Tests/Adapter/AdapterTestCase.php
@@ -12,9 +12,12 @@
namespace Symfony\Component\Cache\Tests\Adapter;
use Cache\IntegrationTests\CachePoolTest;
+use PHPUnit\Framework\Assert;
+use Psr\Cache\CacheItemInterface;
use Psr\Cache\CacheItemPoolInterface;
use Symfony\Component\Cache\CacheItem;
use Symfony\Component\Cache\PruneableInterface;
+use Symfony\Contracts\Cache\CallbackInterface;
abstract class AdapterTestCase extends CachePoolTest
{
@@ -57,6 +60,22 @@ public function testGet()
$this->assertSame($value, $item->get());
}, INF));
$this->assertFalse($isHit);
+
+ $this->assertSame($value, $cache->get('bar', new class($value) implements CallbackInterface {
+ private $value;
+
+ public function __construct(int $value)
+ {
+ $this->value = $value;
+ }
+
+ public function __invoke(CacheItemInterface $item, bool &$save)
+ {
+ Assert::assertSame('bar', $item->getKey());
+
+ return $this->value;
+ }
+ }));
}
public function testRecursiveGet()
diff --git a/src/Symfony/Component/Cache/Tests/Adapter/ChainAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/ChainAdapterTest.php
index 61b039b57b482..46bbef4c31ed8 100644
--- a/src/Symfony/Component/Cache/Tests/Adapter/ChainAdapterTest.php
+++ b/src/Symfony/Component/Cache/Tests/Adapter/ChainAdapterTest.php
@@ -84,7 +84,7 @@ private function getPruneableMock()
$pruneable
->expects($this->atLeastOnce())
->method('prune')
- ->will($this->returnValue(true));
+ ->willReturn(true);
return $pruneable;
}
@@ -101,7 +101,7 @@ private function getFailingPruneableMock()
$pruneable
->expects($this->atLeastOnce())
->method('prune')
- ->will($this->returnValue(false));
+ ->willReturn(false);
return $pruneable;
}
diff --git a/src/Symfony/Component/Cache/Tests/Adapter/MaxIdLengthAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/MaxIdLengthAdapterTest.php
index fec985e6da994..5da80db0dec67 100644
--- a/src/Symfony/Component/Cache/Tests/Adapter/MaxIdLengthAdapterTest.php
+++ b/src/Symfony/Component/Cache/Tests/Adapter/MaxIdLengthAdapterTest.php
@@ -56,7 +56,7 @@ public function testLongKeyVersioning()
$reflectionProperty->setValue($cache, true);
// Versioning enabled
- $this->assertEquals('--------------------------:1/------------', $reflectionMethod->invokeArgs($cache, [str_repeat('-', 12)]));
+ $this->assertEquals('--------------------------:1:------------', $reflectionMethod->invokeArgs($cache, [str_repeat('-', 12)]));
$this->assertLessThanOrEqual(50, \strlen($reflectionMethod->invokeArgs($cache, [str_repeat('-', 12)])));
$this->assertLessThanOrEqual(50, \strlen($reflectionMethod->invokeArgs($cache, [str_repeat('-', 23)])));
$this->assertLessThanOrEqual(50, \strlen($reflectionMethod->invokeArgs($cache, [str_repeat('-', 40)])));
diff --git a/src/Symfony/Component/Cache/Tests/Adapter/SimpleCacheAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/SimpleCacheAdapterTest.php
index 3028af47c6f2a..c76509247e161 100644
--- a/src/Symfony/Component/Cache/Tests/Adapter/SimpleCacheAdapterTest.php
+++ b/src/Symfony/Component/Cache/Tests/Adapter/SimpleCacheAdapterTest.php
@@ -13,6 +13,7 @@
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
use Symfony\Component\Cache\Adapter\SimpleCacheAdapter;
+use Symfony\Component\Cache\Simple\ArrayCache;
use Symfony\Component\Cache\Simple\Psr6Cache;
/**
@@ -28,4 +29,14 @@ public function createCachePool($defaultLifetime = 0)
{
return new SimpleCacheAdapter(new Psr6Cache(new FilesystemAdapter()), '', $defaultLifetime);
}
+
+ public function testValidCacheKeyWithNamespace()
+ {
+ $cache = new SimpleCacheAdapter(new ArrayCache(), 'some_namespace', 0);
+ $item = $cache->getItem('my_key');
+ $item->set('someValue');
+ $cache->save($item);
+
+ $this->assertTrue($cache->getItem('my_key')->isHit(), 'Stored item is successfully retrieved.');
+ }
}
diff --git a/src/Symfony/Component/Cache/Tests/Adapter/TagAwareAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/TagAwareAdapterTest.php
index 7b8895b70019c..031b8500d6d3b 100644
--- a/src/Symfony/Component/Cache/Tests/Adapter/TagAwareAdapterTest.php
+++ b/src/Symfony/Component/Cache/Tests/Adapter/TagAwareAdapterTest.php
@@ -188,7 +188,7 @@ private function getPruneableMock()
$pruneable
->expects($this->atLeastOnce())
->method('prune')
- ->will($this->returnValue(true));
+ ->willReturn(true);
return $pruneable;
}
@@ -205,7 +205,7 @@ private function getFailingPruneableMock()
$pruneable
->expects($this->atLeastOnce())
->method('prune')
- ->will($this->returnValue(false));
+ ->willReturn(false);
return $pruneable;
}
diff --git a/src/Symfony/Component/Cache/Tests/Simple/ChainCacheTest.php b/src/Symfony/Component/Cache/Tests/Simple/ChainCacheTest.php
index e6f7c7cc63229..aa77887919b74 100644
--- a/src/Symfony/Component/Cache/Tests/Simple/ChainCacheTest.php
+++ b/src/Symfony/Component/Cache/Tests/Simple/ChainCacheTest.php
@@ -78,7 +78,7 @@ private function getPruneableMock()
$pruneable
->expects($this->atLeastOnce())
->method('prune')
- ->will($this->returnValue(true));
+ ->willReturn(true);
return $pruneable;
}
@@ -95,7 +95,7 @@ private function getFailingPruneableMock()
$pruneable
->expects($this->atLeastOnce())
->method('prune')
- ->will($this->returnValue(false));
+ ->willReturn(false);
return $pruneable;
}
diff --git a/src/Symfony/Component/Cache/Traits/AbstractTrait.php b/src/Symfony/Component/Cache/Traits/AbstractTrait.php
index 2553ea75cb6a0..f92e541d350ed 100644
--- a/src/Symfony/Component/Cache/Traits/AbstractTrait.php
+++ b/src/Symfony/Component/Cache/Traits/AbstractTrait.php
@@ -107,9 +107,9 @@ public function clear()
{
$this->deferred = [];
if ($cleared = $this->versioningIsEnabled) {
- $namespaceVersion = substr_replace(base64_encode(pack('V', mt_rand())), ':', 5);
+ $namespaceVersion = substr_replace(base64_encode(pack('V', mt_rand())), static::NS_SEPARATOR, 5);
try {
- $cleared = $this->doSave(['/'.$this->namespace => $namespaceVersion], 0);
+ $cleared = $this->doSave([static::NS_SEPARATOR.$this->namespace => $namespaceVersion], 0);
} catch (\Exception $e) {
$cleared = false;
}
@@ -242,14 +242,14 @@ private function getId($key)
{
if ($this->versioningIsEnabled && '' === $this->namespaceVersion) {
$this->ids = [];
- $this->namespaceVersion = '1/';
+ $this->namespaceVersion = '1'.static::NS_SEPARATOR;
try {
- foreach ($this->doFetch(['/'.$this->namespace]) as $v) {
+ foreach ($this->doFetch([static::NS_SEPARATOR.$this->namespace]) as $v) {
$this->namespaceVersion = $v;
}
- if ('1:' === $this->namespaceVersion) {
- $this->namespaceVersion = substr_replace(base64_encode(pack('V', time())), ':', 5);
- $this->doSave(['@'.$this->namespace => $this->namespaceVersion], 0);
+ if ('1'.static::NS_SEPARATOR === $this->namespaceVersion) {
+ $this->namespaceVersion = substr_replace(base64_encode(pack('V', time())), static::NS_SEPARATOR, 5);
+ $this->doSave([static::NS_SEPARATOR.$this->namespace => $this->namespaceVersion], 0);
}
} catch (\Exception $e) {
}
@@ -266,7 +266,7 @@ private function getId($key)
}
if (\strlen($id = $this->namespace.$this->namespaceVersion.$key) > $this->maxIdLength) {
// Use MD5 to favor speed over security, which is not an issue here
- $this->ids[$key] = $id = substr_replace(base64_encode(hash('md5', $key, true)), ':', -(\strlen($this->namespaceVersion) + 2));
+ $this->ids[$key] = $id = substr_replace(base64_encode(hash('md5', $key, true)), static::NS_SEPARATOR, -(\strlen($this->namespaceVersion) + 2));
$id = $this->namespace.$this->namespaceVersion.$id;
}
diff --git a/src/Symfony/Component/Cache/Traits/ArrayTrait.php b/src/Symfony/Component/Cache/Traits/ArrayTrait.php
index e585c3d48cb52..4d67c2df5a238 100644
--- a/src/Symfony/Component/Cache/Traits/ArrayTrait.php
+++ b/src/Symfony/Component/Cache/Traits/ArrayTrait.php
@@ -123,7 +123,7 @@ private function freeze($value, $key)
if ('N;' === $value || (isset($value[2]) && ':' === $value[1])) {
return serialize($value);
}
- } elseif (!\is_scalar($value)) {
+ } elseif (!is_scalar($value)) {
try {
$serialized = serialize($value);
} catch (\Exception $e) {
diff --git a/src/Symfony/Component/Cache/Traits/PhpArrayTrait.php b/src/Symfony/Component/Cache/Traits/PhpArrayTrait.php
index 0bec18a07aa56..4395de0252894 100644
--- a/src/Symfony/Component/Cache/Traits/PhpArrayTrait.php
+++ b/src/Symfony/Component/Cache/Traits/PhpArrayTrait.php
@@ -86,7 +86,7 @@ public function warmUp(array $values)
$isStaticValue = false;
}
$value = var_export($value, true);
- } elseif (!\is_scalar($value)) {
+ } elseif (!is_scalar($value)) {
throw new InvalidArgumentException(sprintf('Cache key "%s" has non-serializable %s value.', $key, \gettype($value)));
} else {
$value = var_export($value, true);
diff --git a/src/Symfony/Component/Cache/Traits/PhpFilesTrait.php b/src/Symfony/Component/Cache/Traits/PhpFilesTrait.php
index 37d25f87a98fa..6afdd8c3a5425 100644
--- a/src/Symfony/Component/Cache/Traits/PhpFilesTrait.php
+++ b/src/Symfony/Component/Cache/Traits/PhpFilesTrait.php
@@ -182,7 +182,7 @@ protected function doSave(array $values, $lifetime)
$isStaticValue = false;
}
$value = var_export($value, true);
- } elseif (!\is_scalar($value)) {
+ } elseif (!is_scalar($value)) {
throw new InvalidArgumentException(sprintf('Cache key "%s" has non-serializable %s value.', $key, \gettype($value)));
} else {
$value = var_export($value, true);
diff --git a/src/Symfony/Component/Config/Definition/Exception/TreeWithoutRootNodeException.php b/src/Symfony/Component/Config/Definition/Exception/TreeWithoutRootNodeException.php
index 67b0c4bb2e084..04406fc90b416 100644
--- a/src/Symfony/Component/Config/Definition/Exception/TreeWithoutRootNodeException.php
+++ b/src/Symfony/Component/Config/Definition/Exception/TreeWithoutRootNodeException.php
@@ -13,6 +13,8 @@
/**
* @author Roland Franssen
+ *
+ * @internal
*/
class TreeWithoutRootNodeException extends \RuntimeException
{
diff --git a/src/Symfony/Component/Config/Tests/Loader/DelegatingLoaderTest.php b/src/Symfony/Component/Config/Tests/Loader/DelegatingLoaderTest.php
index 3517cacfd5dd9..daff5288efe9f 100644
--- a/src/Symfony/Component/Config/Tests/Loader/DelegatingLoaderTest.php
+++ b/src/Symfony/Component/Config/Tests/Loader/DelegatingLoaderTest.php
@@ -35,12 +35,12 @@ public function testGetSetResolver()
public function testSupports()
{
$loader1 = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock();
- $loader1->expects($this->once())->method('supports')->will($this->returnValue(true));
+ $loader1->expects($this->once())->method('supports')->willReturn(true);
$loader = new DelegatingLoader(new LoaderResolver([$loader1]));
$this->assertTrue($loader->supports('foo.xml'), '->supports() returns true if the resource is loadable');
$loader1 = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock();
- $loader1->expects($this->once())->method('supports')->will($this->returnValue(false));
+ $loader1->expects($this->once())->method('supports')->willReturn(false);
$loader = new DelegatingLoader(new LoaderResolver([$loader1]));
$this->assertFalse($loader->supports('foo.foo'), '->supports() returns false if the resource is not loadable');
}
@@ -48,7 +48,7 @@ public function testSupports()
public function testLoad()
{
$loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock();
- $loader->expects($this->once())->method('supports')->will($this->returnValue(true));
+ $loader->expects($this->once())->method('supports')->willReturn(true);
$loader->expects($this->once())->method('load');
$resolver = new LoaderResolver([$loader]);
$loader = new DelegatingLoader($resolver);
@@ -62,7 +62,7 @@ public function testLoad()
public function testLoadThrowsAnExceptionIfTheResourceCannotBeLoaded()
{
$loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock();
- $loader->expects($this->once())->method('supports')->will($this->returnValue(false));
+ $loader->expects($this->once())->method('supports')->willReturn(false);
$resolver = new LoaderResolver([$loader]);
$loader = new DelegatingLoader($resolver);
diff --git a/src/Symfony/Component/Config/Tests/Loader/LoaderResolverTest.php b/src/Symfony/Component/Config/Tests/Loader/LoaderResolverTest.php
index 487dc43adc310..aabc2a600d8dd 100644
--- a/src/Symfony/Component/Config/Tests/Loader/LoaderResolverTest.php
+++ b/src/Symfony/Component/Config/Tests/Loader/LoaderResolverTest.php
@@ -32,7 +32,7 @@ public function testResolve()
$this->assertFalse($resolver->resolve('foo.foo'), '->resolve() returns false if no loader is able to load the resource');
$loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock();
- $loader->expects($this->once())->method('supports')->will($this->returnValue(true));
+ $loader->expects($this->once())->method('supports')->willReturn(true);
$resolver = new LoaderResolver([$loader]);
$this->assertEquals($loader, $resolver->resolve(function () {}), '->resolve() returns the loader for the given resource');
}
diff --git a/src/Symfony/Component/Config/Tests/Loader/LoaderTest.php b/src/Symfony/Component/Config/Tests/Loader/LoaderTest.php
index 926cec833361e..cd14d58fe5eaf 100644
--- a/src/Symfony/Component/Config/Tests/Loader/LoaderTest.php
+++ b/src/Symfony/Component/Config/Tests/Loader/LoaderTest.php
@@ -34,7 +34,7 @@ public function testResolve()
$resolver->expects($this->once())
->method('resolve')
->with('foo.xml')
- ->will($this->returnValue($resolvedLoader));
+ ->willReturn($resolvedLoader);
$loader = new ProjectLoader1();
$loader->setResolver($resolver);
@@ -52,7 +52,7 @@ public function testResolveWhenResolverCannotFindLoader()
$resolver->expects($this->once())
->method('resolve')
->with('FOOBAR')
- ->will($this->returnValue(false));
+ ->willReturn(false);
$loader = new ProjectLoader1();
$loader->setResolver($resolver);
@@ -66,13 +66,13 @@ public function testImport()
$resolvedLoader->expects($this->once())
->method('load')
->with('foo')
- ->will($this->returnValue('yes'));
+ ->willReturn('yes');
$resolver = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderResolverInterface')->getMock();
$resolver->expects($this->once())
->method('resolve')
->with('foo')
- ->will($this->returnValue($resolvedLoader));
+ ->willReturn($resolvedLoader);
$loader = new ProjectLoader1();
$loader->setResolver($resolver);
@@ -86,13 +86,13 @@ public function testImportWithType()
$resolvedLoader->expects($this->once())
->method('load')
->with('foo', 'bar')
- ->will($this->returnValue('yes'));
+ ->willReturn('yes');
$resolver = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderResolverInterface')->getMock();
$resolver->expects($this->once())
->method('resolve')
->with('foo', 'bar')
- ->will($this->returnValue($resolvedLoader));
+ ->willReturn($resolvedLoader);
$loader = new ProjectLoader1();
$loader->setResolver($resolver);
diff --git a/src/Symfony/Component/Console/Application.php b/src/Symfony/Component/Console/Application.php
index 7522cef8f2fe6..5c0faa5fe9a4d 100644
--- a/src/Symfony/Component/Console/Application.php
+++ b/src/Symfony/Component/Console/Application.php
@@ -779,7 +779,7 @@ protected function doRenderException(\Exception $e, OutputInterface $output)
if (false !== strpos($message, "class@anonymous\0")) {
$message = preg_replace_callback('/class@anonymous\x00.*?\.php0x?[0-9a-fA-F]++/', function ($m) {
- return \class_exists($m[0], false) ? get_parent_class($m[0]).'@anonymous' : $m[0];
+ return class_exists($m[0], false) ? get_parent_class($m[0]).'@anonymous' : $m[0];
}, $message);
}
diff --git a/src/Symfony/Component/Console/Descriptor/JsonDescriptor.php b/src/Symfony/Component/Console/Descriptor/JsonDescriptor.php
index 197b843d4b76c..f5a143800b27c 100644
--- a/src/Symfony/Component/Console/Descriptor/JsonDescriptor.php
+++ b/src/Symfony/Component/Console/Descriptor/JsonDescriptor.php
@@ -97,7 +97,9 @@ protected function describeApplication(Application $application, array $options
*/
private function writeData(array $data, array $options)
{
- $this->write(json_encode($data, isset($options['json_encoding']) ? $options['json_encoding'] : 0));
+ $flags = isset($options['json_encoding']) ? $options['json_encoding'] : 0;
+
+ $this->write(json_encode($data, $flags));
}
/**
diff --git a/src/Symfony/Component/Console/Helper/ProcessHelper.php b/src/Symfony/Component/Console/Helper/ProcessHelper.php
index e3a7c77b35816..41f128bb49318 100644
--- a/src/Symfony/Component/Console/Helper/ProcessHelper.php
+++ b/src/Symfony/Component/Console/Helper/ProcessHelper.php
@@ -51,7 +51,7 @@ public function run(OutputInterface $output, $cmd, $error = null, callable $call
if (!\is_array($cmd)) {
@trigger_error(sprintf('Passing a command as a string to "%s()" is deprecated since Symfony 4.2, pass it the command as an array of arguments instead.', __METHOD__), E_USER_DEPRECATED);
- $cmd = [\method_exists(Process::class, 'fromShellCommandline') ? Process::fromShellCommandline($cmd) : new Process($cmd)];
+ $cmd = [method_exists(Process::class, 'fromShellCommandline') ? Process::fromShellCommandline($cmd) : new Process($cmd)];
}
if (\is_string($cmd[0] ?? null)) {
diff --git a/src/Symfony/Component/Console/Output/ConsoleSectionOutput.php b/src/Symfony/Component/Console/Output/ConsoleSectionOutput.php
index 4ada2e86739b8..ce2c28ba1a715 100644
--- a/src/Symfony/Component/Console/Output/ConsoleSectionOutput.php
+++ b/src/Symfony/Component/Console/Output/ConsoleSectionOutput.php
@@ -50,7 +50,7 @@ public function clear(int $lines = null)
}
if ($lines) {
- \array_splice($this->content, -($lines * 2)); // Multiply lines by 2 to cater for each new line added between content
+ array_splice($this->content, -($lines * 2)); // Multiply lines by 2 to cater for each new line added between content
} else {
$lines = $this->lines;
$this->content = [];
diff --git a/src/Symfony/Component/Console/Tests/ApplicationTest.php b/src/Symfony/Component/Console/Tests/ApplicationTest.php
index 0533bb42e7e79..e153e5609a258 100644
--- a/src/Symfony/Component/Console/Tests/ApplicationTest.php
+++ b/src/Symfony/Component/Console/Tests/ApplicationTest.php
@@ -709,7 +709,7 @@ public function testFindNamespaceDoesNotFailOnDeepSimilarNamespaces()
$application = $this->getMockBuilder('Symfony\Component\Console\Application')->setMethods(['getNamespaces'])->getMock();
$application->expects($this->once())
->method('getNamespaces')
- ->will($this->returnValue(['foo:sublong', 'bar:sub']));
+ ->willReturn(['foo:sublong', 'bar:sub']);
$this->assertEquals('foo:sublong', $application->findNamespace('f:sub'));
}
@@ -853,7 +853,7 @@ public function testRenderExceptionLineBreaks()
$application->setAutoExit(false);
$application->expects($this->any())
->method('getTerminalWidth')
- ->will($this->returnValue(120));
+ ->willReturn(120);
$application->register('foo')->setCode(function () {
throw new \InvalidArgumentException("\n\nline 1 with extra spaces \nline 2\n\nline 4\n");
});
diff --git a/src/Symfony/Component/Console/Tests/Command/CommandTest.php b/src/Symfony/Component/Console/Tests/Command/CommandTest.php
index 512feca706bd2..3e1673dd54400 100644
--- a/src/Symfony/Component/Console/Tests/Command/CommandTest.php
+++ b/src/Symfony/Component/Console/Tests/Command/CommandTest.php
@@ -321,7 +321,7 @@ public function testRunReturnsIntegerExitCode()
$command = $this->getMockBuilder('TestCommand')->setMethods(['execute'])->getMock();
$command->expects($this->once())
->method('execute')
- ->will($this->returnValue('2.3'));
+ ->willReturn('2.3');
$exitCode = $command->run(new StringInput(''), new NullOutput());
$this->assertSame(2, $exitCode, '->run() returns integer exit code (casts numeric to int)');
}
diff --git a/src/Symfony/Component/Console/Tests/Helper/AbstractQuestionHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/AbstractQuestionHelperTest.php
index 56dd65f6b456f..f12566dedd655 100644
--- a/src/Symfony/Component/Console/Tests/Helper/AbstractQuestionHelperTest.php
+++ b/src/Symfony/Component/Console/Tests/Helper/AbstractQuestionHelperTest.php
@@ -21,7 +21,7 @@ protected function createStreamableInputInterfaceMock($stream = null, $interacti
$mock = $this->getMockBuilder(StreamableInputInterface::class)->getMock();
$mock->expects($this->any())
->method('isInteractive')
- ->will($this->returnValue($interactive));
+ ->willReturn($interactive);
if ($stream) {
$mock->expects($this->any())
diff --git a/src/Symfony/Component/Console/Tests/Helper/HelperSetTest.php b/src/Symfony/Component/Console/Tests/Helper/HelperSetTest.php
index 826bc51dcd62b..ffb12b3421f9a 100644
--- a/src/Symfony/Component/Console/Tests/Helper/HelperSetTest.php
+++ b/src/Symfony/Component/Console/Tests/Helper/HelperSetTest.php
@@ -114,7 +114,7 @@ private function getGenericMockHelper($name, HelperSet $helperset = null)
$mock_helper = $this->getMockBuilder('\Symfony\Component\Console\Helper\HelperInterface')->getMock();
$mock_helper->expects($this->any())
->method('getName')
- ->will($this->returnValue($name));
+ ->willReturn($name);
if ($helperset) {
$mock_helper->expects($this->any())
diff --git a/src/Symfony/Component/Console/Tests/Helper/ProcessHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/ProcessHelperTest.php
index 5387a9e3c2ed5..82c6b445175d5 100644
--- a/src/Symfony/Component/Console/Tests/Helper/ProcessHelperTest.php
+++ b/src/Symfony/Component/Console/Tests/Helper/ProcessHelperTest.php
@@ -26,7 +26,7 @@ class ProcessHelperTest extends TestCase
public function testVariousProcessRuns($expected, $cmd, $verbosity, $error)
{
if (\is_string($cmd)) {
- $cmd = \method_exists(Process::class, 'fromShellCommandline') ? Process::fromShellCommandline($cmd) : new Process($cmd);
+ $cmd = method_exists(Process::class, 'fromShellCommandline') ? Process::fromShellCommandline($cmd) : new Process($cmd);
}
$helper = new ProcessHelper();
@@ -99,7 +99,7 @@ public function provideCommandsAndOutput()
$args = new Process(['php', '-r', 'echo 42;']);
$args = $args->getCommandLine();
$successOutputProcessDebug = str_replace("'php' '-r' 'echo 42;'", $args, $successOutputProcessDebug);
- $fromShellCommandline = \method_exists(Process::class, 'fromShellCommandline') ? [Process::class, 'fromShellCommandline'] : function ($cmd) { return new Process($cmd); };
+ $fromShellCommandline = method_exists(Process::class, 'fromShellCommandline') ? [Process::class, 'fromShellCommandline'] : function ($cmd) { return new Process($cmd); };
return [
['', 'php -r "echo 42;"', StreamOutput::VERBOSITY_VERBOSE, null],
diff --git a/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php
index 2acbad4785212..1ffd41c9cde7d 100644
--- a/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php
+++ b/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php
@@ -717,7 +717,7 @@ protected function createInputInterfaceMock($interactive = true)
$mock = $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface')->getMock();
$mock->expects($this->any())
->method('isInteractive')
- ->will($this->returnValue($interactive));
+ ->willReturn($interactive);
return $mock;
}
diff --git a/src/Symfony/Component/Console/Tests/Helper/SymfonyQuestionHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/SymfonyQuestionHelperTest.php
index cf7a78c34ecda..6f621db95448a 100644
--- a/src/Symfony/Component/Console/Tests/Helper/SymfonyQuestionHelperTest.php
+++ b/src/Symfony/Component/Console/Tests/Helper/SymfonyQuestionHelperTest.php
@@ -154,7 +154,7 @@ protected function createInputInterfaceMock($interactive = true)
$mock = $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface')->getMock();
$mock->expects($this->any())
->method('isInteractive')
- ->will($this->returnValue($interactive));
+ ->willReturn($interactive);
return $mock;
}
diff --git a/src/Symfony/Component/Console/Tests/Logger/ConsoleLoggerTest.php b/src/Symfony/Component/Console/Tests/Logger/ConsoleLoggerTest.php
index efeec4234e952..c99eb839b7f31 100644
--- a/src/Symfony/Component/Console/Tests/Logger/ConsoleLoggerTest.php
+++ b/src/Symfony/Component/Console/Tests/Logger/ConsoleLoggerTest.php
@@ -166,7 +166,7 @@ public function testObjectCastToString()
} else {
$dummy = $this->getMock('Symfony\Component\Console\Tests\Logger\DummyTest', ['__toString']);
}
- $dummy->method('__toString')->will($this->returnValue('DUMMY'));
+ $dummy->method('__toString')->willReturn('DUMMY');
$this->getLogger()->warning($dummy);
diff --git a/src/Symfony/Component/Debug/DebugClassLoader.php b/src/Symfony/Component/Debug/DebugClassLoader.php
index e648bf60c5375..55fd0df694e4d 100644
--- a/src/Symfony/Component/Debug/DebugClassLoader.php
+++ b/src/Symfony/Component/Debug/DebugClassLoader.php
@@ -171,7 +171,7 @@ public function loadClass($class)
private function checkClass($class, $file = null)
{
- $exists = null === $file || \class_exists($class, false) || \interface_exists($class, false) || \trait_exists($class, false);
+ $exists = null === $file || class_exists($class, false) || interface_exists($class, false) || trait_exists($class, false);
if (null !== $file && $class && '\\' === $class[0]) {
$class = substr($class, 1);
@@ -189,7 +189,7 @@ private function checkClass($class, $file = null)
}
$name = $refl->getName();
- if ($name !== $class && 0 === \strcasecmp($name, $class)) {
+ if ($name !== $class && 0 === strcasecmp($name, $class)) {
throw new \RuntimeException(sprintf('Case mismatch between loaded and declared class names: "%s" vs "%s".', $class, $name));
}
@@ -222,23 +222,23 @@ public function checkAnnotations(\ReflectionClass $refl, $class)
$deprecations = [];
// Don't trigger deprecations for classes in the same vendor
- if (2 > $len = 1 + (\strpos($class, '\\') ?: \strpos($class, '_'))) {
+ if (2 > $len = 1 + (strpos($class, '\\') ?: strpos($class, '_'))) {
$len = 0;
$ns = '';
} else {
- $ns = \str_replace('_', '\\', \substr($class, 0, $len));
+ $ns = str_replace('_', '\\', substr($class, 0, $len));
}
// Detect annotations on the class
if (false !== $doc = $refl->getDocComment()) {
foreach (['final', 'deprecated', 'internal'] as $annotation) {
- if (false !== \strpos($doc, $annotation) && preg_match('#\n\s+\* @'.$annotation.'(?:( .+?)\.?)?\r?\n\s+\*(?: @|/$|\r?\n)#s', $doc, $notice)) {
+ if (false !== strpos($doc, $annotation) && preg_match('#\n\s+\* @'.$annotation.'(?:( .+?)\.?)?\r?\n\s+\*(?: @|/$|\r?\n)#s', $doc, $notice)) {
self::${$annotation}[$class] = isset($notice[1]) ? preg_replace('#\.?\r?\n( \*)? *(?= |\r?\n|$)#', '', $notice[1]) : '';
}
}
}
- $parent = \get_parent_class($class);
+ $parent = get_parent_class($class);
$parentAndOwnInterfaces = $this->getOwnInterfaces($class, $parent);
if ($parent) {
$parentAndOwnInterfaces[$parent] = $parent;
@@ -253,22 +253,22 @@ public function checkAnnotations(\ReflectionClass $refl, $class)
}
// Detect if the parent is annotated
- foreach ($parentAndOwnInterfaces + \class_uses($class, false) as $use) {
+ foreach ($parentAndOwnInterfaces + class_uses($class, false) as $use) {
if (!isset(self::$checkedClasses[$use])) {
$this->checkClass($use);
}
- if (isset(self::$deprecated[$use]) && \strncmp($ns, \str_replace('_', '\\', $use), $len) && !isset(self::$deprecated[$class])) {
+ if (isset(self::$deprecated[$use]) && strncmp($ns, str_replace('_', '\\', $use), $len) && !isset(self::$deprecated[$class])) {
$type = class_exists($class, false) ? 'class' : (interface_exists($class, false) ? 'interface' : 'trait');
$verb = class_exists($use, false) || interface_exists($class, false) ? 'extends' : (interface_exists($use, false) ? 'implements' : 'uses');
$deprecations[] = sprintf('The "%s" %s %s "%s" that is deprecated%s.', $class, $type, $verb, $use, self::$deprecated[$use]);
}
- if (isset(self::$internal[$use]) && \strncmp($ns, \str_replace('_', '\\', $use), $len)) {
+ if (isset(self::$internal[$use]) && strncmp($ns, str_replace('_', '\\', $use), $len)) {
$deprecations[] = sprintf('The "%s" %s is considered internal%s. It may change without further notice. You should not use it from "%s".', $use, class_exists($use, false) ? 'class' : (interface_exists($use, false) ? 'interface' : 'trait'), self::$internal[$use], $class);
}
}
- if (\trait_exists($class)) {
+ if (trait_exists($class)) {
return $deprecations;
}
@@ -296,7 +296,7 @@ public function checkAnnotations(\ReflectionClass $refl, $class)
if (isset(self::$internalMethods[$class][$method->name])) {
list($declaringClass, $message) = self::$internalMethods[$class][$method->name];
- if (\strncmp($ns, $declaringClass, $len)) {
+ if (strncmp($ns, $declaringClass, $len)) {
$deprecations[] = sprintf('The "%s::%s()" method is considered internal%s. It may change without further notice. You should not extend it from "%s".', $declaringClass, $method->name, $message, $class);
}
}
@@ -324,14 +324,14 @@ public function checkAnnotations(\ReflectionClass $refl, $class)
$finalOrInternal = false;
foreach (['final', 'internal'] as $annotation) {
- if (false !== \strpos($doc, $annotation) && preg_match('#\n\s+\* @'.$annotation.'(?:( .+?)\.?)?\r?\n\s+\*(?: @|/$|\r?\n)#s', $doc, $notice)) {
+ if (false !== strpos($doc, $annotation) && preg_match('#\n\s+\* @'.$annotation.'(?:( .+?)\.?)?\r?\n\s+\*(?: @|/$|\r?\n)#s', $doc, $notice)) {
$message = isset($notice[1]) ? preg_replace('#\.?\r?\n( \*)? *(?= |\r?\n|$)#', '', $notice[1]) : '';
self::${$annotation.'Methods'}[$class][$method->name] = [$class, $message];
$finalOrInternal = true;
}
}
- if ($finalOrInternal || $method->isConstructor() || false === \strpos($doc, '@param') || StatelessInvocation::class === $class) {
+ if ($finalOrInternal || $method->isConstructor() || false === strpos($doc, '@param') || StatelessInvocation::class === $class) {
continue;
}
if (!preg_match_all('#\n\s+\* @param (.*?)(?<= )\$([a-zA-Z0-9_\x7f-\xff]++)#', $doc, $matches, PREG_SET_ORDER)) {
diff --git a/src/Symfony/Component/Debug/ErrorHandler.php b/src/Symfony/Component/Debug/ErrorHandler.php
index 78ac0240ab9ab..36bf67bdbb88c 100644
--- a/src/Symfony/Component/Debug/ErrorHandler.php
+++ b/src/Symfony/Component/Debug/ErrorHandler.php
@@ -380,6 +380,11 @@ private function reRegister($prev)
*/
public function handleError($type, $message, $file, $line)
{
+ // @deprecated to be removed in Symfony 5.0
+ if (\PHP_VERSION_ID >= 70300 && $message && '"' === $message[0] && 0 === strpos($message, '"continue') && preg_match('/^"continue(?: \d++)?" targeting switch is equivalent to "break(?: \d++)?"\. Did you mean to use "continue(?: \d++)?"\?$/', $message)) {
+ $type = E_DEPRECATED;
+ }
+
// Level is the current error reporting level to manage silent error.
$level = error_reporting();
$silenced = 0 === ($level & $type);
diff --git a/src/Symfony/Component/Debug/Exception/FlattenException.php b/src/Symfony/Component/Debug/Exception/FlattenException.php
index d016bb2fb45cc..ed8a4e87384bc 100644
--- a/src/Symfony/Component/Debug/Exception/FlattenException.php
+++ b/src/Symfony/Component/Debug/Exception/FlattenException.php
@@ -172,7 +172,7 @@ public function setMessage($message)
{
if (false !== strpos($message, "class@anonymous\0")) {
$message = preg_replace_callback('/class@anonymous\x00.*?\.php0x?[0-9a-fA-F]++/', function ($m) {
- return \class_exists($m[0], false) ? get_parent_class($m[0]).'@anonymous' : $m[0];
+ return class_exists($m[0], false) ? get_parent_class($m[0]).'@anonymous' : $m[0];
}, $message);
}
diff --git a/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php b/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php
index 43da7f27661c8..f758d21e0e989 100644
--- a/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php
+++ b/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php
@@ -234,7 +234,7 @@ public function testHandleError()
$logger
->expects($this->once())
->method('log')
- ->will($this->returnCallback($warnArgCheck))
+ ->willReturnCallback($warnArgCheck)
;
$handler = ErrorHandler::register();
@@ -262,7 +262,7 @@ public function testHandleError()
$logger
->expects($this->once())
->method('log')
- ->will($this->returnCallback($logArgCheck))
+ ->willReturnCallback($logArgCheck)
;
$handler = ErrorHandler::register();
@@ -318,7 +318,7 @@ public function testHandleDeprecation()
$logger
->expects($this->once())
->method('log')
- ->will($this->returnCallback($logArgCheck))
+ ->willReturnCallback($logArgCheck)
;
$handler = new ErrorHandler();
@@ -346,7 +346,7 @@ public function testHandleException()
$logger
->expects($this->exactly(2))
->method('log')
- ->will($this->returnCallback($logArgCheck))
+ ->willReturnCallback($logArgCheck)
;
$handler->setDefaultLogger($logger, E_ERROR);
@@ -462,7 +462,7 @@ public function testHandleFatalError()
$logger
->expects($this->once())
->method('log')
- ->will($this->returnCallback($logArgCheck))
+ ->willReturnCallback($logArgCheck)
;
$handler->setDefaultLogger($logger, E_PARSE);
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/MergeExtensionConfigurationPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/MergeExtensionConfigurationPassTest.php
index 8d07f6223a06a..a254ba99d8124 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/MergeExtensionConfigurationPassTest.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/MergeExtensionConfigurationPassTest.php
@@ -30,18 +30,18 @@ public function testExpressionLanguageProviderForwarding()
$extension = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\Extension\\ExtensionInterface')->getMock();
$extension->expects($this->any())
->method('getXsdValidationBasePath')
- ->will($this->returnValue(false));
+ ->willReturn(false);
$extension->expects($this->any())
->method('getNamespace')
- ->will($this->returnValue('http://example.org/schema/dic/foo'));
+ ->willReturn('http://example.org/schema/dic/foo');
$extension->expects($this->any())
->method('getAlias')
- ->will($this->returnValue('foo'));
+ ->willReturn('foo');
$extension->expects($this->once())
->method('load')
- ->will($this->returnCallback(function (array $config, ContainerBuilder $container) use (&$tmpProviders) {
+ ->willReturnCallback(function (array $config, ContainerBuilder $container) use (&$tmpProviders) {
$tmpProviders = $container->getExpressionLanguageProviders();
- }));
+ });
$provider = $this->getMockBuilder('Symfony\\Component\\ExpressionLanguage\\ExpressionFunctionProviderInterface')->getMock();
$container = new ContainerBuilder(new ParameterBag());
@@ -76,7 +76,7 @@ public function testExtensionConfigurationIsTrackedByDefault()
$extension = $this->getMockBuilder(FooExtension::class)->setMethods(['getConfiguration'])->getMock();
$extension->expects($this->exactly(2))
->method('getConfiguration')
- ->will($this->returnValue(new FooConfiguration()));
+ ->willReturn(new FooConfiguration());
$container = new ContainerBuilder(new ParameterBag());
$container->registerExtension($extension);
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ValidateEnvPlaceholdersPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ValidateEnvPlaceholdersPassTest.php
index b57fb66bff043..7e1de8f08374e 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ValidateEnvPlaceholdersPassTest.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ValidateEnvPlaceholdersPassTest.php
@@ -226,16 +226,15 @@ public function testEnvWithVariableNode(): void
/**
* @group legacy
+ * @expectedDeprecation A tree builder without a root node is deprecated since Symfony 4.2 and will not be supported anymore in 5.0.
*/
public function testConfigurationWithoutRootNode(): void
{
$container = new ContainerBuilder();
$container->registerExtension(new EnvExtension(new EnvConfigurationWithoutRootNode()));
- $container->loadFromExtension('env_extension');
+ $container->loadFromExtension('env_extension', ['foo' => 'bar']);
- $this->doProcess($container);
-
- $this->addToAssertionCount(1);
+ (new ValidateEnvPlaceholdersPass())->process($container);
}
public function testEmptyConfigFromMoreThanOneSource()
@@ -340,8 +339,8 @@ class ConfigurationWithArrayNodeRequiringOneElement implements ConfigurationInte
{
public function getConfigTreeBuilder()
{
- $treeBuilder = new TreeBuilder();
- $treeBuilder->root('env_extension')
+ $treeBuilder = new TreeBuilder('env_extension');
+ $treeBuilder->getRootNode()
->children()
->arrayNode('nodes')
->isRequired()
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Config/ContainerParametersResourceCheckerTest.php b/src/Symfony/Component/DependencyInjection/Tests/Config/ContainerParametersResourceCheckerTest.php
index fc2d85ecf9560..eb5fc5a99d2e1 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Config/ContainerParametersResourceCheckerTest.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/Config/ContainerParametersResourceCheckerTest.php
@@ -67,10 +67,10 @@ public function isFreshProvider()
[$this->equalTo('locales')],
[$this->equalTo('default_locale')]
)
- ->will($this->returnValueMap([
+ ->willReturnMap([
['locales', ['fr', 'en']],
['default_locale', 'fr'],
- ]))
+ ])
;
}, true];
}
diff --git a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php
index 53b337ed56ef9..efef8fe308ef7 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php
@@ -1033,7 +1033,7 @@ public function testExtension()
public function testRegisteredButNotLoadedExtension()
{
$extension = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\Extension\\ExtensionInterface')->getMock();
- $extension->expects($this->once())->method('getAlias')->will($this->returnValue('project'));
+ $extension->expects($this->once())->method('getAlias')->willReturn('project');
$extension->expects($this->never())->method('load');
$container = new ContainerBuilder();
@@ -1045,7 +1045,7 @@ public function testRegisteredButNotLoadedExtension()
public function testRegisteredAndLoadedExtension()
{
$extension = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\Extension\\ExtensionInterface')->getMock();
- $extension->expects($this->exactly(2))->method('getAlias')->will($this->returnValue('project'));
+ $extension->expects($this->exactly(2))->method('getAlias')->willReturn('project');
$extension->expects($this->once())->method('load')->with([['foo' => 'bar']]);
$container = new ContainerBuilder();
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php
index 57b9c11bf6ff9..620a5d775877d 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php
@@ -614,7 +614,7 @@ public function testPrototype()
$fixturesDir = \dirname(__DIR__).\DIRECTORY_SEPARATOR.'Fixtures'.\DIRECTORY_SEPARATOR;
$this->assertContains((string) new FileResource($fixturesDir.'xml'.\DIRECTORY_SEPARATOR.'services_prototype.xml'), $resources);
- $prototypeRealPath = \realpath(__DIR__.\DIRECTORY_SEPARATOR.'..'.\DIRECTORY_SEPARATOR.'Fixtures'.\DIRECTORY_SEPARATOR.'Prototype');
+ $prototypeRealPath = realpath(__DIR__.\DIRECTORY_SEPARATOR.'..'.\DIRECTORY_SEPARATOR.'Fixtures'.\DIRECTORY_SEPARATOR.'Prototype');
$globResource = new GlobResource(
$fixturesDir.'Prototype',
'/*',
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php
index 836ce993c1da8..4351e3c0c1e7c 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php
@@ -367,7 +367,7 @@ public function testPrototype()
$fixturesDir = \dirname(__DIR__).\DIRECTORY_SEPARATOR.'Fixtures'.\DIRECTORY_SEPARATOR;
$this->assertContains((string) new FileResource($fixturesDir.'yaml'.\DIRECTORY_SEPARATOR.'services_prototype.yml'), $resources);
- $prototypeRealPath = \realpath(__DIR__.\DIRECTORY_SEPARATOR.'..'.\DIRECTORY_SEPARATOR.'Fixtures'.\DIRECTORY_SEPARATOR.'Prototype');
+ $prototypeRealPath = realpath(__DIR__.\DIRECTORY_SEPARATOR.'..'.\DIRECTORY_SEPARATOR.'Fixtures'.\DIRECTORY_SEPARATOR.'Prototype');
$globResource = new GlobResource(
$fixturesDir.'Prototype',
'',
diff --git a/src/Symfony/Component/DependencyInjection/TypedReference.php b/src/Symfony/Component/DependencyInjection/TypedReference.php
index f80ac50563972..56a878874e2df 100644
--- a/src/Symfony/Component/DependencyInjection/TypedReference.php
+++ b/src/Symfony/Component/DependencyInjection/TypedReference.php
@@ -34,7 +34,7 @@ public function __construct(string $id, string $type, $invalidBehavior = Contain
@trigger_error(sprintf('The $requiringClass argument of "%s()" is deprecated since Symfony 4.1.', __METHOD__), E_USER_DEPRECATED);
$this->requiringClass = $invalidBehavior;
- $invalidBehavior = 3 < \func_num_args() ? \func_get_arg(3) : ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE;
+ $invalidBehavior = 3 < \func_num_args() ? func_get_arg(3) : ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE;
} else {
$this->name = $type === $id ? $name : null;
}
diff --git a/src/Symfony/Component/DomCrawler/Crawler.php b/src/Symfony/Component/DomCrawler/Crawler.php
index 5dbffe42c609a..1c99293c0d213 100644
--- a/src/Symfony/Component/DomCrawler/Crawler.php
+++ b/src/Symfony/Component/DomCrawler/Crawler.php
@@ -1165,7 +1165,7 @@ private function createSubCrawler($nodes)
*/
private function createCssSelectorConverter(): CssSelectorConverter
{
- if (!\class_exists(CssSelectorConverter::class)) {
+ if (!class_exists(CssSelectorConverter::class)) {
throw new \LogicException('To filter with a CSS selector, install the CssSelector component ("composer require symfony/css-selector"). Or use filterXpath instead.');
}
diff --git a/src/Symfony/Component/DomCrawler/Form.php b/src/Symfony/Component/DomCrawler/Form.php
index 339603d09ef2d..8bdd364347601 100644
--- a/src/Symfony/Component/DomCrawler/Form.php
+++ b/src/Symfony/Component/DomCrawler/Form.php
@@ -44,7 +44,7 @@ class Form extends Link implements \ArrayAccess
*
* @throws \LogicException if the node is not a button inside a form tag
*/
- public function __construct(\DOMElement $node, string $currentUri, string $method = null, string $baseHref = null)
+ public function __construct(\DOMElement $node, string $currentUri = null, string $method = null, string $baseHref = null)
{
parent::__construct($node, $currentUri, $method);
$this->baseHref = $baseHref;
diff --git a/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php b/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php
index c3b40f322663b..548fd1833f114 100644
--- a/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php
+++ b/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php
@@ -1091,6 +1091,7 @@ public function getBaseTagWithFormData()
['/basepath', '/registration', 'http://domain.com/registration', 'http://domain.com/registration', ' tag does work with a path and form action'],
['/basepath', '', 'http://domain.com/registration', 'http://domain.com/registration', ' tag does work with a path and empty form action'],
['http://base.com/', '/registration', 'http://base.com/registration', 'http://domain.com/registration', ' tag does work with a URL and form action'],
+ ['http://base.com/', 'http://base.com/registration', 'http://base.com/registration', null, ' tag does work with a URL and form action'],
['http://base.com', '', 'http://domain.com/path/form', 'http://domain.com/path/form', ' tag does work with a URL and an empty form action'],
['http://base.com/path', '/registration', 'http://base.com/registration', 'http://domain.com/path/form', ' tag does work with a URL and form action'],
];
diff --git a/src/Symfony/Component/DomCrawler/Tests/FormTest.php b/src/Symfony/Component/DomCrawler/Tests/FormTest.php
index 2778fd075e3a5..2c0ee22c1fc45 100644
--- a/src/Symfony/Component/DomCrawler/Tests/FormTest.php
+++ b/src/Symfony/Component/DomCrawler/Tests/FormTest.php
@@ -862,13 +862,13 @@ protected function getFormFieldMock($name, $value = null)
$field
->expects($this->any())
->method('getName')
- ->will($this->returnValue($name))
+ ->willReturn($name)
;
$field
->expects($this->any())
->method('getValue')
- ->will($this->returnValue($value))
+ ->willReturn($value)
;
return $field;
diff --git a/src/Symfony/Component/Dotenv/Dotenv.php b/src/Symfony/Component/Dotenv/Dotenv.php
index fa9a2ee931a77..dbb70c4730aa8 100644
--- a/src/Symfony/Component/Dotenv/Dotenv.php
+++ b/src/Symfony/Component/Dotenv/Dotenv.php
@@ -382,7 +382,7 @@ private function resolveCommands($value)
throw new \LogicException('Resolving commands requires the Symfony Process component.');
}
- $process = \method_exists(Process::class, 'fromShellCommandline') ? Process::fromShellCommandline('echo '.$matches[0]) : new Process('echo '.$matches[0]);
+ $process = method_exists(Process::class, 'fromShellCommandline') ? Process::fromShellCommandline('echo '.$matches[0]) : new Process('echo '.$matches[0]);
$process->inheritEnvironmentVariables(true);
$process->setEnv($this->values);
try {
diff --git a/src/Symfony/Component/Dotenv/Tests/DotenvTest.php b/src/Symfony/Component/Dotenv/Tests/DotenvTest.php
index 156fcf4dd721b..05d1bedcbd6de 100644
--- a/src/Symfony/Component/Dotenv/Tests/DotenvTest.php
+++ b/src/Symfony/Component/Dotenv/Tests/DotenvTest.php
@@ -305,7 +305,7 @@ public function testLoadDirectory()
$dotenv->load(__DIR__);
}
- public function testServerSuperglobalIsNotOverriden()
+ public function testServerSuperglobalIsNotOverridden()
{
$originalValue = $_SERVER['argc'];
@@ -315,7 +315,7 @@ public function testServerSuperglobalIsNotOverriden()
$this->assertSame($originalValue, $_SERVER['argc']);
}
- public function testEnvVarIsNotOverriden()
+ public function testEnvVarIsNotOverridden()
{
putenv('TEST_ENV_VAR=original_value');
$_SERVER['TEST_ENV_VAR'] = 'original_value';
@@ -326,7 +326,7 @@ public function testEnvVarIsNotOverriden()
$this->assertSame('original_value', getenv('TEST_ENV_VAR'));
}
- public function testHttpVarIsPartiallyOverriden()
+ public function testHttpVarIsPartiallyOverridden()
{
$_SERVER['HTTP_TEST_ENV_VAR'] = 'http_value';
diff --git a/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php b/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php
index 9ec9a3469684d..2f1b7d33aeb88 100644
--- a/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php
+++ b/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php
@@ -193,21 +193,18 @@ public function getNotCalledListeners()
return [];
}
+ $calledListeners = [];
+
+ if (null !== $this->callStack) {
+ foreach ($this->callStack as $calledListener) {
+ $calledListeners[] = $calledListener->getWrappedListener();
+ }
+ }
+
$notCalled = [];
foreach ($allListeners as $eventName => $listeners) {
foreach ($listeners as $listener) {
- $called = false;
- if (null !== $this->callStack) {
- foreach ($this->callStack as $calledListener) {
- if ($calledListener->getWrappedListener() === $listener) {
- $called = true;
-
- break;
- }
- }
- }
-
- if (!$called) {
+ if (!\in_array($listener, $calledListeners, true)) {
if (!$listener instanceof WrappedListener) {
$listener = new WrappedListener($listener, null, $this->stopwatch, $this);
}
diff --git a/src/Symfony/Component/EventDispatcher/Tests/ImmutableEventDispatcherTest.php b/src/Symfony/Component/EventDispatcher/Tests/ImmutableEventDispatcherTest.php
index 04f2861e33193..c52fefe509ae9 100644
--- a/src/Symfony/Component/EventDispatcher/Tests/ImmutableEventDispatcherTest.php
+++ b/src/Symfony/Component/EventDispatcher/Tests/ImmutableEventDispatcherTest.php
@@ -43,7 +43,7 @@ public function testDispatchDelegates()
$this->innerDispatcher->expects($this->once())
->method('dispatch')
->with('event', $event)
- ->will($this->returnValue('result'));
+ ->willReturn('result');
$this->assertSame('result', $this->dispatcher->dispatch('event', $event));
}
@@ -53,7 +53,7 @@ public function testGetListenersDelegates()
$this->innerDispatcher->expects($this->once())
->method('getListeners')
->with('event')
- ->will($this->returnValue('result'));
+ ->willReturn('result');
$this->assertSame('result', $this->dispatcher->getListeners('event'));
}
@@ -63,7 +63,7 @@ public function testHasListenersDelegates()
$this->innerDispatcher->expects($this->once())
->method('hasListeners')
->with('event')
- ->will($this->returnValue('result'));
+ ->willReturn('result');
$this->assertSame('result', $this->dispatcher->hasListeners('event'));
}
diff --git a/src/Symfony/Component/ExpressionLanguage/Tests/ExpressionLanguageTest.php b/src/Symfony/Component/ExpressionLanguage/Tests/ExpressionLanguageTest.php
index f9c9dae42b50a..41a1f578d4017 100644
--- a/src/Symfony/Component/ExpressionLanguage/Tests/ExpressionLanguageTest.php
+++ b/src/Symfony/Component/ExpressionLanguage/Tests/ExpressionLanguageTest.php
@@ -36,18 +36,18 @@ public function testCachedParse()
$cacheItemMock
->expects($this->exactly(2))
->method('get')
- ->will($this->returnCallback(function () use (&$savedParsedExpression) {
+ ->willReturnCallback(function () use (&$savedParsedExpression) {
return $savedParsedExpression;
- }))
+ })
;
$cacheItemMock
->expects($this->exactly(1))
->method('set')
->with($this->isInstanceOf(ParsedExpression::class))
- ->will($this->returnCallback(function ($parsedExpression) use (&$savedParsedExpression) {
+ ->willReturnCallback(function ($parsedExpression) use (&$savedParsedExpression) {
$savedParsedExpression = $parsedExpression;
- }))
+ })
;
$cacheMock
@@ -172,18 +172,18 @@ public function testCachingWithDifferentNamesOrder()
$cacheItemMock
->expects($this->exactly(2))
->method('get')
- ->will($this->returnCallback(function () use (&$savedParsedExpression) {
+ ->willReturnCallback(function () use (&$savedParsedExpression) {
return $savedParsedExpression;
- }))
+ })
;
$cacheItemMock
->expects($this->exactly(1))
->method('set')
->with($this->isInstanceOf(ParsedExpression::class))
- ->will($this->returnCallback(function ($parsedExpression) use (&$savedParsedExpression) {
+ ->willReturnCallback(function ($parsedExpression) use (&$savedParsedExpression) {
$savedParsedExpression = $parsedExpression;
- }))
+ })
;
$cacheMock
diff --git a/src/Symfony/Component/Filesystem/Filesystem.php b/src/Symfony/Component/Filesystem/Filesystem.php
index 082084b4d93d1..dc3290c9aff6d 100644
--- a/src/Symfony/Component/Filesystem/Filesystem.php
+++ b/src/Symfony/Component/Filesystem/Filesystem.php
@@ -743,16 +743,15 @@ private function getSchemeAndHierarchy(string $filename): array
private static function box($func)
{
self::$lastError = null;
- \set_error_handler(__CLASS__.'::handleError');
+ set_error_handler(__CLASS__.'::handleError');
try {
$result = $func(...\array_slice(\func_get_args(), 1));
- \restore_error_handler();
+ restore_error_handler();
return $result;
} catch (\Throwable $e) {
- } catch (\Exception $e) {
}
- \restore_error_handler();
+ restore_error_handler();
throw $e;
}
diff --git a/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php b/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php
index 8ad94a1e28abb..d51b4f9e0108c 100644
--- a/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php
+++ b/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php
@@ -1372,6 +1372,22 @@ public function testMirrorWithCustomIteratorWithRelativePath()
$this->filesystem->mirror($sourcePath, $targetPath, $iterator);
}
+ public function testMirrorFromSubdirectoryInToParentDirectory()
+ {
+ $targetPath = $this->workspace.\DIRECTORY_SEPARATOR.'foo'.\DIRECTORY_SEPARATOR;
+ $sourcePath = $targetPath.'bar'.\DIRECTORY_SEPARATOR;
+ $file1 = $sourcePath.'file1';
+ $file2 = $sourcePath.'file2';
+
+ $this->filesystem->mkdir($sourcePath);
+ file_put_contents($file1, 'FILE1');
+ file_put_contents($file2, 'FILE2');
+
+ $this->filesystem->mirror($sourcePath, $targetPath);
+
+ $this->assertFileEquals($file1, $targetPath.'file1');
+ }
+
/**
* @dataProvider providePathsForIsAbsolutePath
*/
diff --git a/src/Symfony/Component/Finder/Finder.php b/src/Symfony/Component/Finder/Finder.php
index 83163f51d52eb..7b7b1152efc03 100644
--- a/src/Symfony/Component/Finder/Finder.php
+++ b/src/Symfony/Component/Finder/Finder.php
@@ -172,7 +172,7 @@ public function date($dates)
*/
public function name($patterns)
{
- $this->names = \array_merge($this->names, (array) $patterns);
+ $this->names = array_merge($this->names, (array) $patterns);
return $this;
}
@@ -188,7 +188,7 @@ public function name($patterns)
*/
public function notName($patterns)
{
- $this->notNames = \array_merge($this->notNames, (array) $patterns);
+ $this->notNames = array_merge($this->notNames, (array) $patterns);
return $this;
}
@@ -210,7 +210,7 @@ public function notName($patterns)
*/
public function contains($patterns)
{
- $this->contains = \array_merge($this->contains, (array) $patterns);
+ $this->contains = array_merge($this->contains, (array) $patterns);
return $this;
}
@@ -232,7 +232,7 @@ public function contains($patterns)
*/
public function notContains($patterns)
{
- $this->notContains = \array_merge($this->notContains, (array) $patterns);
+ $this->notContains = array_merge($this->notContains, (array) $patterns);
return $this;
}
@@ -256,7 +256,7 @@ public function notContains($patterns)
*/
public function path($patterns)
{
- $this->paths = \array_merge($this->paths, (array) $patterns);
+ $this->paths = array_merge($this->paths, (array) $patterns);
return $this;
}
@@ -280,7 +280,7 @@ public function path($patterns)
*/
public function notPath($patterns)
{
- $this->notPaths = \array_merge($this->notPaths, (array) $patterns);
+ $this->notPaths = array_merge($this->notPaths, (array) $patterns);
return $this;
}
diff --git a/src/Symfony/Component/Form/Console/Descriptor/JsonDescriptor.php b/src/Symfony/Component/Form/Console/Descriptor/JsonDescriptor.php
index 18a288b444dd6..9c4c68a5ccbb4 100644
--- a/src/Symfony/Component/Form/Console/Descriptor/JsonDescriptor.php
+++ b/src/Symfony/Component/Form/Console/Descriptor/JsonDescriptor.php
@@ -94,7 +94,8 @@ protected function describeOption(OptionsResolver $optionsResolver, array $optio
private function writeData(array $data, array $options)
{
- $flags = $options['json_encoding'] ?? 0;
+ $flags = isset($options['json_encoding']) ? $options['json_encoding'] : 0;
+
$this->output->write(json_encode($data, $flags | JSON_PRETTY_PRINT)."\n");
}
diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformer.php
index b97773353c6f7..a56e8e98cb4b8 100644
--- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformer.php
+++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformer.php
@@ -162,11 +162,8 @@ protected function getIntlDateFormatter($ignoreTimezone = false)
{
$dateFormat = $this->dateFormat;
$timeFormat = $this->timeFormat;
- $timezone = $ignoreTimezone ? 'UTC' : $this->outputTimezone;
- if (class_exists('IntlTimeZone', false)) {
- // see https://bugs.php.net/bug.php?id=66323
- $timezone = \IntlTimeZone::createTimeZone($timezone);
- }
+ $timezone = new \DateTimeZone($ignoreTimezone ? 'UTC' : $this->outputTimezone);
+
$calendar = $this->calendar;
$pattern = $this->pattern;
diff --git a/src/Symfony/Component/Form/Extension/Core/Type/BirthdayType.php b/src/Symfony/Component/Form/Extension/Core/Type/BirthdayType.php
index 841bd0d85f32f..acb8d02b8c5a9 100644
--- a/src/Symfony/Component/Form/Extension/Core/Type/BirthdayType.php
+++ b/src/Symfony/Component/Form/Extension/Core/Type/BirthdayType.php
@@ -21,7 +21,7 @@ class BirthdayType extends AbstractType
*/
public function configureOptions(OptionsResolver $resolver)
{
- $resolver->setDefault('years', range(date('Y') - 120, date('Y')));
+ $resolver->setDefault('years', range((int) date('Y') - 120, date('Y')));
$resolver->setAllowedTypes('years', 'array');
}
diff --git a/src/Symfony/Component/Form/Extension/Core/Type/DateType.php b/src/Symfony/Component/Form/Extension/Core/Type/DateType.php
index 81a928871dd08..44e5af6fe7ae3 100644
--- a/src/Symfony/Component/Form/Extension/Core/Type/DateType.php
+++ b/src/Symfony/Component/Form/Extension/Core/Type/DateType.php
@@ -259,7 +259,7 @@ public function configureOptions(OptionsResolver $resolver)
};
$resolver->setDefaults([
- 'years' => range(date('Y') - 5, date('Y') + 5),
+ 'years' => range((int) date('Y') - 5, (int) date('Y') + 5),
'months' => range(1, 12),
'days' => range(1, 31),
'widget' => 'choice',
diff --git a/src/Symfony/Component/Form/Extension/Core/Type/FileType.php b/src/Symfony/Component/Form/Extension/Core/Type/FileType.php
index f8afce2ee5a4d..abc30d819550a 100644
--- a/src/Symfony/Component/Form/Extension/Core/Type/FileType.php
+++ b/src/Symfony/Component/Form/Extension/Core/Type/FileType.php
@@ -20,7 +20,8 @@
use Symfony\Component\Form\FormView;
use Symfony\Component\OptionsResolver\Options;
use Symfony\Component\OptionsResolver\OptionsResolver;
-use Symfony\Component\Translation\TranslatorInterface;
+use Symfony\Component\Translation\TranslatorInterface as LegacyTranslatorInterface;
+use Symfony\Contracts\Translation\TranslatorInterface;
class FileType extends AbstractType
{
@@ -35,8 +36,14 @@ class FileType extends AbstractType
private $translator;
- public function __construct(TranslatorInterface $translator = null)
+ /**
+ * @param TranslatorInterface|null $translator
+ */
+ public function __construct($translator = null)
{
+ if (null !== $translator && !$translator instanceof LegacyTranslatorInterface && !$translator instanceof TranslatorInterface) {
+ throw new \TypeError(sprintf('Argument 1 passed to %s() must be an instance of %s, %s given.', __METHOD__, TranslatorInterface::class, \is_object($translator) ? \get_class($translator) : \gettype($translator)));
+ }
$this->translator = $translator;
}
@@ -159,7 +166,7 @@ private function getFileUploadError($errorCode)
}
if (null !== $this->translator) {
- $message = $this->translator->trans($messageTemplate, $messageParameters);
+ $message = $this->translator->trans($messageTemplate, $messageParameters, 'validators');
} else {
$message = strtr($messageTemplate, $messageParameters);
}
diff --git a/src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php b/src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php
index 8a5cd14ff4dca..206c75b153ea1 100644
--- a/src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php
+++ b/src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php
@@ -13,6 +13,7 @@
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Validator\Constraint;
+use Symfony\Component\Validator\Constraints\Composite;
use Symfony\Component\Validator\Constraints\GroupSequence;
use Symfony\Component\Validator\Constraints\Valid;
use Symfony\Component\Validator\ConstraintValidator;
@@ -90,7 +91,9 @@ public function validate($form, Constraint $formConstraint)
$validator->atPath('data')->validate($form->getData(), $constraint, $group);
// Prevent duplicate validation
- continue 2;
+ if (!$constraint instanceof Composite) {
+ continue 2;
+ }
}
}
}
diff --git a/src/Symfony/Component/Form/Form.php b/src/Symfony/Component/Form/Form.php
index f54bd73d48340..12be6c4ca515b 100644
--- a/src/Symfony/Component/Form/Form.php
+++ b/src/Symfony/Component/Form/Form.php
@@ -89,7 +89,7 @@ class Form implements \IteratorAggregate, FormInterface, ClearableErrorsInterfac
private $submitted = false;
/**
- * @var ClickableInterface|null The button that was used to submit the form
+ * @var FormInterface|ClickableInterface|null The button that was used to submit the form
*/
private $clickedButton;
@@ -747,7 +747,7 @@ public function isValid()
/**
* Returns the button that was used to submit the form.
*
- * @return ClickableInterface|null
+ * @return FormInterface|ClickableInterface|null
*/
public function getClickedButton()
{
diff --git a/src/Symfony/Component/Form/Resources/translations/validators.tr.xlf b/src/Symfony/Component/Form/Resources/translations/validators.tr.xlf
new file mode 100644
index 0000000000000..70e8541ed909c
--- /dev/null
+++ b/src/Symfony/Component/Form/Resources/translations/validators.tr.xlf
@@ -0,0 +1,19 @@
+
+
+
+
+
+ This form should not contain extra fields.
+ Form ekstra alanlar içeremez.
+
+
+ The uploaded file was too large. Please try to upload a smaller file.
+ Yüklenen dosya boyutu çok yüksek. Lütfen daha küçük bir dosya yüklemeyi deneyin.
+
+
+ The CSRF token is invalid. Please try to resubmit the form.
+ CSRF fişi geçersiz. Formu tekrar göndermeyi deneyin.
+
+
+
+
diff --git a/src/Symfony/Component/Form/Tests/AbstractDivLayoutTest.php b/src/Symfony/Component/Form/Tests/AbstractDivLayoutTest.php
index ab8444974959d..fe0d3e6629b26 100644
--- a/src/Symfony/Component/Form/Tests/AbstractDivLayoutTest.php
+++ b/src/Symfony/Component/Form/Tests/AbstractDivLayoutTest.php
@@ -473,7 +473,7 @@ public function testCsrf()
{
$this->csrfTokenManager->expects($this->any())
->method('getToken')
- ->will($this->returnValue(new CsrfToken('token_id', 'foo&bar')));
+ ->willReturn(new CsrfToken('token_id', 'foo&bar'));
$form = $this->factory->createNamedBuilder('name', 'Symfony\Component\Form\Extension\Core\Type\FormType')
->add($this->factory
diff --git a/src/Symfony/Component/Form/Tests/AbstractRequestHandlerTest.php b/src/Symfony/Component/Form/Tests/AbstractRequestHandlerTest.php
index b470769344bb2..f2ee71b3424cd 100644
--- a/src/Symfony/Component/Form/Tests/AbstractRequestHandlerTest.php
+++ b/src/Symfony/Component/Form/Tests/AbstractRequestHandlerTest.php
@@ -312,10 +312,10 @@ public function testAddFormErrorIfPostMaxSizeExceeded($contentLength, $iniMax, $
{
$this->serverParams->expects($this->once())
->method('getContentLength')
- ->will($this->returnValue($contentLength));
+ ->willReturn($contentLength);
$this->serverParams->expects($this->any())
->method('getNormalizedIniPostMaxSize')
- ->will($this->returnValue($iniMax));
+ ->willReturn($iniMax);
$options = ['post_max_size_message' => 'Max {{ max }}!'];
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, $options);
diff --git a/src/Symfony/Component/Form/Tests/AbstractTableLayoutTest.php b/src/Symfony/Component/Form/Tests/AbstractTableLayoutTest.php
index 6c09ba8ead456..7cc68bd83d268 100644
--- a/src/Symfony/Component/Form/Tests/AbstractTableLayoutTest.php
+++ b/src/Symfony/Component/Form/Tests/AbstractTableLayoutTest.php
@@ -339,7 +339,7 @@ public function testCsrf()
{
$this->csrfTokenManager->expects($this->any())
->method('getToken')
- ->will($this->returnValue(new CsrfToken('token_id', 'foo&bar')));
+ ->willReturn(new CsrfToken('token_id', 'foo&bar'));
$form = $this->factory->createNamedBuilder('name', 'Symfony\Component\Form\Extension\Core\Type\FormType')
->add($this->factory
diff --git a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/CachingFactoryDecoratorTest.php b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/CachingFactoryDecoratorTest.php
index ca5b67c817f2e..7277d49780d65 100644
--- a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/CachingFactoryDecoratorTest.php
+++ b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/CachingFactoryDecoratorTest.php
@@ -42,7 +42,7 @@ public function testCreateFromChoicesEmpty()
$this->decoratedFactory->expects($this->once())
->method('createListFromChoices')
->with([])
- ->will($this->returnValue($list));
+ ->willReturn($list);
$this->assertSame($list, $this->factory->createListFromChoices([]));
$this->assertSame($list, $this->factory->createListFromChoices([]));
@@ -58,7 +58,7 @@ public function testCreateFromChoicesComparesTraversableChoicesAsArray()
$this->decoratedFactory->expects($this->once())
->method('createListFromChoices')
->with($choices2)
- ->will($this->returnValue($list));
+ ->willReturn($list);
$this->assertSame($list, $this->factory->createListFromChoices($choices1));
$this->assertSame($list, $this->factory->createListFromChoices($choices2));
@@ -74,11 +74,11 @@ public function testCreateFromChoicesGroupedChoices()
$this->decoratedFactory->expects($this->at(0))
->method('createListFromChoices')
->with($choices1)
- ->will($this->returnValue($list1));
+ ->willReturn($list1);
$this->decoratedFactory->expects($this->at(1))
->method('createListFromChoices')
->with($choices2)
- ->will($this->returnValue($list2));
+ ->willReturn($list2);
$this->assertSame($list1, $this->factory->createListFromChoices($choices1));
$this->assertSame($list2, $this->factory->createListFromChoices($choices2));
@@ -96,7 +96,7 @@ public function testCreateFromChoicesSameChoices($choice1, $choice2)
$this->decoratedFactory->expects($this->once())
->method('createListFromChoices')
->with($choices1)
- ->will($this->returnValue($list));
+ ->willReturn($list);
$this->assertSame($list, $this->factory->createListFromChoices($choices1));
$this->assertSame($list, $this->factory->createListFromChoices($choices2));
@@ -115,11 +115,11 @@ public function testCreateFromChoicesDifferentChoices($choice1, $choice2)
$this->decoratedFactory->expects($this->at(0))
->method('createListFromChoices')
->with($choices1)
- ->will($this->returnValue($list1));
+ ->willReturn($list1);
$this->decoratedFactory->expects($this->at(1))
->method('createListFromChoices')
->with($choices2)
- ->will($this->returnValue($list2));
+ ->willReturn($list2);
$this->assertSame($list1, $this->factory->createListFromChoices($choices1));
$this->assertSame($list2, $this->factory->createListFromChoices($choices2));
@@ -134,7 +134,7 @@ public function testCreateFromChoicesSameValueClosure()
$this->decoratedFactory->expects($this->once())
->method('createListFromChoices')
->with($choices, $closure)
- ->will($this->returnValue($list));
+ ->willReturn($list);
$this->assertSame($list, $this->factory->createListFromChoices($choices, $closure));
$this->assertSame($list, $this->factory->createListFromChoices($choices, $closure));
@@ -151,11 +151,11 @@ public function testCreateFromChoicesDifferentValueClosure()
$this->decoratedFactory->expects($this->at(0))
->method('createListFromChoices')
->with($choices, $closure1)
- ->will($this->returnValue($list1));
+ ->willReturn($list1);
$this->decoratedFactory->expects($this->at(1))
->method('createListFromChoices')
->with($choices, $closure2)
- ->will($this->returnValue($list2));
+ ->willReturn($list2);
$this->assertSame($list1, $this->factory->createListFromChoices($choices, $closure1));
$this->assertSame($list2, $this->factory->createListFromChoices($choices, $closure2));
@@ -169,7 +169,7 @@ public function testCreateFromLoaderSameLoader()
$this->decoratedFactory->expects($this->once())
->method('createListFromLoader')
->with($loader)
- ->will($this->returnValue($list));
+ ->willReturn($list);
$this->assertSame($list, $this->factory->createListFromLoader($loader));
$this->assertSame($list, $this->factory->createListFromLoader($loader));
@@ -185,11 +185,11 @@ public function testCreateFromLoaderDifferentLoader()
$this->decoratedFactory->expects($this->at(0))
->method('createListFromLoader')
->with($loader1)
- ->will($this->returnValue($list1));
+ ->willReturn($list1);
$this->decoratedFactory->expects($this->at(1))
->method('createListFromLoader')
->with($loader2)
- ->will($this->returnValue($list2));
+ ->willReturn($list2);
$this->assertSame($list1, $this->factory->createListFromLoader($loader1));
$this->assertSame($list2, $this->factory->createListFromLoader($loader2));
@@ -204,7 +204,7 @@ public function testCreateFromLoaderSameValueClosure()
$this->decoratedFactory->expects($this->once())
->method('createListFromLoader')
->with($loader, $closure)
- ->will($this->returnValue($list));
+ ->willReturn($list);
$this->assertSame($list, $this->factory->createListFromLoader($loader, $closure));
$this->assertSame($list, $this->factory->createListFromLoader($loader, $closure));
@@ -221,11 +221,11 @@ public function testCreateFromLoaderDifferentValueClosure()
$this->decoratedFactory->expects($this->at(0))
->method('createListFromLoader')
->with($loader, $closure1)
- ->will($this->returnValue($list1));
+ ->willReturn($list1);
$this->decoratedFactory->expects($this->at(1))
->method('createListFromLoader')
->with($loader, $closure2)
- ->will($this->returnValue($list2));
+ ->willReturn($list2);
$this->assertSame($list1, $this->factory->createListFromLoader($loader, $closure1));
$this->assertSame($list2, $this->factory->createListFromLoader($loader, $closure2));
@@ -240,7 +240,7 @@ public function testCreateViewSamePreferredChoices()
$this->decoratedFactory->expects($this->once())
->method('createView')
->with($list, $preferred)
- ->will($this->returnValue($view));
+ ->willReturn($view);
$this->assertSame($view, $this->factory->createView($list, $preferred));
$this->assertSame($view, $this->factory->createView($list, $preferred));
@@ -257,11 +257,11 @@ public function testCreateViewDifferentPreferredChoices()
$this->decoratedFactory->expects($this->at(0))
->method('createView')
->with($list, $preferred1)
- ->will($this->returnValue($view1));
+ ->willReturn($view1);
$this->decoratedFactory->expects($this->at(1))
->method('createView')
->with($list, $preferred2)
- ->will($this->returnValue($view2));
+ ->willReturn($view2);
$this->assertSame($view1, $this->factory->createView($list, $preferred1));
$this->assertSame($view2, $this->factory->createView($list, $preferred2));
@@ -276,7 +276,7 @@ public function testCreateViewSamePreferredChoicesClosure()
$this->decoratedFactory->expects($this->once())
->method('createView')
->with($list, $preferred)
- ->will($this->returnValue($view));
+ ->willReturn($view);
$this->assertSame($view, $this->factory->createView($list, $preferred));
$this->assertSame($view, $this->factory->createView($list, $preferred));
@@ -293,11 +293,11 @@ public function testCreateViewDifferentPreferredChoicesClosure()
$this->decoratedFactory->expects($this->at(0))
->method('createView')
->with($list, $preferred1)
- ->will($this->returnValue($view1));
+ ->willReturn($view1);
$this->decoratedFactory->expects($this->at(1))
->method('createView')
->with($list, $preferred2)
- ->will($this->returnValue($view2));
+ ->willReturn($view2);
$this->assertSame($view1, $this->factory->createView($list, $preferred1));
$this->assertSame($view2, $this->factory->createView($list, $preferred2));
@@ -312,7 +312,7 @@ public function testCreateViewSameLabelClosure()
$this->decoratedFactory->expects($this->once())
->method('createView')
->with($list, null, $labels)
- ->will($this->returnValue($view));
+ ->willReturn($view);
$this->assertSame($view, $this->factory->createView($list, null, $labels));
$this->assertSame($view, $this->factory->createView($list, null, $labels));
@@ -329,11 +329,11 @@ public function testCreateViewDifferentLabelClosure()
$this->decoratedFactory->expects($this->at(0))
->method('createView')
->with($list, null, $labels1)
- ->will($this->returnValue($view1));
+ ->willReturn($view1);
$this->decoratedFactory->expects($this->at(1))
->method('createView')
->with($list, null, $labels2)
- ->will($this->returnValue($view2));
+ ->willReturn($view2);
$this->assertSame($view1, $this->factory->createView($list, null, $labels1));
$this->assertSame($view2, $this->factory->createView($list, null, $labels2));
@@ -348,7 +348,7 @@ public function testCreateViewSameIndexClosure()
$this->decoratedFactory->expects($this->once())
->method('createView')
->with($list, null, null, $index)
- ->will($this->returnValue($view));
+ ->willReturn($view);
$this->assertSame($view, $this->factory->createView($list, null, null, $index));
$this->assertSame($view, $this->factory->createView($list, null, null, $index));
@@ -365,11 +365,11 @@ public function testCreateViewDifferentIndexClosure()
$this->decoratedFactory->expects($this->at(0))
->method('createView')
->with($list, null, null, $index1)
- ->will($this->returnValue($view1));
+ ->willReturn($view1);
$this->decoratedFactory->expects($this->at(1))
->method('createView')
->with($list, null, null, $index2)
- ->will($this->returnValue($view2));
+ ->willReturn($view2);
$this->assertSame($view1, $this->factory->createView($list, null, null, $index1));
$this->assertSame($view2, $this->factory->createView($list, null, null, $index2));
@@ -384,7 +384,7 @@ public function testCreateViewSameGroupByClosure()
$this->decoratedFactory->expects($this->once())
->method('createView')
->with($list, null, null, null, $groupBy)
- ->will($this->returnValue($view));
+ ->willReturn($view);
$this->assertSame($view, $this->factory->createView($list, null, null, null, $groupBy));
$this->assertSame($view, $this->factory->createView($list, null, null, null, $groupBy));
@@ -401,11 +401,11 @@ public function testCreateViewDifferentGroupByClosure()
$this->decoratedFactory->expects($this->at(0))
->method('createView')
->with($list, null, null, null, $groupBy1)
- ->will($this->returnValue($view1));
+ ->willReturn($view1);
$this->decoratedFactory->expects($this->at(1))
->method('createView')
->with($list, null, null, null, $groupBy2)
- ->will($this->returnValue($view2));
+ ->willReturn($view2);
$this->assertSame($view1, $this->factory->createView($list, null, null, null, $groupBy1));
$this->assertSame($view2, $this->factory->createView($list, null, null, null, $groupBy2));
@@ -420,7 +420,7 @@ public function testCreateViewSameAttributes()
$this->decoratedFactory->expects($this->once())
->method('createView')
->with($list, null, null, null, null, $attr)
- ->will($this->returnValue($view));
+ ->willReturn($view);
$this->assertSame($view, $this->factory->createView($list, null, null, null, null, $attr));
$this->assertSame($view, $this->factory->createView($list, null, null, null, null, $attr));
@@ -437,11 +437,11 @@ public function testCreateViewDifferentAttributes()
$this->decoratedFactory->expects($this->at(0))
->method('createView')
->with($list, null, null, null, null, $attr1)
- ->will($this->returnValue($view1));
+ ->willReturn($view1);
$this->decoratedFactory->expects($this->at(1))
->method('createView')
->with($list, null, null, null, null, $attr2)
- ->will($this->returnValue($view2));
+ ->willReturn($view2);
$this->assertSame($view1, $this->factory->createView($list, null, null, null, null, $attr1));
$this->assertSame($view2, $this->factory->createView($list, null, null, null, null, $attr2));
@@ -456,7 +456,7 @@ public function testCreateViewSameAttributesClosure()
$this->decoratedFactory->expects($this->once())
->method('createView')
->with($list, null, null, null, null, $attr)
- ->will($this->returnValue($view));
+ ->willReturn($view);
$this->assertSame($view, $this->factory->createView($list, null, null, null, null, $attr));
$this->assertSame($view, $this->factory->createView($list, null, null, null, null, $attr));
@@ -473,11 +473,11 @@ public function testCreateViewDifferentAttributesClosure()
$this->decoratedFactory->expects($this->at(0))
->method('createView')
->with($list, null, null, null, null, $attr1)
- ->will($this->returnValue($view1));
+ ->willReturn($view1);
$this->decoratedFactory->expects($this->at(1))
->method('createView')
->with($list, null, null, null, null, $attr2)
- ->will($this->returnValue($view2));
+ ->willReturn($view2);
$this->assertSame($view1, $this->factory->createView($list, null, null, null, null, $attr1));
$this->assertSame($view2, $this->factory->createView($list, null, null, null, null, $attr2));
diff --git a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/PropertyAccessDecoratorTest.php b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/PropertyAccessDecoratorTest.php
index e4ef0e601a66a..7094ae696ac43 100644
--- a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/PropertyAccessDecoratorTest.php
+++ b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/PropertyAccessDecoratorTest.php
@@ -43,9 +43,9 @@ public function testCreateFromChoicesPropertyPath()
$this->decoratedFactory->expects($this->once())
->method('createListFromChoices')
->with($choices, $this->isInstanceOf('\Closure'))
- ->will($this->returnCallback(function ($choices, $callback) {
+ ->willReturnCallback(function ($choices, $callback) {
return array_map($callback, $choices);
- }));
+ });
$this->assertSame(['value'], $this->factory->createListFromChoices($choices, 'property'));
}
@@ -57,9 +57,9 @@ public function testCreateFromChoicesPropertyPathInstance()
$this->decoratedFactory->expects($this->once())
->method('createListFromChoices')
->with($choices, $this->isInstanceOf('\Closure'))
- ->will($this->returnCallback(function ($choices, $callback) {
+ ->willReturnCallback(function ($choices, $callback) {
return array_map($callback, $choices);
- }));
+ });
$this->assertSame(['value'], $this->factory->createListFromChoices($choices, new PropertyPath('property')));
}
@@ -71,9 +71,9 @@ public function testCreateFromLoaderPropertyPath()
$this->decoratedFactory->expects($this->once())
->method('createListFromLoader')
->with($loader, $this->isInstanceOf('\Closure'))
- ->will($this->returnCallback(function ($loader, $callback) {
+ ->willReturnCallback(function ($loader, $callback) {
return $callback((object) ['property' => 'value']);
- }));
+ });
$this->assertSame('value', $this->factory->createListFromLoader($loader, 'property'));
}
@@ -86,9 +86,9 @@ public function testCreateFromChoicesAssumeNullIfValuePropertyPathUnreadable()
$this->decoratedFactory->expects($this->once())
->method('createListFromChoices')
->with($choices, $this->isInstanceOf('\Closure'))
- ->will($this->returnCallback(function ($choices, $callback) {
+ ->willReturnCallback(function ($choices, $callback) {
return array_map($callback, $choices);
- }));
+ });
$this->assertSame([null], $this->factory->createListFromChoices($choices, 'property'));
}
@@ -101,9 +101,9 @@ public function testCreateFromChoiceLoaderAssumeNullIfValuePropertyPathUnreadabl
$this->decoratedFactory->expects($this->once())
->method('createListFromLoader')
->with($loader, $this->isInstanceOf('\Closure'))
- ->will($this->returnCallback(function ($loader, $callback) {
+ ->willReturnCallback(function ($loader, $callback) {
return $callback(null);
- }));
+ });
$this->assertNull($this->factory->createListFromLoader($loader, 'property'));
}
@@ -115,9 +115,9 @@ public function testCreateFromLoaderPropertyPathInstance()
$this->decoratedFactory->expects($this->once())
->method('createListFromLoader')
->with($loader, $this->isInstanceOf('\Closure'))
- ->will($this->returnCallback(function ($loader, $callback) {
+ ->willReturnCallback(function ($loader, $callback) {
return $callback((object) ['property' => 'value']);
- }));
+ });
$this->assertSame('value', $this->factory->createListFromLoader($loader, new PropertyPath('property')));
}
@@ -129,9 +129,9 @@ public function testCreateViewPreferredChoicesAsPropertyPath()
$this->decoratedFactory->expects($this->once())
->method('createView')
->with($list, $this->isInstanceOf('\Closure'))
- ->will($this->returnCallback(function ($list, $preferred) {
+ ->willReturnCallback(function ($list, $preferred) {
return $preferred((object) ['property' => true]);
- }));
+ });
$this->assertTrue($this->factory->createView(
$list,
@@ -146,9 +146,9 @@ public function testCreateViewPreferredChoicesAsPropertyPathInstance()
$this->decoratedFactory->expects($this->once())
->method('createView')
->with($list, $this->isInstanceOf('\Closure'))
- ->will($this->returnCallback(function ($list, $preferred) {
+ ->willReturnCallback(function ($list, $preferred) {
return $preferred((object) ['property' => true]);
- }));
+ });
$this->assertTrue($this->factory->createView(
$list,
@@ -164,9 +164,9 @@ public function testCreateViewAssumeNullIfPreferredChoicesPropertyPathUnreadable
$this->decoratedFactory->expects($this->once())
->method('createView')
->with($list, $this->isInstanceOf('\Closure'))
- ->will($this->returnCallback(function ($list, $preferred) {
+ ->willReturnCallback(function ($list, $preferred) {
return $preferred((object) ['category' => null]);
- }));
+ });
$this->assertFalse($this->factory->createView(
$list,
@@ -181,9 +181,9 @@ public function testCreateViewLabelsAsPropertyPath()
$this->decoratedFactory->expects($this->once())
->method('createView')
->with($list, null, $this->isInstanceOf('\Closure'))
- ->will($this->returnCallback(function ($list, $preferred, $label) {
+ ->willReturnCallback(function ($list, $preferred, $label) {
return $label((object) ['property' => 'label']);
- }));
+ });
$this->assertSame('label', $this->factory->createView(
$list,
@@ -199,9 +199,9 @@ public function testCreateViewLabelsAsPropertyPathInstance()
$this->decoratedFactory->expects($this->once())
->method('createView')
->with($list, null, $this->isInstanceOf('\Closure'))
- ->will($this->returnCallback(function ($list, $preferred, $label) {
+ ->willReturnCallback(function ($list, $preferred, $label) {
return $label((object) ['property' => 'label']);
- }));
+ });
$this->assertSame('label', $this->factory->createView(
$list,
@@ -217,9 +217,9 @@ public function testCreateViewIndicesAsPropertyPath()
$this->decoratedFactory->expects($this->once())
->method('createView')
->with($list, null, null, $this->isInstanceOf('\Closure'))
- ->will($this->returnCallback(function ($list, $preferred, $label, $index) {
+ ->willReturnCallback(function ($list, $preferred, $label, $index) {
return $index((object) ['property' => 'index']);
- }));
+ });
$this->assertSame('index', $this->factory->createView(
$list,
@@ -236,9 +236,9 @@ public function testCreateViewIndicesAsPropertyPathInstance()
$this->decoratedFactory->expects($this->once())
->method('createView')
->with($list, null, null, $this->isInstanceOf('\Closure'))
- ->will($this->returnCallback(function ($list, $preferred, $label, $index) {
+ ->willReturnCallback(function ($list, $preferred, $label, $index) {
return $index((object) ['property' => 'index']);
- }));
+ });
$this->assertSame('index', $this->factory->createView(
$list,
@@ -255,9 +255,9 @@ public function testCreateViewGroupsAsPropertyPath()
$this->decoratedFactory->expects($this->once())
->method('createView')
->with($list, null, null, null, $this->isInstanceOf('\Closure'))
- ->will($this->returnCallback(function ($list, $preferred, $label, $index, $groupBy) {
+ ->willReturnCallback(function ($list, $preferred, $label, $index, $groupBy) {
return $groupBy((object) ['property' => 'group']);
- }));
+ });
$this->assertSame('group', $this->factory->createView(
$list,
@@ -275,9 +275,9 @@ public function testCreateViewGroupsAsPropertyPathInstance()
$this->decoratedFactory->expects($this->once())
->method('createView')
->with($list, null, null, null, $this->isInstanceOf('\Closure'))
- ->will($this->returnCallback(function ($list, $preferred, $label, $index, $groupBy) {
+ ->willReturnCallback(function ($list, $preferred, $label, $index, $groupBy) {
return $groupBy((object) ['property' => 'group']);
- }));
+ });
$this->assertSame('group', $this->factory->createView(
$list,
@@ -296,9 +296,9 @@ public function testCreateViewAssumeNullIfGroupsPropertyPathUnreadable()
$this->decoratedFactory->expects($this->once())
->method('createView')
->with($list, null, null, null, $this->isInstanceOf('\Closure'))
- ->will($this->returnCallback(function ($list, $preferred, $label, $index, $groupBy) {
+ ->willReturnCallback(function ($list, $preferred, $label, $index, $groupBy) {
return $groupBy((object) ['group' => null]);
- }));
+ });
$this->assertNull($this->factory->createView(
$list,
@@ -316,9 +316,9 @@ public function testCreateViewAttrAsPropertyPath()
$this->decoratedFactory->expects($this->once())
->method('createView')
->with($list, null, null, null, null, $this->isInstanceOf('\Closure'))
- ->will($this->returnCallback(function ($list, $preferred, $label, $index, $groupBy, $attr) {
+ ->willReturnCallback(function ($list, $preferred, $label, $index, $groupBy, $attr) {
return $attr((object) ['property' => 'attr']);
- }));
+ });
$this->assertSame('attr', $this->factory->createView(
$list,
@@ -337,9 +337,9 @@ public function testCreateViewAttrAsPropertyPathInstance()
$this->decoratedFactory->expects($this->once())
->method('createView')
->with($list, null, null, null, null, $this->isInstanceOf('\Closure'))
- ->will($this->returnCallback(function ($list, $preferred, $label, $index, $groupBy, $attr) {
+ ->willReturnCallback(function ($list, $preferred, $label, $index, $groupBy, $attr) {
return $attr((object) ['property' => 'attr']);
- }));
+ });
$this->assertSame('attr', $this->factory->createView(
$list,
diff --git a/src/Symfony/Component/Form/Tests/ChoiceList/LazyChoiceListTest.php b/src/Symfony/Component/Form/Tests/ChoiceList/LazyChoiceListTest.php
index d61d1131c5dca..350955f614c2d 100644
--- a/src/Symfony/Component/Form/Tests/ChoiceList/LazyChoiceListTest.php
+++ b/src/Symfony/Component/Form/Tests/ChoiceList/LazyChoiceListTest.php
@@ -49,12 +49,12 @@ public function testGetChoiceLoadersLoadsLoadedListOnFirstCall()
$this->loader->expects($this->exactly(2))
->method('loadChoiceList')
->with($this->value)
- ->will($this->returnValue($this->loadedList));
+ ->willReturn($this->loadedList);
// The same list is returned by the loader
$this->loadedList->expects($this->exactly(2))
->method('getChoices')
- ->will($this->returnValue('RESULT'));
+ ->willReturn('RESULT');
$this->assertSame('RESULT', $this->list->getChoices());
$this->assertSame('RESULT', $this->list->getChoices());
@@ -65,12 +65,12 @@ public function testGetValuesLoadsLoadedListOnFirstCall()
$this->loader->expects($this->exactly(2))
->method('loadChoiceList')
->with($this->value)
- ->will($this->returnValue($this->loadedList));
+ ->willReturn($this->loadedList);
// The same list is returned by the loader
$this->loadedList->expects($this->exactly(2))
->method('getValues')
- ->will($this->returnValue('RESULT'));
+ ->willReturn('RESULT');
$this->assertSame('RESULT', $this->list->getValues());
$this->assertSame('RESULT', $this->list->getValues());
@@ -81,12 +81,12 @@ public function testGetStructuredValuesLoadsLoadedListOnFirstCall()
$this->loader->expects($this->exactly(2))
->method('loadChoiceList')
->with($this->value)
- ->will($this->returnValue($this->loadedList));
+ ->willReturn($this->loadedList);
// The same list is returned by the loader
$this->loadedList->expects($this->exactly(2))
->method('getStructuredValues')
- ->will($this->returnValue('RESULT'));
+ ->willReturn('RESULT');
$this->assertSame('RESULT', $this->list->getStructuredValues());
$this->assertSame('RESULT', $this->list->getStructuredValues());
@@ -97,12 +97,12 @@ public function testGetOriginalKeysLoadsLoadedListOnFirstCall()
$this->loader->expects($this->exactly(2))
->method('loadChoiceList')
->with($this->value)
- ->will($this->returnValue($this->loadedList));
+ ->willReturn($this->loadedList);
// The same list is returned by the loader
$this->loadedList->expects($this->exactly(2))
->method('getOriginalKeys')
- ->will($this->returnValue('RESULT'));
+ ->willReturn('RESULT');
$this->assertSame('RESULT', $this->list->getOriginalKeys());
$this->assertSame('RESULT', $this->list->getOriginalKeys());
@@ -113,7 +113,7 @@ public function testGetChoicesForValuesForwardsCallIfListNotLoaded()
$this->loader->expects($this->exactly(2))
->method('loadChoicesForValues')
->with(['a', 'b'])
- ->will($this->returnValue('RESULT'));
+ ->willReturn('RESULT');
$this->assertSame('RESULT', $this->list->getChoicesForValues(['a', 'b']));
$this->assertSame('RESULT', $this->list->getChoicesForValues(['a', 'b']));
@@ -124,12 +124,12 @@ public function testGetChoicesForValuesUsesLoadedList()
$this->loader->expects($this->exactly(1))
->method('loadChoiceList')
->with($this->value)
- ->will($this->returnValue($this->loadedList));
+ ->willReturn($this->loadedList);
$this->loader->expects($this->exactly(2))
->method('loadChoicesForValues')
->with(['a', 'b'])
- ->will($this->returnValue('RESULT'));
+ ->willReturn('RESULT');
// load choice list
$this->list->getChoices();
@@ -143,12 +143,12 @@ public function testGetValuesForChoicesUsesLoadedList()
$this->loader->expects($this->exactly(1))
->method('loadChoiceList')
->with($this->value)
- ->will($this->returnValue($this->loadedList));
+ ->willReturn($this->loadedList);
$this->loader->expects($this->exactly(2))
->method('loadValuesForChoices')
->with(['a', 'b'])
- ->will($this->returnValue('RESULT'));
+ ->willReturn('RESULT');
// load choice list
$this->list->getChoices();
diff --git a/src/Symfony/Component/Form/Tests/CompoundFormTest.php b/src/Symfony/Component/Form/Tests/CompoundFormTest.php
index 642b25ee12c23..2fb535ae7ef1e 100644
--- a/src/Symfony/Component/Form/Tests/CompoundFormTest.php
+++ b/src/Symfony/Component/Form/Tests/CompoundFormTest.php
@@ -179,7 +179,7 @@ public function testAddUsingNameAndType()
'bar' => 'baz',
'auto_initialize' => false,
])
- ->will($this->returnValue($child));
+ ->willReturn($child);
$this->form->add('foo', 'Symfony\Component\Form\Extension\Core\Type\TextType', ['bar' => 'baz']);
@@ -198,7 +198,7 @@ public function testAddUsingIntegerNameAndType()
'bar' => 'baz',
'auto_initialize' => false,
])
- ->will($this->returnValue($child));
+ ->willReturn($child);
// in order to make casting unnecessary
$this->form->add(0, 'Symfony\Component\Form\Extension\Core\Type\TextType', ['bar' => 'baz']);
@@ -215,7 +215,7 @@ public function testAddWithoutType()
$this->factory->expects($this->once())
->method('createNamed')
->with('foo', 'Symfony\Component\Form\Extension\Core\Type\TextType')
- ->will($this->returnValue($child));
+ ->willReturn($child);
$this->form->add('foo');
@@ -236,7 +236,7 @@ public function testAddUsingNameButNoType()
$this->factory->expects($this->once())
->method('createForProperty')
->with('\stdClass', 'foo')
- ->will($this->returnValue($child));
+ ->willReturn($child);
$this->form->add('foo');
@@ -260,7 +260,7 @@ public function testAddUsingNameButNoTypeAndOptions()
'bar' => 'baz',
'auto_initialize' => false,
])
- ->will($this->returnValue($child));
+ ->willReturn($child);
$this->form->add('foo', null, ['bar' => 'baz']);
@@ -352,10 +352,10 @@ public function testAddMapsViewDataToFormIfInitialized()
$mapper->expects($this->once())
->method('mapDataToForms')
->with('bar', $this->isInstanceOf('\RecursiveIteratorIterator'))
- ->will($this->returnCallback(function ($data, \RecursiveIteratorIterator $iterator) use ($child) {
+ ->willReturnCallback(function ($data, \RecursiveIteratorIterator $iterator) use ($child) {
$this->assertInstanceOf('Symfony\Component\Form\Util\InheritDataAwareIterator', $iterator->getInnerIterator());
$this->assertSame([$child->getName() => $child], iterator_to_array($iterator));
- }));
+ });
$form->initialize();
$form->add($child);
@@ -442,10 +442,10 @@ public function testSetDataMapsViewDataToChildren()
$mapper->expects($this->once())
->method('mapDataToForms')
->with('bar', $this->isInstanceOf('\RecursiveIteratorIterator'))
- ->will($this->returnCallback(function ($data, \RecursiveIteratorIterator $iterator) use ($child1, $child2) {
+ ->willReturnCallback(function ($data, \RecursiveIteratorIterator $iterator) use ($child1, $child2) {
$this->assertInstanceOf('Symfony\Component\Form\Util\InheritDataAwareIterator', $iterator->getInnerIterator());
$this->assertSame(['firstName' => $child1, 'lastName' => $child2], iterator_to_array($iterator));
- }));
+ });
$form->setData('foo');
}
@@ -517,12 +517,12 @@ public function testSubmitMapsSubmittedChildrenOntoExistingViewData()
$mapper->expects($this->once())
->method('mapFormsToData')
->with($this->isInstanceOf('\RecursiveIteratorIterator'), 'bar')
- ->will($this->returnCallback(function (\RecursiveIteratorIterator $iterator) use ($child1, $child2) {
+ ->willReturnCallback(function (\RecursiveIteratorIterator $iterator) use ($child1, $child2) {
$this->assertInstanceOf('Symfony\Component\Form\Util\InheritDataAwareIterator', $iterator->getInnerIterator());
$this->assertSame(['firstName' => $child1, 'lastName' => $child2], iterator_to_array($iterator));
$this->assertEquals('Bernhard', $child1->getData());
$this->assertEquals('Schussek', $child2->getData());
- }));
+ });
$form->submit([
'firstName' => 'Bernhard',
@@ -589,10 +589,10 @@ public function testSubmitMapsSubmittedChildrenOntoEmptyData()
$mapper->expects($this->once())
->method('mapFormsToData')
->with($this->isInstanceOf('\RecursiveIteratorIterator'), $object)
- ->will($this->returnCallback(function (\RecursiveIteratorIterator $iterator) use ($child) {
+ ->willReturnCallback(function (\RecursiveIteratorIterator $iterator) use ($child) {
$this->assertInstanceOf('Symfony\Component\Form\Util\InheritDataAwareIterator', $iterator->getInnerIterator());
$this->assertSame(['name' => $child], iterator_to_array($iterator));
- }));
+ });
$form->submit([
'name' => 'Bernhard',
@@ -957,11 +957,11 @@ public function testCreateViewWithChildren()
$field1View = new FormView();
$type1
->method('createView')
- ->will($this->returnValue($field1View));
+ ->willReturn($field1View);
$field2View = new FormView();
$type2
->method('createView')
- ->will($this->returnValue($field2View));
+ ->willReturn($field2View);
$this->form = $this->getBuilder('form', null, null, $options)
->setCompound(true)
@@ -980,13 +980,13 @@ public function testCreateViewWithChildren()
// First create the view
$type->expects($this->once())
->method('createView')
- ->will($this->returnValue($view));
+ ->willReturn($view);
// Then build it for the form itself
$type->expects($this->once())
->method('buildView')
->with($view, $this->form, $options)
- ->will($this->returnCallback($assertChildViewsEqual([])));
+ ->willReturnCallback($assertChildViewsEqual([]));
$this->assertSame($view, $this->form->createView());
$this->assertSame(['foo' => $field1View, 'bar' => $field2View], $view->children);
@@ -1006,7 +1006,7 @@ public function testNoClickedButton()
$button->expects($this->any())
->method('isClicked')
- ->will($this->returnValue(false));
+ ->willReturn(false);
$parentForm = $this->getBuilder('parent')->getForm();
$nestedForm = $this->getBuilder('nested')->getForm();
@@ -1028,7 +1028,7 @@ public function testClickedButton()
$button->expects($this->any())
->method('isClicked')
- ->will($this->returnValue(true));
+ ->willReturn(true);
$this->form->add($button);
$this->form->submit([]);
@@ -1047,7 +1047,7 @@ public function testClickedButtonFromNestedForm()
$nestedForm->expects($this->any())
->method('getClickedButton')
- ->will($this->returnValue($button));
+ ->willReturn($button);
$this->form->add($nestedForm);
$this->form->submit([]);
@@ -1066,7 +1066,7 @@ public function testClickedButtonFromParentForm()
$parentForm->expects($this->any())
->method('getClickedButton')
- ->will($this->returnValue($button));
+ ->willReturn($button);
$this->form->setParent($parentForm);
$this->form->submit([]);
diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DataTransformerChainTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DataTransformerChainTest.php
index f62d3c52110f1..2c685a4197a95 100644
--- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DataTransformerChainTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DataTransformerChainTest.php
@@ -22,12 +22,12 @@ public function testTransform()
$transformer1->expects($this->once())
->method('transform')
->with($this->identicalTo('foo'))
- ->will($this->returnValue('bar'));
+ ->willReturn('bar');
$transformer2 = $this->getMockBuilder('Symfony\Component\Form\DataTransformerInterface')->getMock();
$transformer2->expects($this->once())
->method('transform')
->with($this->identicalTo('bar'))
- ->will($this->returnValue('baz'));
+ ->willReturn('baz');
$chain = new DataTransformerChain([$transformer1, $transformer2]);
@@ -40,12 +40,12 @@ public function testReverseTransform()
$transformer2->expects($this->once())
->method('reverseTransform')
->with($this->identicalTo('foo'))
- ->will($this->returnValue('bar'));
+ ->willReturn('bar');
$transformer1 = $this->getMockBuilder('Symfony\Component\Form\DataTransformerInterface')->getMock();
$transformer1->expects($this->once())
->method('reverseTransform')
->with($this->identicalTo('bar'))
- ->will($this->returnValue('baz'));
+ ->willReturn('baz');
$chain = new DataTransformerChain([$transformer1, $transformer2]);
diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php
index 4a7f006f6f2ec..bb7cc0ca7f757 100644
--- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php
@@ -725,10 +725,7 @@ public function testSubmitMultipleChoiceExpandedWithEmptyDataAndInitialData()
$this->assertSame(['test'], $form->getData());
}
- /**
- * @group legacy
- */
- public function testLegacyNullChoices()
+ public function testNullChoices()
{
$form = $this->factory->create(static::TESTED_TYPE, null, [
'multiple' => false,
diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/FileTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/FileTypeTest.php
index 311529c294799..0731942c8960a 100644
--- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/FileTypeTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/FileTypeTest.php
@@ -17,7 +17,7 @@
use Symfony\Component\Form\RequestHandlerInterface;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\HttpFoundation\File\UploadedFile;
-use Symfony\Component\Translation\TranslatorInterface;
+use Symfony\Contracts\Translation\TranslatorInterface;
class FileTypeTest extends BaseTypeTest
{
diff --git a/src/Symfony/Component/Form/Tests/Extension/Csrf/Type/FormTypeCsrfExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/Csrf/Type/FormTypeCsrfExtensionTest.php
index 5478db9b831e1..bde6c2808dfbd 100644
--- a/src/Symfony/Component/Form/Tests/Extension/Csrf/Type/FormTypeCsrfExtensionTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/Csrf/Type/FormTypeCsrfExtensionTest.php
@@ -124,7 +124,7 @@ public function testGenerateCsrfToken()
$this->tokenManager->expects($this->once())
->method('getToken')
->with('TOKEN_ID')
- ->will($this->returnValue(new CsrfToken('TOKEN_ID', 'token')));
+ ->willReturn(new CsrfToken('TOKEN_ID', 'token'));
$view = $this->factory
->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, [
@@ -143,7 +143,7 @@ public function testGenerateCsrfTokenUsesFormNameAsIntentionByDefault()
$this->tokenManager->expects($this->once())
->method('getToken')
->with('FORM_NAME')
- ->will($this->returnValue('token'));
+ ->willReturn('token');
$view = $this->factory
->createNamed('FORM_NAME', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, [
@@ -161,7 +161,7 @@ public function testGenerateCsrfTokenUsesTypeClassAsIntentionIfEmptyFormName()
$this->tokenManager->expects($this->once())
->method('getToken')
->with('Symfony\Component\Form\Extension\Core\Type\FormType')
- ->will($this->returnValue('token'));
+ ->willReturn('token');
$view = $this->factory
->createNamed('', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, [
@@ -190,7 +190,7 @@ public function testValidateTokenOnSubmitIfRootAndCompound($valid)
$this->tokenManager->expects($this->once())
->method('isTokenValid')
->with(new CsrfToken('TOKEN_ID', 'token'))
- ->will($this->returnValue($valid));
+ ->willReturn($valid);
$form = $this->factory
->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', null, [
@@ -222,7 +222,7 @@ public function testValidateTokenOnSubmitIfRootAndCompoundUsesFormNameAsIntentio
$this->tokenManager->expects($this->once())
->method('isTokenValid')
->with(new CsrfToken('FORM_NAME', 'token'))
- ->will($this->returnValue($valid));
+ ->willReturn($valid);
$form = $this->factory
->createNamedBuilder('FORM_NAME', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, [
@@ -253,7 +253,7 @@ public function testValidateTokenOnSubmitIfRootAndCompoundUsesTypeClassAsIntenti
$this->tokenManager->expects($this->once())
->method('isTokenValid')
->with(new CsrfToken('Symfony\Component\Form\Extension\Core\Type\FormType', 'token'))
- ->will($this->returnValue($valid));
+ ->willReturn($valid);
$form = $this->factory
->createNamedBuilder('', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, [
@@ -369,12 +369,12 @@ public function testsTranslateCustomErrorMessage()
$this->tokenManager->expects($this->once())
->method('isTokenValid')
->with($csrfToken)
- ->will($this->returnValue(false));
+ ->willReturn(false);
$this->translator->expects($this->once())
->method('trans')
->with('Foobar')
- ->will($this->returnValue('[trans]Foobar[/trans]'));
+ ->willReturn('[trans]Foobar[/trans]');
$form = $this->factory
->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', null, [
diff --git a/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataCollectorTest.php b/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataCollectorTest.php
index 2ca0f95f3c6e3..83d44167d5cf4 100644
--- a/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataCollectorTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataCollectorTest.php
@@ -84,29 +84,29 @@ public function testBuildPreliminaryFormTree()
$this->dataExtractor->expects($this->at(0))
->method('extractConfiguration')
->with($this->form)
- ->will($this->returnValue(['config' => 'foo']));
+ ->willReturn(['config' => 'foo']);
$this->dataExtractor->expects($this->at(1))
->method('extractConfiguration')
->with($this->childForm)
- ->will($this->returnValue(['config' => 'bar']));
+ ->willReturn(['config' => 'bar']);
$this->dataExtractor->expects($this->at(2))
->method('extractDefaultData')
->with($this->form)
- ->will($this->returnValue(['default_data' => 'foo']));
+ ->willReturn(['default_data' => 'foo']);
$this->dataExtractor->expects($this->at(3))
->method('extractDefaultData')
->with($this->childForm)
- ->will($this->returnValue(['default_data' => 'bar']));
+ ->willReturn(['default_data' => 'bar']);
$this->dataExtractor->expects($this->at(4))
->method('extractSubmittedData')
->with($this->form)
- ->will($this->returnValue(['submitted_data' => 'foo']));
+ ->willReturn(['submitted_data' => 'foo']);
$this->dataExtractor->expects($this->at(5))
->method('extractSubmittedData')
->with($this->childForm)
- ->will($this->returnValue(['submitted_data' => 'bar']));
+ ->willReturn(['submitted_data' => 'bar']);
$this->dataCollector->collectConfiguration($this->form);
$this->dataCollector->collectDefaultData($this->form);
@@ -150,11 +150,11 @@ public function testBuildMultiplePreliminaryFormTrees()
$this->dataExtractor->expects($this->at(0))
->method('extractConfiguration')
->with($form1)
- ->will($this->returnValue(['config' => 'foo']));
+ ->willReturn(['config' => 'foo']);
$this->dataExtractor->expects($this->at(1))
->method('extractConfiguration')
->with($form2)
- ->will($this->returnValue(['config' => 'bar']));
+ ->willReturn(['config' => 'bar']);
$this->dataCollector->collectConfiguration($form1);
$this->dataCollector->collectConfiguration($form2);
@@ -200,12 +200,12 @@ public function testBuildSamePreliminaryFormTreeMultipleTimes()
$this->dataExtractor->expects($this->at(0))
->method('extractConfiguration')
->with($this->form)
- ->will($this->returnValue(['config' => 'foo']));
+ ->willReturn(['config' => 'foo']);
$this->dataExtractor->expects($this->at(1))
->method('extractDefaultData')
->with($this->form)
- ->will($this->returnValue(['default_data' => 'foo']));
+ ->willReturn(['default_data' => 'foo']);
$this->dataCollector->collectConfiguration($this->form);
$this->dataCollector->buildPreliminaryFormTree($this->form);
@@ -272,39 +272,39 @@ public function testBuildFinalFormTree()
$this->dataExtractor->expects($this->at(0))
->method('extractConfiguration')
->with($this->form)
- ->will($this->returnValue(['config' => 'foo']));
+ ->willReturn(['config' => 'foo']);
$this->dataExtractor->expects($this->at(1))
->method('extractConfiguration')
->with($this->childForm)
- ->will($this->returnValue(['config' => 'bar']));
+ ->willReturn(['config' => 'bar']);
$this->dataExtractor->expects($this->at(2))
->method('extractDefaultData')
->with($this->form)
- ->will($this->returnValue(['default_data' => 'foo']));
+ ->willReturn(['default_data' => 'foo']);
$this->dataExtractor->expects($this->at(3))
->method('extractDefaultData')
->with($this->childForm)
- ->will($this->returnValue(['default_data' => 'bar']));
+ ->willReturn(['default_data' => 'bar']);
$this->dataExtractor->expects($this->at(4))
->method('extractSubmittedData')
->with($this->form)
- ->will($this->returnValue(['submitted_data' => 'foo']));
+ ->willReturn(['submitted_data' => 'foo']);
$this->dataExtractor->expects($this->at(5))
->method('extractSubmittedData')
->with($this->childForm)
- ->will($this->returnValue(['submitted_data' => 'bar']));
+ ->willReturn(['submitted_data' => 'bar']);
$this->dataExtractor->expects($this->at(6))
->method('extractViewVariables')
->with($this->view)
- ->will($this->returnValue(['view_vars' => 'foo']));
+ ->willReturn(['view_vars' => 'foo']);
$this->dataExtractor->expects($this->at(7))
->method('extractViewVariables')
->with($this->childView)
- ->will($this->returnValue(['view_vars' => 'bar']));
+ ->willReturn(['view_vars' => 'bar']);
$this->dataCollector->collectConfiguration($this->form);
$this->dataCollector->collectDefaultData($this->form);
@@ -365,76 +365,76 @@ public function testSerializeWithFormAddedMultipleTimes()
$this->dataExtractor->expects($this->at(0))
->method('extractConfiguration')
->with($form1)
- ->will($this->returnValue(['config' => 'foo']));
+ ->willReturn(['config' => 'foo']);
$this->dataExtractor->expects($this->at(1))
->method('extractConfiguration')
->with($child1)
- ->will($this->returnValue(['config' => 'bar']));
+ ->willReturn(['config' => 'bar']);
$this->dataExtractor->expects($this->at(2))
->method('extractDefaultData')
->with($form1)
- ->will($this->returnValue(['default_data' => 'foo']));
+ ->willReturn(['default_data' => 'foo']);
$this->dataExtractor->expects($this->at(3))
->method('extractDefaultData')
->with($child1)
- ->will($this->returnValue(['default_data' => 'bar']));
+ ->willReturn(['default_data' => 'bar']);
$this->dataExtractor->expects($this->at(4))
->method('extractSubmittedData')
->with($form1)
- ->will($this->returnValue(['submitted_data' => 'foo']));
+ ->willReturn(['submitted_data' => 'foo']);
$this->dataExtractor->expects($this->at(5))
->method('extractSubmittedData')
->with($child1)
- ->will($this->returnValue(['submitted_data' => 'bar']));
+ ->willReturn(['submitted_data' => 'bar']);
$this->dataExtractor->expects($this->at(6))
->method('extractViewVariables')
->with($form1View)
- ->will($this->returnValue(['view_vars' => 'foo']));
+ ->willReturn(['view_vars' => 'foo']);
$this->dataExtractor->expects($this->at(7))
->method('extractViewVariables')
->with($child1View)
- ->will($this->returnValue(['view_vars' => $child1View->vars]));
+ ->willReturn(['view_vars' => $child1View->vars]);
$this->dataExtractor->expects($this->at(8))
->method('extractConfiguration')
->with($form2)
- ->will($this->returnValue(['config' => 'foo']));
+ ->willReturn(['config' => 'foo']);
$this->dataExtractor->expects($this->at(9))
->method('extractConfiguration')
->with($child1)
- ->will($this->returnValue(['config' => 'bar']));
+ ->willReturn(['config' => 'bar']);
$this->dataExtractor->expects($this->at(10))
->method('extractDefaultData')
->with($form2)
- ->will($this->returnValue(['default_data' => 'foo']));
+ ->willReturn(['default_data' => 'foo']);
$this->dataExtractor->expects($this->at(11))
->method('extractDefaultData')
->with($child1)
- ->will($this->returnValue(['default_data' => 'bar']));
+ ->willReturn(['default_data' => 'bar']);
$this->dataExtractor->expects($this->at(12))
->method('extractSubmittedData')
->with($form2)
- ->will($this->returnValue(['submitted_data' => 'foo']));
+ ->willReturn(['submitted_data' => 'foo']);
$this->dataExtractor->expects($this->at(13))
->method('extractSubmittedData')
->with($child1)
- ->will($this->returnValue(['submitted_data' => 'bar']));
+ ->willReturn(['submitted_data' => 'bar']);
$this->dataExtractor->expects($this->at(14))
->method('extractViewVariables')
->with($form2View)
- ->will($this->returnValue(['view_vars' => 'foo']));
+ ->willReturn(['view_vars' => 'foo']);
$this->dataExtractor->expects($this->at(15))
->method('extractViewVariables')
->with($child1View)
- ->will($this->returnValue(['view_vars' => $child1View->vars]));
+ ->willReturn(['view_vars' => $child1View->vars]);
$this->dataCollector->collectConfiguration($form1);
$this->dataCollector->collectDefaultData($form1);
@@ -518,11 +518,11 @@ public function testChildViewsCanBeWithoutCorrespondingChildForms()
$this->dataExtractor->expects($this->at(0))
->method('extractConfiguration')
->with($this->form)
- ->will($this->returnValue(['config' => 'foo']));
+ ->willReturn(['config' => 'foo']);
$this->dataExtractor->expects($this->at(1))
->method('extractConfiguration')
->with($this->childForm)
- ->will($this->returnValue(['config' => 'bar']));
+ ->willReturn(['config' => 'bar']);
// explicitly call collectConfiguration(), since $this->childForm is not
// contained in the form tree
@@ -566,11 +566,11 @@ public function testChildViewsWithoutCorrespondingChildFormsMayBeExplicitlyAssoc
$this->dataExtractor->expects($this->at(0))
->method('extractConfiguration')
->with($this->form)
- ->will($this->returnValue(['config' => 'foo']));
+ ->willReturn(['config' => 'foo']);
$this->dataExtractor->expects($this->at(1))
->method('extractConfiguration')
->with($this->childForm)
- ->will($this->returnValue(['config' => 'bar']));
+ ->willReturn(['config' => 'bar']);
// explicitly call collectConfiguration(), since $this->childForm is not
// contained in the form tree
@@ -611,22 +611,22 @@ public function testCollectSubmittedDataCountsErrors()
$form1->add($childForm1);
$this->dataExtractor
->method('extractConfiguration')
- ->will($this->returnValue([]));
+ ->willReturn([]);
$this->dataExtractor
->method('extractDefaultData')
- ->will($this->returnValue([]));
+ ->willReturn([]);
$this->dataExtractor->expects($this->at(4))
->method('extractSubmittedData')
->with($form1)
- ->will($this->returnValue(['errors' => ['foo']]));
+ ->willReturn(['errors' => ['foo']]);
$this->dataExtractor->expects($this->at(5))
->method('extractSubmittedData')
->with($childForm1)
- ->will($this->returnValue(['errors' => ['bar', 'bam']]));
+ ->willReturn(['errors' => ['bar', 'bam']]);
$this->dataExtractor->expects($this->at(8))
->method('extractSubmittedData')
->with($form2)
- ->will($this->returnValue(['errors' => ['baz']]));
+ ->willReturn(['errors' => ['baz']]);
$this->dataCollector->collectSubmittedData($form1);
@@ -653,30 +653,30 @@ public function testCollectSubmittedDataExpandedFormsErrors()
$this->dataExtractor
->method('extractConfiguration')
- ->will($this->returnValue([]));
+ ->willReturn([]);
$this->dataExtractor
->method('extractDefaultData')
- ->will($this->returnValue([]));
+ ->willReturn([]);
$this->dataExtractor->expects($this->at(10))
->method('extractSubmittedData')
->with($this->form)
- ->will($this->returnValue(['errors' => []]));
+ ->willReturn(['errors' => []]);
$this->dataExtractor->expects($this->at(11))
->method('extractSubmittedData')
->with($child1Form)
- ->will($this->returnValue(['errors' => []]));
+ ->willReturn(['errors' => []]);
$this->dataExtractor->expects($this->at(12))
->method('extractSubmittedData')
->with($child11Form)
- ->will($this->returnValue(['errors' => ['foo']]));
+ ->willReturn(['errors' => ['foo']]);
$this->dataExtractor->expects($this->at(13))
->method('extractSubmittedData')
->with($child2Form)
- ->will($this->returnValue(['errors' => []]));
+ ->willReturn(['errors' => []]);
$this->dataExtractor->expects($this->at(14))
->method('extractSubmittedData')
->with($child21Form)
- ->will($this->returnValue(['errors' => []]));
+ ->willReturn(['errors' => []]);
$this->dataCollector->collectSubmittedData($this->form);
$this->dataCollector->buildPreliminaryFormTree($this->form);
@@ -701,14 +701,14 @@ public function testReset()
$this->dataExtractor->expects($this->any())
->method('extractConfiguration')
- ->will($this->returnValue([]));
+ ->willReturn([]);
$this->dataExtractor->expects($this->any())
->method('extractDefaultData')
- ->will($this->returnValue([]));
+ ->willReturn([]);
$this->dataExtractor->expects($this->any())
->method('extractSubmittedData')
->with($form)
- ->will($this->returnValue(['errors' => ['baz']]));
+ ->willReturn(['errors' => ['baz']]);
$this->dataCollector->buildPreliminaryFormTree($form);
$this->dataCollector->collectSubmittedData($form);
diff --git a/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataExtractorTest.php b/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataExtractorTest.php
index 8e66a9801e105..fb83d23640078 100644
--- a/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataExtractorTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataExtractorTest.php
@@ -56,7 +56,7 @@ public function testExtractConfiguration()
$type = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock();
$type->expects($this->any())
->method('getInnerType')
- ->will($this->returnValue(new \stdClass()));
+ ->willReturn(new \stdClass());
$form = $this->createBuilder('name')
->setType($type)
@@ -77,7 +77,7 @@ public function testExtractConfigurationSortsPassedOptions()
$type = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock();
$type->expects($this->any())
->method('getInnerType')
- ->will($this->returnValue(new \stdClass()));
+ ->willReturn(new \stdClass());
$options = [
'b' => 'foo',
@@ -111,7 +111,7 @@ public function testExtractConfigurationSortsResolvedOptions()
$type = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock();
$type->expects($this->any())
->method('getInnerType')
- ->will($this->returnValue(new \stdClass()));
+ ->willReturn(new \stdClass());
$options = [
'b' => 'foo',
@@ -142,7 +142,7 @@ public function testExtractConfigurationBuildsIdRecursively()
$type = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock();
$type->expects($this->any())
->method('getInnerType')
- ->will($this->returnValue(new \stdClass()));
+ ->willReturn(new \stdClass());
$grandParent = $this->createBuilder('grandParent')
->setCompound(true)
diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php
index f23cc204f81a3..ac10d4c2b1e1e 100644
--- a/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php
@@ -24,6 +24,7 @@
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\SubmitButtonBuilder;
use Symfony\Component\Translation\IdentityTranslator;
+use Symfony\Component\Validator\Constraints\Collection;
use Symfony\Component\Validator\Constraints\GroupSequence;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Constraints\NotNull;
@@ -673,6 +674,63 @@ public function testCauseForNotAllowedExtraFieldsIsTheFormConstraint()
$this->assertSame($constraint, $context->getViolations()->get(0)->getConstraint());
}
+ public function testNonCompositeConstraintValidatedOnce()
+ {
+ $form = $this
+ ->getBuilder('form', null, [
+ 'constraints' => [new NotBlank(['groups' => ['foo', 'bar']])],
+ 'validation_groups' => ['foo', 'bar'],
+ ])
+ ->setCompound(false)
+ ->getForm();
+ $form->submit('');
+
+ $context = new ExecutionContext(Validation::createValidator(), $form, new IdentityTranslator());
+ $this->validator->initialize($context);
+ $this->validator->validate($form, new Form());
+
+ $this->assertCount(1, $context->getViolations());
+ $this->assertSame('This value should not be blank.', $context->getViolations()[0]->getMessage());
+ $this->assertSame('data', $context->getViolations()[0]->getPropertyPath());
+ }
+
+ public function testCompositeConstraintValidatedInEachGroup()
+ {
+ $form = $this->getBuilder('form', null, [
+ 'constraints' => [
+ new Collection([
+ 'field1' => new NotBlank([
+ 'groups' => ['field1'],
+ ]),
+ 'field2' => new NotBlank([
+ 'groups' => ['field2'],
+ ]),
+ ]),
+ ],
+ 'validation_groups' => ['field1', 'field2'],
+ ])
+ ->setData([])
+ ->setCompound(true)
+ ->setDataMapper(new PropertyPathMapper())
+ ->getForm();
+ $form->add($this->getForm('field1'));
+ $form->add($this->getForm('field2'));
+ $form->submit([
+ 'field1' => '',
+ 'field2' => '',
+ ]);
+
+ $context = new ExecutionContext(Validation::createValidator(), $form, new IdentityTranslator());
+ $this->validator->initialize($context);
+ $this->validator->validate($form, new Form());
+
+ $this->assertCount(2, $context->getViolations());
+ $this->assertSame('This value should not be blank.', $context->getViolations()[0]->getMessage());
+ $this->assertSame('data[field1]', $context->getViolations()[0]->getPropertyPath());
+ $this->assertSame('This value should not be blank.', $context->getViolations()[1]->getMessage());
+ $this->assertSame('data[field2]', $context->getViolations()[1]->getPropertyPath());
+ }
+
protected function createValidator()
{
return new FormValidator();
diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/FormTypeValidatorExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/FormTypeValidatorExtensionTest.php
index 53d29a19112c7..57f92b6574e3b 100644
--- a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/FormTypeValidatorExtensionTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/FormTypeValidatorExtensionTest.php
@@ -42,7 +42,7 @@ public function testSubmitValidatesData()
$this->validator->expects($this->once())
->method('validate')
->with($this->equalTo($form))
- ->will($this->returnValue(new ConstraintViolationList()));
+ ->willReturn(new ConstraintViolationList());
// specific data is irrelevant
$form->submit([]);
diff --git a/src/Symfony/Component/Form/Tests/FormBuilderTest.php b/src/Symfony/Component/Form/Tests/FormBuilderTest.php
index c087cbbcf4365..5d47438d06a5f 100644
--- a/src/Symfony/Component/Form/Tests/FormBuilderTest.php
+++ b/src/Symfony/Component/Form/Tests/FormBuilderTest.php
@@ -93,7 +93,7 @@ public function testAll()
$this->factory->expects($this->once())
->method('createNamedBuilder')
->with('foo', 'Symfony\Component\Form\Extension\Core\Type\TextType')
- ->will($this->returnValue(new FormBuilder('foo', null, $this->dispatcher, $this->factory)));
+ ->willReturn(new FormBuilder('foo', null, $this->dispatcher, $this->factory));
$this->assertCount(0, $this->builder->all());
$this->assertFalse($this->builder->has('foo'));
@@ -188,7 +188,7 @@ public function testGetExplicitType()
$this->factory->expects($this->once())
->method('createNamedBuilder')
->with($expectedName, $expectedType, null, $expectedOptions)
- ->will($this->returnValue($this->getFormBuilder()));
+ ->willReturn($this->getFormBuilder());
$this->builder->add($expectedName, $expectedType, $expectedOptions);
$builder = $this->builder->get($expectedName);
@@ -204,7 +204,7 @@ public function testGetGuessedType()
$this->factory->expects($this->once())
->method('createBuilderForProperty')
->with('stdClass', $expectedName, null, $expectedOptions)
- ->will($this->returnValue($this->getFormBuilder()));
+ ->willReturn($this->getFormBuilder());
$this->builder = new FormBuilder('name', 'stdClass', $this->dispatcher, $this->factory);
$this->builder->add($expectedName, null, $expectedOptions);
@@ -246,7 +246,7 @@ private function getFormBuilder($name = 'name')
$mock->expects($this->any())
->method('getName')
- ->will($this->returnValue($name));
+ ->willReturn($name);
return $mock;
}
diff --git a/src/Symfony/Component/Form/Tests/FormFactoryTest.php b/src/Symfony/Component/Form/Tests/FormFactoryTest.php
index 27a5ca6e20f7c..4426310676538 100644
--- a/src/Symfony/Component/Form/Tests/FormFactoryTest.php
+++ b/src/Symfony/Component/Form/Tests/FormFactoryTest.php
@@ -58,10 +58,10 @@ protected function setUp()
$this->registry->expects($this->any())
->method('getTypeGuesser')
- ->will($this->returnValue(new FormTypeGuesserChain([
+ ->willReturn(new FormTypeGuesserChain([
$this->guesser1,
$this->guesser2,
- ])));
+ ]));
}
public function testCreateNamedBuilderWithTypeName()
@@ -73,16 +73,16 @@ public function testCreateNamedBuilderWithTypeName()
$this->registry->expects($this->once())
->method('getType')
->with('type')
- ->will($this->returnValue($resolvedType));
+ ->willReturn($resolvedType);
$resolvedType->expects($this->once())
->method('createBuilder')
->with($this->factory, 'name', $options)
- ->will($this->returnValue($this->builder));
+ ->willReturn($this->builder);
$this->builder->expects($this->any())
->method('getOptions')
- ->will($this->returnValue($resolvedOptions));
+ ->willReturn($resolvedOptions);
$resolvedType->expects($this->once())
->method('buildForm')
@@ -101,16 +101,16 @@ public function testCreateNamedBuilderFillsDataOption()
$this->registry->expects($this->once())
->method('getType')
->with('type')
- ->will($this->returnValue($resolvedType));
+ ->willReturn($resolvedType);
$resolvedType->expects($this->once())
->method('createBuilder')
->with($this->factory, 'name', $expectedOptions)
- ->will($this->returnValue($this->builder));
+ ->willReturn($this->builder);
$this->builder->expects($this->any())
->method('getOptions')
- ->will($this->returnValue($resolvedOptions));
+ ->willReturn($resolvedOptions);
$resolvedType->expects($this->once())
->method('buildForm')
@@ -128,16 +128,16 @@ public function testCreateNamedBuilderDoesNotOverrideExistingDataOption()
$this->registry->expects($this->once())
->method('getType')
->with('type')
- ->will($this->returnValue($resolvedType));
+ ->willReturn($resolvedType);
$resolvedType->expects($this->once())
->method('createBuilder')
->with($this->factory, 'name', $options)
- ->will($this->returnValue($this->builder));
+ ->willReturn($this->builder);
$this->builder->expects($this->any())
->method('getOptions')
- ->will($this->returnValue($resolvedOptions));
+ ->willReturn($resolvedOptions);
$resolvedType->expects($this->once())
->method('buildForm')
@@ -181,16 +181,16 @@ public function testCreateUsesBlockPrefixIfTypeGivenAsString()
$this->registry->expects($this->any())
->method('getType')
->with('TYPE')
- ->will($this->returnValue($resolvedType));
+ ->willReturn($resolvedType);
$resolvedType->expects($this->once())
->method('createBuilder')
->with($this->factory, 'TYPE_PREFIX', $options)
- ->will($this->returnValue($this->builder));
+ ->willReturn($this->builder);
$this->builder->expects($this->any())
->method('getOptions')
- ->will($this->returnValue($resolvedOptions));
+ ->willReturn($resolvedOptions);
$resolvedType->expects($this->once())
->method('buildForm')
@@ -198,7 +198,7 @@ public function testCreateUsesBlockPrefixIfTypeGivenAsString()
$this->builder->expects($this->once())
->method('getForm')
- ->will($this->returnValue('FORM'));
+ ->willReturn('FORM');
$this->assertSame('FORM', $this->factory->create('TYPE', null, $options));
}
@@ -212,16 +212,16 @@ public function testCreateNamed()
$this->registry->expects($this->once())
->method('getType')
->with('type')
- ->will($this->returnValue($resolvedType));
+ ->willReturn($resolvedType);
$resolvedType->expects($this->once())
->method('createBuilder')
->with($this->factory, 'name', $options)
- ->will($this->returnValue($this->builder));
+ ->willReturn($this->builder);
$this->builder->expects($this->any())
->method('getOptions')
- ->will($this->returnValue($resolvedOptions));
+ ->willReturn($resolvedOptions);
$resolvedType->expects($this->once())
->method('buildForm')
@@ -229,7 +229,7 @@ public function testCreateNamed()
$this->builder->expects($this->once())
->method('getForm')
- ->will($this->returnValue('FORM'));
+ ->willReturn('FORM');
$this->assertSame('FORM', $this->factory->createNamed('name', 'type', null, $options));
}
@@ -245,7 +245,7 @@ public function testCreateBuilderForPropertyWithoutTypeGuesser()
$factory->expects($this->once())
->method('createNamedBuilder')
->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [])
- ->will($this->returnValue('builderInstance'));
+ ->willReturn('builderInstance');
$this->builder = $factory->createBuilderForProperty('Application\Author', 'firstName');
@@ -257,27 +257,27 @@ public function testCreateBuilderForPropertyCreatesFormWithHighestConfidence()
$this->guesser1->expects($this->once())
->method('guessType')
->with('Application\Author', 'firstName')
- ->will($this->returnValue(new TypeGuess(
+ ->willReturn(new TypeGuess(
'Symfony\Component\Form\Extension\Core\Type\TextType',
['attr' => ['maxlength' => 10]],
Guess::MEDIUM_CONFIDENCE
- )));
+ ));
$this->guesser2->expects($this->once())
->method('guessType')
->with('Application\Author', 'firstName')
- ->will($this->returnValue(new TypeGuess(
+ ->willReturn(new TypeGuess(
'Symfony\Component\Form\Extension\Core\Type\PasswordType',
['attr' => ['maxlength' => 7]],
Guess::HIGH_CONFIDENCE
- )));
+ ));
$factory = $this->getMockFactory(['createNamedBuilder']);
$factory->expects($this->once())
->method('createNamedBuilder')
->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\PasswordType', null, ['attr' => ['maxlength' => 7]])
- ->will($this->returnValue('builderInstance'));
+ ->willReturn('builderInstance');
$this->builder = $factory->createBuilderForProperty('Application\Author', 'firstName');
@@ -289,14 +289,14 @@ public function testCreateBuilderCreatesTextFormIfNoGuess()
$this->guesser1->expects($this->once())
->method('guessType')
->with('Application\Author', 'firstName')
- ->will($this->returnValue(null));
+ ->willReturn(null);
$factory = $this->getMockFactory(['createNamedBuilder']);
$factory->expects($this->once())
->method('createNamedBuilder')
->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType')
- ->will($this->returnValue('builderInstance'));
+ ->willReturn('builderInstance');
$this->builder = $factory->createBuilderForProperty('Application\Author', 'firstName');
@@ -308,18 +308,18 @@ public function testOptionsCanBeOverridden()
$this->guesser1->expects($this->once())
->method('guessType')
->with('Application\Author', 'firstName')
- ->will($this->returnValue(new TypeGuess(
+ ->willReturn(new TypeGuess(
'Symfony\Component\Form\Extension\Core\Type\TextType',
['attr' => ['class' => 'foo', 'maxlength' => 10]],
Guess::MEDIUM_CONFIDENCE
- )));
+ ));
$factory = $this->getMockFactory(['createNamedBuilder']);
$factory->expects($this->once())
->method('createNamedBuilder')
->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, ['attr' => ['class' => 'foo', 'maxlength' => 11]])
- ->will($this->returnValue('builderInstance'));
+ ->willReturn('builderInstance');
$this->builder = $factory->createBuilderForProperty(
'Application\Author',
@@ -336,25 +336,25 @@ public function testCreateBuilderUsesMaxLengthIfFound()
$this->guesser1->expects($this->once())
->method('guessMaxLength')
->with('Application\Author', 'firstName')
- ->will($this->returnValue(new ValueGuess(
+ ->willReturn(new ValueGuess(
15,
Guess::MEDIUM_CONFIDENCE
- )));
+ ));
$this->guesser2->expects($this->once())
->method('guessMaxLength')
->with('Application\Author', 'firstName')
- ->will($this->returnValue(new ValueGuess(
+ ->willReturn(new ValueGuess(
20,
Guess::HIGH_CONFIDENCE
- )));
+ ));
$factory = $this->getMockFactory(['createNamedBuilder']);
$factory->expects($this->once())
->method('createNamedBuilder')
->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, ['attr' => ['maxlength' => 20]])
- ->will($this->returnValue('builderInstance'));
+ ->willReturn('builderInstance');
$this->builder = $factory->createBuilderForProperty(
'Application\Author',
@@ -369,25 +369,25 @@ public function testCreateBuilderUsesMaxLengthAndPattern()
$this->guesser1->expects($this->once())
->method('guessMaxLength')
->with('Application\Author', 'firstName')
- ->will($this->returnValue(new ValueGuess(
+ ->willReturn(new ValueGuess(
20,
Guess::HIGH_CONFIDENCE
- )));
+ ));
$this->guesser2->expects($this->once())
->method('guessPattern')
->with('Application\Author', 'firstName')
- ->will($this->returnValue(new ValueGuess(
+ ->willReturn(new ValueGuess(
'.{5,}',
Guess::HIGH_CONFIDENCE
- )));
+ ));
$factory = $this->getMockFactory(['createNamedBuilder']);
$factory->expects($this->once())
->method('createNamedBuilder')
->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, ['attr' => ['maxlength' => 20, 'pattern' => '.{5,}', 'class' => 'tinymce']])
- ->will($this->returnValue('builderInstance'));
+ ->willReturn('builderInstance');
$this->builder = $factory->createBuilderForProperty(
'Application\Author',
@@ -404,25 +404,25 @@ public function testCreateBuilderUsesRequiredSettingWithHighestConfidence()
$this->guesser1->expects($this->once())
->method('guessRequired')
->with('Application\Author', 'firstName')
- ->will($this->returnValue(new ValueGuess(
+ ->willReturn(new ValueGuess(
true,
Guess::MEDIUM_CONFIDENCE
- )));
+ ));
$this->guesser2->expects($this->once())
->method('guessRequired')
->with('Application\Author', 'firstName')
- ->will($this->returnValue(new ValueGuess(
+ ->willReturn(new ValueGuess(
false,
Guess::HIGH_CONFIDENCE
- )));
+ ));
$factory = $this->getMockFactory(['createNamedBuilder']);
$factory->expects($this->once())
->method('createNamedBuilder')
->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, ['required' => false])
- ->will($this->returnValue('builderInstance'));
+ ->willReturn('builderInstance');
$this->builder = $factory->createBuilderForProperty(
'Application\Author',
@@ -437,25 +437,25 @@ public function testCreateBuilderUsesPatternIfFound()
$this->guesser1->expects($this->once())
->method('guessPattern')
->with('Application\Author', 'firstName')
- ->will($this->returnValue(new ValueGuess(
+ ->willReturn(new ValueGuess(
'[a-z]',
Guess::MEDIUM_CONFIDENCE
- )));
+ ));
$this->guesser2->expects($this->once())
->method('guessPattern')
->with('Application\Author', 'firstName')
- ->will($this->returnValue(new ValueGuess(
+ ->willReturn(new ValueGuess(
'[a-zA-Z]',
Guess::HIGH_CONFIDENCE
- )));
+ ));
$factory = $this->getMockFactory(['createNamedBuilder']);
$factory->expects($this->once())
->method('createNamedBuilder')
->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, ['attr' => ['pattern' => '[a-zA-Z]']])
- ->will($this->returnValue('builderInstance'));
+ ->willReturn('builderInstance');
$this->builder = $factory->createBuilderForProperty(
'Application\Author',
diff --git a/src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php b/src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php
index 32bb8bb788716..ba078ad1fd119 100644
--- a/src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php
+++ b/src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php
@@ -99,21 +99,21 @@ public function testGetOptionsResolver()
// First the default options are generated for the super type
$this->parentType->expects($this->once())
->method('configureOptions')
- ->will($this->returnCallback($assertIndexAndAddOption(0, 'a', 'a_default')));
+ ->willReturnCallback($assertIndexAndAddOption(0, 'a', 'a_default'));
// The form type itself
$this->type->expects($this->once())
->method('configureOptions')
- ->will($this->returnCallback($assertIndexAndAddOption(1, 'b', 'b_default')));
+ ->willReturnCallback($assertIndexAndAddOption(1, 'b', 'b_default'));
// And its extensions
$this->extension1->expects($this->once())
->method('configureOptions')
- ->will($this->returnCallback($assertIndexAndAddOption(2, 'c', 'c_default')));
+ ->willReturnCallback($assertIndexAndAddOption(2, 'c', 'c_default'));
$this->extension2->expects($this->once())
->method('configureOptions')
- ->will($this->returnCallback($assertIndexAndAddOption(3, 'd', 'd_default')));
+ ->willReturnCallback($assertIndexAndAddOption(3, 'd', 'd_default'));
$givenOptions = ['a' => 'a_custom', 'c' => 'c_custom'];
$resolvedOptions = ['a' => 'a_custom', 'b' => 'b_default', 'c' => 'c_custom', 'd' => 'd_default'];
@@ -136,12 +136,12 @@ public function testCreateBuilder()
$this->resolvedType->expects($this->once())
->method('getOptionsResolver')
- ->will($this->returnValue($optionsResolver));
+ ->willReturn($optionsResolver);
$optionsResolver->expects($this->once())
->method('resolve')
->with($givenOptions)
- ->will($this->returnValue($resolvedOptions));
+ ->willReturn($resolvedOptions);
$factory = $this->getMockFormFactory();
$builder = $this->resolvedType->createBuilder($factory, 'name', $givenOptions);
@@ -164,12 +164,12 @@ public function testCreateBuilderWithDataClassOption()
$this->resolvedType->expects($this->once())
->method('getOptionsResolver')
- ->will($this->returnValue($optionsResolver));
+ ->willReturn($optionsResolver);
$optionsResolver->expects($this->once())
->method('resolve')
->with($givenOptions)
- ->will($this->returnValue($resolvedOptions));
+ ->willReturn($resolvedOptions);
$factory = $this->getMockFormFactory();
$builder = $this->resolvedType->createBuilder($factory, 'name', $givenOptions);
@@ -198,24 +198,24 @@ public function testBuildForm()
$this->parentType->expects($this->once())
->method('buildForm')
->with($builder, $options)
- ->will($this->returnCallback($assertIndex(0)));
+ ->willReturnCallback($assertIndex(0));
// Then the type itself
$this->type->expects($this->once())
->method('buildForm')
->with($builder, $options)
- ->will($this->returnCallback($assertIndex(1)));
+ ->willReturnCallback($assertIndex(1));
// Then its extensions
$this->extension1->expects($this->once())
->method('buildForm')
->with($builder, $options)
- ->will($this->returnCallback($assertIndex(2)));
+ ->willReturnCallback($assertIndex(2));
$this->extension2->expects($this->once())
->method('buildForm')
->with($builder, $options)
- ->will($this->returnCallback($assertIndex(3)));
+ ->willReturnCallback($assertIndex(3));
$this->resolvedType->buildForm($builder, $options);
}
@@ -261,24 +261,24 @@ public function testBuildView()
$this->parentType->expects($this->once())
->method('buildView')
->with($view, $form, $options)
- ->will($this->returnCallback($assertIndex(0)));
+ ->willReturnCallback($assertIndex(0));
// Then the type itself
$this->type->expects($this->once())
->method('buildView')
->with($view, $form, $options)
- ->will($this->returnCallback($assertIndex(1)));
+ ->willReturnCallback($assertIndex(1));
// Then its extensions
$this->extension1->expects($this->once())
->method('buildView')
->with($view, $form, $options)
- ->will($this->returnCallback($assertIndex(2)));
+ ->willReturnCallback($assertIndex(2));
$this->extension2->expects($this->once())
->method('buildView')
->with($view, $form, $options)
- ->will($this->returnCallback($assertIndex(3)));
+ ->willReturnCallback($assertIndex(3));
$this->resolvedType->buildView($view, $form, $options);
}
@@ -303,24 +303,24 @@ public function testFinishView()
$this->parentType->expects($this->once())
->method('finishView')
->with($view, $form, $options)
- ->will($this->returnCallback($assertIndex(0)));
+ ->willReturnCallback($assertIndex(0));
// Then the type itself
$this->type->expects($this->once())
->method('finishView')
->with($view, $form, $options)
- ->will($this->returnCallback($assertIndex(1)));
+ ->willReturnCallback($assertIndex(1));
// Then its extensions
$this->extension1->expects($this->once())
->method('finishView')
->with($view, $form, $options)
- ->will($this->returnCallback($assertIndex(2)));
+ ->willReturnCallback($assertIndex(2));
$this->extension2->expects($this->once())
->method('finishView')
->with($view, $form, $options)
- ->will($this->returnCallback($assertIndex(3)));
+ ->willReturnCallback($assertIndex(3));
$this->resolvedType->finishView($view, $form, $options);
}
diff --git a/src/Symfony/Component/Form/Tests/SimpleFormTest.php b/src/Symfony/Component/Form/Tests/SimpleFormTest.php
index 922375c46d208..284738313b180 100644
--- a/src/Symfony/Component/Form/Tests/SimpleFormTest.php
+++ b/src/Symfony/Component/Form/Tests/SimpleFormTest.php
@@ -722,7 +722,7 @@ public function testCreateView()
$type->expects($this->once())
->method('createView')
->with($form)
- ->will($this->returnValue($view));
+ ->willReturn($view);
$this->assertSame($view, $form->createView());
}
@@ -739,12 +739,12 @@ public function testCreateViewWithParent()
$parentType->expects($this->once())
->method('createView')
- ->will($this->returnValue($parentView));
+ ->willReturn($parentView);
$type->expects($this->once())
->method('createView')
->with($form, $parentView)
- ->will($this->returnValue($view));
+ ->willReturn($view);
$this->assertSame($view, $form->createView());
}
@@ -759,7 +759,7 @@ public function testCreateViewWithExplicitParent()
$type->expects($this->once())
->method('createView')
->with($form, $parentView)
- ->will($this->returnValue($view));
+ ->willReturn($view);
$this->assertSame($view, $form->createView($parentView));
}
diff --git a/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php b/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php
index 115f486f023f5..e217820950057 100644
--- a/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php
+++ b/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php
@@ -223,12 +223,17 @@ public function prepare(Request $request)
list($pathPrefix, $location) = $part;
if (substr($path, 0, \strlen($pathPrefix)) === $pathPrefix) {
$path = $location.substr($path, \strlen($pathPrefix));
+ // Only set X-Accel-Redirect header if a valid URI can be produced
+ // as nginx does not serve arbitrary file paths.
+ $this->headers->set($type, $path);
+ $this->maxlen = 0;
break;
}
}
+ } else {
+ $this->headers->set($type, $path);
+ $this->maxlen = 0;
}
- $this->headers->set($type, $path);
- $this->maxlen = 0;
} elseif ($request->headers->has('Range')) {
// Process the range headers.
if (!$request->headers->has('If-Range') || $this->hasValidIfRangeHeader($request->headers->get('If-Range'))) {
diff --git a/src/Symfony/Component/HttpFoundation/JsonResponse.php b/src/Symfony/Component/HttpFoundation/JsonResponse.php
index 817cbb9afc4db..c0a6916f052a2 100644
--- a/src/Symfony/Component/HttpFoundation/JsonResponse.php
+++ b/src/Symfony/Component/HttpFoundation/JsonResponse.php
@@ -18,7 +18,7 @@
* object. It is however recommended that you do return an object as it
* protects yourself against XSSI and JSON-JavaScript Hijacking.
*
- * @see https://www.owasp.org/index.php/OWASP_AJAX_Security_Guidelines#Always_return_JSON_with_an_Object_on_the_outside
+ * @see https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/AJAX_Security_Cheat_Sheet.md#always-return-json-with-an-object-on-the-outside
*
* @author Igor Wiedler
*/
@@ -55,10 +55,10 @@ public function __construct($data = null, int $status = 200, array $headers = []
*
* Example:
*
- * return JsonResponse::create($data, 200)
+ * return JsonResponse::create(['key' => 'value'])
* ->setSharedMaxAge(300);
*
- * @param mixed $data The json response data
+ * @param mixed $data The JSON response data
* @param int $status The response status code
* @param array $headers An array of response headers
*
@@ -70,7 +70,18 @@ public static function create($data = null, $status = 200, $headers = [])
}
/**
- * Make easier the creation of JsonResponse from raw json.
+ * Factory method for chainability.
+ *
+ * Example:
+ *
+ * return JsonResponse::fromJsonString('{"key": "value"}')
+ * ->setSharedMaxAge(300);
+ *
+ * @param string|null $data The JSON response string
+ * @param int $status The response status code
+ * @param array $headers An array of response headers
+ *
+ * @return static
*/
public static function fromJsonString($data = null, $status = 200, $headers = [])
{
@@ -148,6 +159,10 @@ public function setData($data = [])
throw $e;
}
+ if (\PHP_VERSION_ID >= 70300 && (JSON_THROW_ON_ERROR & $this->encodingOptions)) {
+ return $this->setJson($data);
+ }
+
if (JSON_ERROR_NONE !== json_last_error()) {
throw new \InvalidArgumentException(json_last_error_msg());
}
diff --git a/src/Symfony/Component/HttpFoundation/RedirectResponse.php b/src/Symfony/Component/HttpFoundation/RedirectResponse.php
index f685856584598..8d04aa42c9d87 100644
--- a/src/Symfony/Component/HttpFoundation/RedirectResponse.php
+++ b/src/Symfony/Component/HttpFoundation/RedirectResponse.php
@@ -42,7 +42,7 @@ public function __construct(?string $url, int $status = 302, array $headers = []
throw new \InvalidArgumentException(sprintf('The HTTP status code is not a redirect ("%s" given).', $status));
}
- if (301 == $status && !\array_key_exists('cache-control', $headers)) {
+ if (301 == $status && !\array_key_exists('cache-control', array_change_key_case($headers, \CASE_LOWER))) {
$this->headers->remove('cache-control');
}
}
diff --git a/src/Symfony/Component/HttpFoundation/Response.php b/src/Symfony/Component/HttpFoundation/Response.php
index c3ac19d4a91de..d1263ca7a15d0 100644
--- a/src/Symfony/Component/HttpFoundation/Response.php
+++ b/src/Symfony/Component/HttpFoundation/Response.php
@@ -684,7 +684,7 @@ public function getAge(): int
return (int) $age;
}
- return max(time() - $this->getDate()->format('U'), 0);
+ return max(time() - (int) $this->getDate()->format('U'), 0);
}
/**
@@ -764,7 +764,7 @@ public function getMaxAge(): ?int
}
if (null !== $this->getExpires()) {
- return (int) ($this->getExpires()->format('U') - $this->getDate()->format('U'));
+ return (int) $this->getExpires()->format('U') - (int) $this->getDate()->format('U');
}
return null;
diff --git a/src/Symfony/Component/HttpFoundation/Session/Session.php b/src/Symfony/Component/HttpFoundation/Session/Session.php
index 867ceba97f8db..db0b9aeb0b118 100644
--- a/src/Symfony/Component/HttpFoundation/Session/Session.php
+++ b/src/Symfony/Component/HttpFoundation/Session/Session.php
@@ -253,7 +253,9 @@ public function registerBag(SessionBagInterface $bag)
*/
public function getBag($name)
{
- return $this->storage->getBag($name)->getBag();
+ $bag = $this->storage->getBag($name);
+
+ return method_exists($bag, 'getBag') ? $bag->getBag() : $bag;
}
/**
diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php
index 0623318d0a18b..a3877ef4c7855 100644
--- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php
+++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php
@@ -681,7 +681,7 @@ private function doAdvisoryLock(string $sessionId)
switch ($this->driver) {
case 'mysql':
// MySQL 5.7.5 and later enforces a maximum length on lock names of 64 characters. Previously, no limit was enforced.
- $lockId = \substr($sessionId, 0, 64);
+ $lockId = substr($sessionId, 0, 64);
// should we handle the return value? 0 on timeout, null on error
// we use a timeout of 50 seconds which is also the default for innodb_lock_wait_timeout
$stmt = $this->pdo->prepare('SELECT GET_LOCK(:key, 50)');
diff --git a/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php b/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php
index 9f3beb08d1af3..effffe925be85 100644
--- a/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php
+++ b/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php
@@ -339,6 +339,7 @@ public function getSampleXAccelMappings()
['/var/www/var/www/files/foo.txt', '/var/www/=/files/', '/files/var/www/files/foo.txt'],
['/home/Foo/bar.txt', '/var/www/=/files/,/home/Foo/=/baz/', '/baz/bar.txt'],
['/home/Foo/bar.txt', '"/var/www/"="/files/", "/home/Foo/"="/baz/"', '/baz/bar.txt'],
+ ['/tmp/bar.txt', '"/var/www/"="/files/", "/home/Foo/"="/baz/"', null],
];
}
diff --git a/src/Symfony/Component/HttpFoundation/Tests/File/FileTest.php b/src/Symfony/Component/HttpFoundation/Tests/File/FileTest.php
index fb82dae768b4f..caf2029927008 100644
--- a/src/Symfony/Component/HttpFoundation/Tests/File/FileTest.php
+++ b/src/Symfony/Component/HttpFoundation/Tests/File/FileTest.php
@@ -172,7 +172,7 @@ protected function createMockGuesser($path, $mimeType)
->expects($this->once())
->method('guess')
->with($this->equalTo($path))
- ->will($this->returnValue($mimeType))
+ ->willReturn($mimeType)
;
return $guesser;
diff --git a/src/Symfony/Component/HttpFoundation/Tests/JsonResponseTest.php b/src/Symfony/Component/HttpFoundation/Tests/JsonResponseTest.php
index 03a7b7d9b8682..261c9d3e0599b 100644
--- a/src/Symfony/Component/HttpFoundation/Tests/JsonResponseTest.php
+++ b/src/Symfony/Component/HttpFoundation/Tests/JsonResponseTest.php
@@ -43,7 +43,8 @@ public function testConstructorWithSimpleTypes()
$this->assertSame('0', $response->getContent());
$response = new JsonResponse(0.1);
- $this->assertSame('0.1', $response->getContent());
+ $this->assertEquals('0.1', $response->getContent());
+ $this->assertInternalType('string', $response->getContent());
$response = new JsonResponse(true);
$this->assertSame('true', $response->getContent());
@@ -131,7 +132,8 @@ public function testStaticCreateWithSimpleTypes()
$response = JsonResponse::create(0.1);
$this->assertInstanceOf('Symfony\Component\HttpFoundation\JsonResponse', $response);
- $this->assertSame('0.1', $response->getContent());
+ $this->assertEquals('0.1', $response->getContent());
+ $this->assertInternalType('string', $response->getContent());
$response = JsonResponse::create(true);
$this->assertInstanceOf('Symfony\Component\HttpFoundation\JsonResponse', $response);
diff --git a/src/Symfony/Component/HttpFoundation/Tests/RedirectResponseTest.php b/src/Symfony/Component/HttpFoundation/Tests/RedirectResponseTest.php
index 64c3e73ee21af..5f6a8ac0883f4 100644
--- a/src/Symfony/Component/HttpFoundation/Tests/RedirectResponseTest.php
+++ b/src/Symfony/Component/HttpFoundation/Tests/RedirectResponseTest.php
@@ -91,6 +91,10 @@ public function testCacheHeaders()
$this->assertFalse($response->headers->hasCacheControlDirective('no-cache'));
$this->assertTrue($response->headers->hasCacheControlDirective('max-age'));
+ $response = new RedirectResponse('foo.bar', 301, ['Cache-Control' => 'max-age=86400']);
+ $this->assertFalse($response->headers->hasCacheControlDirective('no-cache'));
+ $this->assertTrue($response->headers->hasCacheControlDirective('max-age'));
+
$response = new RedirectResponse('foo.bar', 302);
$this->assertTrue($response->headers->hasCacheControlDirective('no-cache'));
}
diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/SessionTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/SessionTest.php
index afa00fc7c3046..acb129984edd1 100644
--- a/src/Symfony/Component/HttpFoundation/Tests/Session/SessionTest.php
+++ b/src/Symfony/Component/HttpFoundation/Tests/Session/SessionTest.php
@@ -15,6 +15,7 @@
use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag;
use Symfony\Component\HttpFoundation\Session\Flash\FlashBag;
use Symfony\Component\HttpFoundation\Session\Session;
+use Symfony\Component\HttpFoundation\Session\SessionBagProxy;
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
/**
@@ -260,4 +261,28 @@ public function testIsEmpty()
$flash->get('hello');
$this->assertTrue($this->session->isEmpty());
}
+
+ public function testGetBagWithBagImplementingGetBag()
+ {
+ $bag = new AttributeBag();
+ $bag->setName('foo');
+
+ $storage = new MockArraySessionStorage();
+ $storage->registerBag($bag);
+
+ $this->assertSame($bag, (new Session($storage))->getBag('foo'));
+ }
+
+ public function testGetBagWithBagNotImplementingGetBag()
+ {
+ $data = [];
+
+ $bag = new AttributeBag();
+ $bag->setName('foo');
+
+ $storage = new MockArraySessionStorage();
+ $storage->registerBag(new SessionBagProxy($bag, $data, $usageIndex));
+
+ $this->assertSame($bag, (new Session($storage))->getBag('foo'));
+ }
}
diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php
index 5c72a89aa5512..2393ddf182046 100644
--- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php
+++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php
@@ -62,7 +62,7 @@ public function testCloseSession()
$this->memcached
->expects($this->once())
->method('quit')
- ->will($this->returnValue(true))
+ ->willReturn(true)
;
$this->assertTrue($this->storage->close());
@@ -85,7 +85,7 @@ public function testWriteSession()
->expects($this->once())
->method('set')
->with(self::PREFIX.'id', 'data', $this->equalTo(time() + self::TTL, 2))
- ->will($this->returnValue(true))
+ ->willReturn(true)
;
$this->assertTrue($this->storage->write('id', 'data'));
@@ -97,7 +97,7 @@ public function testDestroySession()
->expects($this->once())
->method('delete')
->with(self::PREFIX.'id')
- ->will($this->returnValue(true))
+ ->willReturn(true)
;
$this->assertTrue($this->storage->destroy('id'));
diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MigratingSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MigratingSessionHandlerTest.php
index 1c0f3ca6637a4..6dc5b0cb5c48f 100644
--- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MigratingSessionHandlerTest.php
+++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MigratingSessionHandlerTest.php
@@ -38,11 +38,11 @@ public function testClose()
{
$this->currentHandler->expects($this->once())
->method('close')
- ->will($this->returnValue(true));
+ ->willReturn(true);
$this->writeOnlyHandler->expects($this->once())
->method('close')
- ->will($this->returnValue(false));
+ ->willReturn(false);
$result = $this->dualHandler->close();
@@ -56,12 +56,12 @@ public function testDestroy()
$this->currentHandler->expects($this->once())
->method('destroy')
->with($sessionId)
- ->will($this->returnValue(true));
+ ->willReturn(true);
$this->writeOnlyHandler->expects($this->once())
->method('destroy')
->with($sessionId)
- ->will($this->returnValue(false));
+ ->willReturn(false);
$result = $this->dualHandler->destroy($sessionId);
@@ -75,12 +75,12 @@ public function testGc()
$this->currentHandler->expects($this->once())
->method('gc')
->with($maxlifetime)
- ->will($this->returnValue(true));
+ ->willReturn(true);
$this->writeOnlyHandler->expects($this->once())
->method('gc')
->with($maxlifetime)
- ->will($this->returnValue(false));
+ ->willReturn(false);
$result = $this->dualHandler->gc($maxlifetime);
$this->assertTrue($result);
@@ -94,12 +94,12 @@ public function testOpen()
$this->currentHandler->expects($this->once())
->method('open')
->with($savePath, $sessionName)
- ->will($this->returnValue(true));
+ ->willReturn(true);
$this->writeOnlyHandler->expects($this->once())
->method('open')
->with($savePath, $sessionName)
- ->will($this->returnValue(false));
+ ->willReturn(false);
$result = $this->dualHandler->open($savePath, $sessionName);
@@ -114,7 +114,7 @@ public function testRead()
$this->currentHandler->expects($this->once())
->method('read')
->with($sessionId)
- ->will($this->returnValue($readValue));
+ ->willReturn($readValue);
$this->writeOnlyHandler->expects($this->never())
->method('read')
@@ -133,12 +133,12 @@ public function testWrite()
$this->currentHandler->expects($this->once())
->method('write')
->with($sessionId, $data)
- ->will($this->returnValue(true));
+ ->willReturn(true);
$this->writeOnlyHandler->expects($this->once())
->method('write')
->with($sessionId, $data)
- ->will($this->returnValue(false));
+ ->willReturn(false);
$result = $this->dualHandler->write($sessionId, $data);
@@ -153,7 +153,7 @@ public function testValidateId()
$this->currentHandler->expects($this->once())
->method('read')
->with($sessionId)
- ->will($this->returnValue($readValue));
+ ->willReturn($readValue);
$this->writeOnlyHandler->expects($this->never())
->method('read')
@@ -172,12 +172,12 @@ public function testUpdateTimestamp()
$this->currentHandler->expects($this->once())
->method('write')
->with($sessionId, $data)
- ->will($this->returnValue(true));
+ ->willReturn(true);
$this->writeOnlyHandler->expects($this->once())
->method('write')
->with($sessionId, $data)
- ->will($this->returnValue(false));
+ ->willReturn(false);
$result = $this->dualHandler->updateTimestamp($sessionId, $data);
diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php
index 891516d52368b..5fcdad9b58c65 100644
--- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php
+++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php
@@ -77,7 +77,7 @@ public function testRead()
$this->mongo->expects($this->once())
->method('selectCollection')
->with($this->options['database'], $this->options['collection'])
- ->will($this->returnValue($collection));
+ ->willReturn($collection);
// defining the timeout before the actual method call
// allows to test for "greater than" values in the $criteria
@@ -85,7 +85,7 @@ public function testRead()
$collection->expects($this->once())
->method('findOne')
- ->will($this->returnCallback(function ($criteria) use ($testTimeout) {
+ ->willReturnCallback(function ($criteria) use ($testTimeout) {
$this->assertArrayHasKey($this->options['id_field'], $criteria);
$this->assertEquals($criteria[$this->options['id_field']], 'foo');
@@ -100,7 +100,7 @@ public function testRead()
$this->options['expiry_field'] => new \MongoDB\BSON\UTCDateTime(),
$this->options['data_field'] => new \MongoDB\BSON\Binary('bar', \MongoDB\BSON\Binary::TYPE_OLD_BINARY),
];
- }));
+ });
$this->assertEquals('bar', $this->storage->read('foo'));
}
@@ -112,11 +112,11 @@ public function testWrite()
$this->mongo->expects($this->once())
->method('selectCollection')
->with($this->options['database'], $this->options['collection'])
- ->will($this->returnValue($collection));
+ ->willReturn($collection);
$collection->expects($this->once())
->method('updateOne')
- ->will($this->returnCallback(function ($criteria, $updateData, $options) {
+ ->willReturnCallback(function ($criteria, $updateData, $options) {
$this->assertEquals([$this->options['id_field'] => 'foo'], $criteria);
$this->assertEquals(['upsert' => true], $options);
@@ -127,7 +127,7 @@ public function testWrite()
$this->assertInstanceOf(\MongoDB\BSON\UTCDateTime::class, $data[$this->options['time_field']]);
$this->assertInstanceOf(\MongoDB\BSON\UTCDateTime::class, $data[$this->options['expiry_field']]);
$this->assertGreaterThanOrEqual($expectedExpiry, round((string) $data[$this->options['expiry_field']] / 1000));
- }));
+ });
$this->assertTrue($this->storage->write('foo', 'bar'));
}
@@ -139,15 +139,15 @@ public function testReplaceSessionData()
$this->mongo->expects($this->once())
->method('selectCollection')
->with($this->options['database'], $this->options['collection'])
- ->will($this->returnValue($collection));
+ ->willReturn($collection);
$data = [];
$collection->expects($this->exactly(2))
->method('updateOne')
- ->will($this->returnCallback(function ($criteria, $updateData, $options) use (&$data) {
+ ->willReturnCallback(function ($criteria, $updateData, $options) use (&$data) {
$data = $updateData;
- }));
+ });
$this->storage->write('foo', 'bar');
$this->storage->write('foo', 'foobar');
@@ -162,7 +162,7 @@ public function testDestroy()
$this->mongo->expects($this->once())
->method('selectCollection')
->with($this->options['database'], $this->options['collection'])
- ->will($this->returnValue($collection));
+ ->willReturn($collection);
$collection->expects($this->once())
->method('deleteOne')
@@ -178,14 +178,14 @@ public function testGc()
$this->mongo->expects($this->once())
->method('selectCollection')
->with($this->options['database'], $this->options['collection'])
- ->will($this->returnValue($collection));
+ ->willReturn($collection);
$collection->expects($this->once())
->method('deleteMany')
- ->will($this->returnCallback(function ($criteria) {
+ ->willReturnCallback(function ($criteria) {
$this->assertInstanceOf(\MongoDB\BSON\UTCDateTime::class, $criteria[$this->options['expiry_field']]['$lt']);
$this->assertGreaterThanOrEqual(time() - 1, round((string) $criteria[$this->options['expiry_field']]['$lt'] / 1000));
- }));
+ });
$this->assertTrue($this->storage->gc(1));
}
diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php
index 8aa84cff81326..380b4d7da4ad8 100644
--- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php
+++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php
@@ -143,7 +143,7 @@ public function testReadConvertsStreamToString()
$stream = $this->createStream($content);
$pdo->prepareResult->expects($this->once())->method('fetchAll')
- ->will($this->returnValue([[$stream, 42, time()]]));
+ ->willReturn([[$stream, 42, time()]]);
$storage = new PdoSessionHandler($pdo);
$result = $storage->read('foo');
@@ -170,14 +170,14 @@ public function testReadLockedConvertsStreamToString()
$exception = null;
$selectStmt->expects($this->atLeast(2))->method('fetchAll')
- ->will($this->returnCallback(function () use (&$exception, $stream) {
+ ->willReturnCallback(function () use (&$exception, $stream) {
return $exception ? [[$stream, 42, time()]] : [];
- }));
+ });
$insertStmt->expects($this->once())->method('execute')
- ->will($this->returnCallback(function () use (&$exception) {
+ ->willReturnCallback(function () use (&$exception) {
throw $exception = new \PDOException('', '23');
- }));
+ });
$storage = new PdoSessionHandler($pdo);
$result = $storage->read('foo');
diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php
index 0459a8ce97d50..b6e0da99ddd67 100644
--- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php
+++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php
@@ -50,7 +50,7 @@ public function testOpenTrue()
{
$this->mock->expects($this->once())
->method('open')
- ->will($this->returnValue(true));
+ ->willReturn(true);
$this->assertFalse($this->proxy->isActive());
$this->proxy->open('name', 'id');
@@ -61,7 +61,7 @@ public function testOpenFalse()
{
$this->mock->expects($this->once())
->method('open')
- ->will($this->returnValue(false));
+ ->willReturn(false);
$this->assertFalse($this->proxy->isActive());
$this->proxy->open('name', 'id');
@@ -72,7 +72,7 @@ public function testClose()
{
$this->mock->expects($this->once())
->method('close')
- ->will($this->returnValue(true));
+ ->willReturn(true);
$this->assertFalse($this->proxy->isActive());
$this->proxy->close();
@@ -83,7 +83,7 @@ public function testCloseFalse()
{
$this->mock->expects($this->once())
->method('close')
- ->will($this->returnValue(false));
+ ->willReturn(false);
$this->assertFalse($this->proxy->isActive());
$this->proxy->close();
diff --git a/src/Symfony/Component/HttpKernel/DataCollector/TimeDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/TimeDataCollector.php
index f48db705686b6..7ab14b7cb856a 100644
--- a/src/Symfony/Component/HttpKernel/DataCollector/TimeDataCollector.php
+++ b/src/Symfony/Component/HttpKernel/DataCollector/TimeDataCollector.php
@@ -47,7 +47,7 @@ public function collect(Request $request, Response $response, \Exception $except
'token' => $response->headers->get('X-Debug-Token'),
'start_time' => $startTime * 1000,
'events' => [],
- 'stopwatch_installed' => \class_exists(Stopwatch::class, false),
+ 'stopwatch_installed' => class_exists(Stopwatch::class, false),
];
}
diff --git a/src/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php b/src/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php
index 6659e21793ffc..b28ad7b83e5e4 100644
--- a/src/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php
+++ b/src/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php
@@ -19,7 +19,10 @@
use Symfony\Component\Debug\ExceptionHandler;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
+use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Debug\FileLinkFormatter;
+use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Symfony\Component\HttpKernel\Event\KernelEvent;
use Symfony\Component\HttpKernel\KernelEvents;
@@ -37,6 +40,7 @@ class DebugHandlersListener implements EventSubscriberInterface
private $scream;
private $fileLinkFormat;
private $scope;
+ private $charset;
private $firstCall = true;
private $hasTerminatedWithException;
@@ -49,7 +53,7 @@ class DebugHandlersListener implements EventSubscriberInterface
* @param string|FileLinkFormatter|null $fileLinkFormat The format for links to source files
* @param bool $scope Enables/disables scoping mode
*/
- public function __construct(callable $exceptionHandler = null, LoggerInterface $logger = null, $levels = E_ALL, ?int $throwAt = E_ALL, bool $scream = true, $fileLinkFormat = null, bool $scope = true)
+ public function __construct(callable $exceptionHandler = null, LoggerInterface $logger = null, $levels = E_ALL, ?int $throwAt = E_ALL, bool $scream = true, $fileLinkFormat = null, bool $scope = true, string $charset = null)
{
$this->exceptionHandler = $exceptionHandler;
$this->logger = $logger;
@@ -58,6 +62,7 @@ public function __construct(callable $exceptionHandler = null, LoggerInterface $
$this->scream = $scream;
$this->fileLinkFormat = $fileLinkFormat;
$this->scope = $scope;
+ $this->charset = $charset;
}
/**
@@ -144,6 +149,26 @@ public function configure(Event $event = null)
}
}
+ /**
+ * @internal
+ */
+ public function onKernelException(GetResponseForExceptionEvent $event)
+ {
+ if (!$this->hasTerminatedWithException || !$event->isMasterRequest()) {
+ return;
+ }
+
+ $debug = $this->scream && $this->scope;
+ $controller = function (Request $request) use ($debug) {
+ $e = $request->attributes->get('exception');
+ $handler = new ExceptionHandler($debug, $this->charset, $this->fileLinkFormat);
+
+ return new Response($handler->getHtml($e), $e->getStatusCode(), $e->getHeaders());
+ };
+
+ (new ExceptionListener($controller, $this->logger, $debug))->onKernelException($event);
+ }
+
public static function getSubscribedEvents()
{
$events = [KernelEvents::REQUEST => ['configure', 2048]];
@@ -152,6 +177,8 @@ public static function getSubscribedEvents()
$events[ConsoleEvents::COMMAND] = ['configure', 2048];
}
+ $events[KernelEvents::EXCEPTION] = ['onKernelException', -2048];
+
return $events;
}
}
diff --git a/src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php b/src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php
index 811f99bd9de8f..d2b97e66276fe 100644
--- a/src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php
+++ b/src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php
@@ -13,11 +13,9 @@
use Psr\Log\LoggerInterface;
use Symfony\Component\Debug\Exception\FlattenException;
-use Symfony\Component\Debug\ExceptionHandler;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\Request;
-use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
@@ -35,17 +33,12 @@ class ExceptionListener implements EventSubscriberInterface
protected $controller;
protected $logger;
protected $debug;
- private $charset;
- private $fileLinkFormat;
- private $isTerminating = false;
- public function __construct($controller, LoggerInterface $logger = null, $debug = false, string $charset = null, $fileLinkFormat = null)
+ public function __construct($controller, LoggerInterface $logger = null, $debug = false)
{
$this->controller = $controller;
$this->logger = $logger;
$this->debug = $debug;
- $this->charset = $charset;
- $this->fileLinkFormat = $fileLinkFormat;
}
public function logKernelException(GetResponseForExceptionEvent $event)
@@ -58,16 +51,9 @@ public function logKernelException(GetResponseForExceptionEvent $event)
public function onKernelException(GetResponseForExceptionEvent $event)
{
if (null === $this->controller) {
- if (!$event->isMasterRequest()) {
- return;
- }
- if (!$this->isTerminating) {
- $this->isTerminating = true;
-
- return;
- }
- $this->isTerminating = false;
+ return;
}
+
$exception = $event->getException();
$request = $this->duplicateRequest($exception, $event->getRequest());
$eventDispatcher = \func_num_args() > 2 ? func_get_arg(2) : null;
@@ -104,11 +90,6 @@ public function onKernelException(GetResponseForExceptionEvent $event)
}
}
- public function reset()
- {
- $this->isTerminating = false;
- }
-
public static function getSubscribedEvents()
{
return [
@@ -147,12 +128,8 @@ protected function logException(\Exception $exception, $message)
protected function duplicateRequest(\Exception $exception, Request $request)
{
$attributes = [
- 'exception' => $exception = FlattenException::create($exception),
- '_controller' => $this->controller ?: function () use ($exception) {
- $handler = new ExceptionHandler($this->debug, $this->charset, $this->fileLinkFormat);
-
- return new Response($handler->getHtml($exception), $exception->getStatusCode(), $exception->getHeaders());
- },
+ '_controller' => $this->controller,
+ 'exception' => FlattenException::create($exception),
'logger' => $this->logger instanceof DebugLoggerInterface ? $this->logger : null,
];
$request = $request->duplicate(null, null, $attributes);
diff --git a/src/Symfony/Component/HttpKernel/HttpCache/ResponseCacheStrategy.php b/src/Symfony/Component/HttpKernel/HttpCache/ResponseCacheStrategy.php
index 1efad607e8277..25c071c335a02 100644
--- a/src/Symfony/Component/HttpKernel/HttpCache/ResponseCacheStrategy.php
+++ b/src/Symfony/Component/HttpKernel/HttpCache/ResponseCacheStrategy.php
@@ -85,7 +85,7 @@ public function add(Response $response)
$this->storeRelativeAgeDirective('s-maxage', $response->headers->getCacheControlDirective('s-maxage') ?: $response->headers->getCacheControlDirective('max-age'), $age);
$expires = $response->getExpires();
- $expires = null !== $expires ? $expires->format('U') - $response->getDate()->format('U') : null;
+ $expires = null !== $expires ? (int) $expires->format('U') - (int) $response->getDate()->format('U') : null;
$this->storeRelativeAgeDirective('expires', $expires >= 0 ? $expires : null, 0);
}
@@ -132,12 +132,12 @@ public function update(Response $response)
$maxAge = null;
$sMaxage = null;
- if (\is_numeric($this->ageDirectives['max-age'])) {
+ if (is_numeric($this->ageDirectives['max-age'])) {
$maxAge = $this->ageDirectives['max-age'] + $this->age;
$response->headers->addCacheControlDirective('max-age', $maxAge);
}
- if (\is_numeric($this->ageDirectives['s-maxage'])) {
+ if (is_numeric($this->ageDirectives['s-maxage'])) {
$sMaxage = $this->ageDirectives['s-maxage'] + $this->age;
if ($maxAge !== $sMaxage) {
@@ -145,7 +145,7 @@ public function update(Response $response)
}
}
- if (\is_numeric($this->ageDirectives['expires'])) {
+ if (is_numeric($this->ageDirectives['expires'])) {
$date = clone $response->getDate();
$date->modify('+'.($this->ageDirectives['expires'] + $this->age).' seconds');
$response->setExpires($date);
diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php
index fd063881387d8..2cac878a584e3 100644
--- a/src/Symfony/Component/HttpKernel/Kernel.php
+++ b/src/Symfony/Component/HttpKernel/Kernel.php
@@ -73,11 +73,11 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
private $requestStackSize = 0;
private $resetServices = false;
- const VERSION = '4.2.9';
- const VERSION_ID = 40209;
+ const VERSION = '4.2.10';
+ const VERSION_ID = 40210;
const MAJOR_VERSION = 4;
const MINOR_VERSION = 2;
- const RELEASE_VERSION = 9;
+ const RELEASE_VERSION = 10;
const EXTRA_VERSION = '';
const END_OF_MAINTENANCE = '07/2019';
@@ -487,7 +487,6 @@ protected function initializeContainer()
$fresh = true;
}
} catch (\Throwable $e) {
- } catch (\Exception $e) {
} finally {
error_reporting($errorLevel);
}
@@ -556,7 +555,6 @@ protected function initializeContainer()
try {
$oldContainer = include $cache->getPath();
} catch (\Throwable $e) {
- } catch (\Exception $e) {
} finally {
error_reporting($errorLevel);
}
diff --git a/src/Symfony/Component/HttpKernel/Tests/CacheWarmer/CacheWarmerAggregateTest.php b/src/Symfony/Component/HttpKernel/Tests/CacheWarmer/CacheWarmerAggregateTest.php
index 7753600959595..27e8f9f2aff5c 100644
--- a/src/Symfony/Component/HttpKernel/Tests/CacheWarmer/CacheWarmerAggregateTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/CacheWarmer/CacheWarmerAggregateTest.php
@@ -59,7 +59,7 @@ public function testWarmupDoesNotCallWarmupOnOptionalWarmersWhenEnableOptionalWa
$warmer
->expects($this->once())
->method('isOptional')
- ->will($this->returnValue(true));
+ ->willReturn(true);
$warmer
->expects($this->never())
->method('warmUp');
diff --git a/src/Symfony/Component/HttpKernel/Tests/ClientTest.php b/src/Symfony/Component/HttpKernel/Tests/ClientTest.php
index c260727849444..6ab1002e6682d 100644
--- a/src/Symfony/Component/HttpKernel/Tests/ClientTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/ClientTest.php
@@ -156,11 +156,11 @@ public function testUploadedFileWhenSizeExceedsUploadMaxFileSize()
/* should be modified when the getClientSize will be removed */
$file->expects($this->any())
->method('getSize')
- ->will($this->returnValue(INF))
+ ->willReturn(INF)
;
$file->expects($this->any())
->method('getClientSize')
- ->will($this->returnValue(INF))
+ ->willReturn(INF)
;
$client->request('POST', '/', [], [$file]);
diff --git a/src/Symfony/Component/HttpKernel/Tests/Config/FileLocatorTest.php b/src/Symfony/Component/HttpKernel/Tests/Config/FileLocatorTest.php
index 6265f0275560a..b20b12ab59ed6 100644
--- a/src/Symfony/Component/HttpKernel/Tests/Config/FileLocatorTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/Config/FileLocatorTest.php
@@ -23,7 +23,7 @@ public function testLocate()
->expects($this->atLeastOnce())
->method('locateResource')
->with('@BundleName/some/path', null, true)
- ->will($this->returnValue('/bundle-name/some/path'));
+ ->willReturn('/bundle-name/some/path');
$locator = new FileLocator($kernel);
$this->assertEquals('/bundle-name/some/path', $locator->locate('@BundleName/some/path'));
diff --git a/src/Symfony/Component/HttpKernel/Tests/Controller/ContainerControllerResolverTest.php b/src/Symfony/Component/HttpKernel/Tests/Controller/ContainerControllerResolverTest.php
index 61d8bec32a708..27f35b64c604c 100644
--- a/src/Symfony/Component/HttpKernel/Tests/Controller/ContainerControllerResolverTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/Controller/ContainerControllerResolverTest.php
@@ -27,11 +27,11 @@ public function testGetControllerServiceWithSingleColon()
$container->expects($this->once())
->method('has')
->with('foo')
- ->will($this->returnValue(true));
+ ->willReturn(true);
$container->expects($this->once())
->method('get')
->with('foo')
- ->will($this->returnValue($service))
+ ->willReturn($service)
;
$resolver = $this->createControllerResolver(null, $container);
@@ -52,11 +52,11 @@ public function testGetControllerService()
$container->expects($this->once())
->method('has')
->with('foo')
- ->will($this->returnValue(true));
+ ->willReturn(true);
$container->expects($this->once())
->method('get')
->with('foo')
- ->will($this->returnValue($service))
+ ->willReturn($service)
;
$resolver = $this->createControllerResolver(null, $container);
@@ -77,12 +77,12 @@ public function testGetControllerInvokableService()
$container->expects($this->once())
->method('has')
->with('foo')
- ->will($this->returnValue(true))
+ ->willReturn(true)
;
$container->expects($this->once())
->method('get')
->with('foo')
- ->will($this->returnValue($service))
+ ->willReturn($service)
;
$resolver = $this->createControllerResolver(null, $container);
@@ -102,12 +102,12 @@ public function testGetControllerInvokableServiceWithClassNameAsName()
$container->expects($this->once())
->method('has')
->with(InvokableControllerService::class)
- ->will($this->returnValue(true))
+ ->willReturn(true)
;
$container->expects($this->once())
->method('get')
->with(InvokableControllerService::class)
- ->will($this->returnValue($service))
+ ->willReturn($service)
;
$resolver = $this->createControllerResolver(null, $container);
@@ -131,13 +131,13 @@ public function testExceptionWhenUsingRemovedControllerServiceWithClassNameAsNam
$container->expects($this->once())
->method('has')
->with(ControllerTestService::class)
- ->will($this->returnValue(false))
+ ->willReturn(false)
;
$container->expects($this->atLeastOnce())
->method('getRemovedIds')
->with()
- ->will($this->returnValue([ControllerTestService::class => true]))
+ ->willReturn([ControllerTestService::class => true])
;
$resolver = $this->createControllerResolver(null, $container);
@@ -159,13 +159,13 @@ public function testExceptionWhenUsingRemovedControllerService()
$container->expects($this->once())
->method('has')
->with('app.my_controller')
- ->will($this->returnValue(false))
+ ->willReturn(false)
;
$container->expects($this->atLeastOnce())
->method('getRemovedIds')
->with()
- ->will($this->returnValue(['app.my_controller' => true]))
+ ->willReturn(['app.my_controller' => true])
;
$resolver = $this->createControllerResolver(null, $container);
diff --git a/src/Symfony/Component/HttpKernel/Tests/DataCollector/LoggerDataCollectorTest.php b/src/Symfony/Component/HttpKernel/Tests/DataCollector/LoggerDataCollectorTest.php
index e0bcc24bd78bd..261f098a72c19 100644
--- a/src/Symfony/Component/HttpKernel/Tests/DataCollector/LoggerDataCollectorTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/DataCollector/LoggerDataCollectorTest.php
@@ -27,8 +27,8 @@ public function testCollectWithUnexpectedFormat()
->getMockBuilder('Symfony\Component\HttpKernel\Log\DebugLoggerInterface')
->setMethods(['countErrors', 'getLogs', 'clear'])
->getMock();
- $logger->expects($this->once())->method('countErrors')->will($this->returnValue('foo'));
- $logger->expects($this->exactly(2))->method('getLogs')->will($this->returnValue([]));
+ $logger->expects($this->once())->method('countErrors')->willReturn('foo');
+ $logger->expects($this->exactly(2))->method('getLogs')->willReturn([]);
$c = new LoggerDataCollector($logger, __DIR__.'/');
$c->lateCollect();
@@ -56,7 +56,7 @@ public function testWithMasterRequest()
->setMethods(['countErrors', 'getLogs', 'clear'])
->getMock();
$logger->expects($this->once())->method('countErrors')->with(null);
- $logger->expects($this->exactly(2))->method('getLogs')->with(null)->will($this->returnValue([]));
+ $logger->expects($this->exactly(2))->method('getLogs')->with(null)->willReturn([]);
$c = new LoggerDataCollector($logger, __DIR__.'/', $stack);
@@ -77,7 +77,7 @@ public function testWithSubRequest()
->setMethods(['countErrors', 'getLogs', 'clear'])
->getMock();
$logger->expects($this->once())->method('countErrors')->with($subRequest);
- $logger->expects($this->exactly(2))->method('getLogs')->with($subRequest)->will($this->returnValue([]));
+ $logger->expects($this->exactly(2))->method('getLogs')->with($subRequest)->willReturn([]);
$c = new LoggerDataCollector($logger, __DIR__.'/', $stack);
@@ -94,8 +94,8 @@ public function testCollect($nb, $logs, $expectedLogs, $expectedDeprecationCount
->getMockBuilder('Symfony\Component\HttpKernel\Log\DebugLoggerInterface')
->setMethods(['countErrors', 'getLogs', 'clear'])
->getMock();
- $logger->expects($this->once())->method('countErrors')->will($this->returnValue($nb));
- $logger->expects($this->exactly(2))->method('getLogs')->will($this->returnValue($logs));
+ $logger->expects($this->once())->method('countErrors')->willReturn($nb);
+ $logger->expects($this->exactly(2))->method('getLogs')->willReturn($logs);
$c = new LoggerDataCollector($logger);
$c->lateCollect();
diff --git a/src/Symfony/Component/HttpKernel/Tests/DataCollector/TimeDataCollectorTest.php b/src/Symfony/Component/HttpKernel/Tests/DataCollector/TimeDataCollectorTest.php
index 793fbd319f94d..e044e5e1add53 100644
--- a/src/Symfony/Component/HttpKernel/Tests/DataCollector/TimeDataCollectorTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/DataCollector/TimeDataCollectorTest.php
@@ -44,7 +44,7 @@ public function testCollect()
$this->assertEquals(0, $c->getStartTime());
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
- $kernel->expects($this->once())->method('getStartTime')->will($this->returnValue(123456));
+ $kernel->expects($this->once())->method('getStartTime')->willReturn(123456);
$c = new TimeDataCollector($kernel);
$request = new Request();
@@ -52,6 +52,6 @@ public function testCollect()
$c->collect($request, new Response());
$this->assertEquals(123456000, $c->getStartTime());
- $this->assertSame(\class_exists(Stopwatch::class, false), $c->isStopwatchInstalled());
+ $this->assertSame(class_exists(Stopwatch::class, false), $c->isStopwatchInstalled());
}
}
diff --git a/src/Symfony/Component/HttpKernel/Tests/Debug/TraceableEventDispatcherTest.php b/src/Symfony/Component/HttpKernel/Tests/Debug/TraceableEventDispatcherTest.php
index 8b8e91aeb474d..60ad1b89c4dfb 100644
--- a/src/Symfony/Component/HttpKernel/Tests/Debug/TraceableEventDispatcherTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/Debug/TraceableEventDispatcherTest.php
@@ -49,7 +49,7 @@ public function testStopwatchCheckControllerOnRequestEvent()
->getMock();
$stopwatch->expects($this->once())
->method('isStarted')
- ->will($this->returnValue(false));
+ ->willReturn(false);
$dispatcher = new TraceableEventDispatcher(new EventDispatcher(), $stopwatch);
@@ -65,7 +65,7 @@ public function testStopwatchStopControllerOnRequestEvent()
->getMock();
$stopwatch->expects($this->once())
->method('isStarted')
- ->will($this->returnValue(true));
+ ->willReturn(true);
$stopwatch->expects($this->once())
->method('stop');
$stopwatch->expects($this->once())
@@ -112,9 +112,9 @@ public function testListenerCanRemoveItselfWhenExecuted()
protected function getHttpKernel($dispatcher, $controller)
{
$controllerResolver = $this->getMockBuilder('Symfony\Component\HttpKernel\Controller\ControllerResolverInterface')->getMock();
- $controllerResolver->expects($this->once())->method('getController')->will($this->returnValue($controller));
+ $controllerResolver->expects($this->once())->method('getController')->willReturn($controller);
$argumentResolver = $this->getMockBuilder('Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface')->getMock();
- $argumentResolver->expects($this->once())->method('getArguments')->will($this->returnValue([]));
+ $argumentResolver->expects($this->once())->method('getArguments')->willReturn([]);
return new HttpKernel($dispatcher, $controllerResolver, new RequestStack(), $argumentResolver);
}
diff --git a/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/LazyLoadingFragmentHandlerTest.php b/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/LazyLoadingFragmentHandlerTest.php
index 2bc84a53c8592..39a1cb73b1127 100644
--- a/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/LazyLoadingFragmentHandlerTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/LazyLoadingFragmentHandlerTest.php
@@ -21,15 +21,15 @@ class LazyLoadingFragmentHandlerTest extends TestCase
public function testRender()
{
$renderer = $this->getMockBuilder('Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface')->getMock();
- $renderer->expects($this->once())->method('getName')->will($this->returnValue('foo'));
- $renderer->expects($this->any())->method('render')->will($this->returnValue(new Response()));
+ $renderer->expects($this->once())->method('getName')->willReturn('foo');
+ $renderer->expects($this->any())->method('render')->willReturn(new Response());
$requestStack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->getMock();
- $requestStack->expects($this->any())->method('getCurrentRequest')->will($this->returnValue(Request::create('/')));
+ $requestStack->expects($this->any())->method('getCurrentRequest')->willReturn(Request::create('/'));
$container = $this->getMockBuilder('Psr\Container\ContainerInterface')->getMock();
$container->expects($this->once())->method('has')->with('foo')->willReturn(true);
- $container->expects($this->once())->method('get')->will($this->returnValue($renderer));
+ $container->expects($this->once())->method('get')->willReturn($renderer);
$handler = new LazyLoadingFragmentHandler($container, $requestStack, false);
diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/AddRequestFormatsListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/AddRequestFormatsListenerTest.php
index b4ea2f955bb53..4ab0a8fb1ea62 100644
--- a/src/Symfony/Component/HttpKernel/Tests/EventListener/AddRequestFormatsListenerTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/AddRequestFormatsListenerTest.php
@@ -77,7 +77,7 @@ protected function getGetResponseEventMock(Request $request)
$event->expects($this->any())
->method('getRequest')
- ->will($this->returnValue($request));
+ ->willReturn($request);
return $event;
}
diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/DebugHandlersListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/DebugHandlersListenerTest.php
index d9e261d35af5e..d7077cb7e5036 100644
--- a/src/Symfony/Component/HttpKernel/Tests/EventListener/DebugHandlersListenerTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/DebugHandlersListenerTest.php
@@ -94,7 +94,7 @@ public function testConsoleEvent()
$dispatcher = new EventDispatcher();
$listener = new DebugHandlersListener(null);
$app = $this->getMockBuilder('Symfony\Component\Console\Application')->getMock();
- $app->expects($this->once())->method('getHelperSet')->will($this->returnValue(new HelperSet()));
+ $app->expects($this->once())->method('getHelperSet')->willReturn(new HelperSet());
$command = new Command(__FUNCTION__);
$command->setApplication($app);
$event = new ConsoleEvent($command, new ArgvInput(), new ConsoleOutput());
@@ -104,6 +104,7 @@ public function testConsoleEvent()
$xListeners = [
KernelEvents::REQUEST => [[$listener, 'configure']],
ConsoleEvents::COMMAND => [[$listener, 'configure']],
+ KernelEvents::EXCEPTION => [[$listener, 'onKernelException']],
];
$this->assertSame($xListeners, $dispatcher->getListeners());
diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/ExceptionListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/ExceptionListenerTest.php
index b7224ddceaad3..bc5a8c77c8f7f 100644
--- a/src/Symfony/Component/HttpKernel/Tests/EventListener/ExceptionListenerTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/ExceptionListenerTest.php
@@ -116,9 +116,9 @@ public function testSubRequestFormat()
$listener = new ExceptionListener('foo', $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock());
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
- $kernel->expects($this->once())->method('handle')->will($this->returnCallback(function (Request $request) {
+ $kernel->expects($this->once())->method('handle')->willReturnCallback(function (Request $request) {
return new Response($request->getRequestFormat());
- }));
+ });
$request = Request::create('/');
$request->setRequestFormat('xml');
@@ -134,9 +134,9 @@ public function testCSPHeaderIsRemoved()
{
$dispatcher = new EventDispatcher();
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
- $kernel->expects($this->once())->method('handle')->will($this->returnCallback(function (Request $request) {
+ $kernel->expects($this->once())->method('handle')->willReturnCallback(function (Request $request) {
return new Response($request->getRequestFormat());
- }));
+ });
$listener = new ExceptionListener('foo', $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(), true);
@@ -155,25 +155,6 @@ public function testCSPHeaderIsRemoved()
$this->assertFalse($response->headers->has('content-security-policy'), 'CSP header has been removed');
$this->assertFalse($dispatcher->hasListeners(KernelEvents::RESPONSE), 'CSP removal listener has been removed');
}
-
- public function testNullController()
- {
- $listener = new ExceptionListener(null);
- $kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock();
- $kernel->expects($this->once())->method('handle')->will($this->returnCallback(function (Request $request) {
- $controller = $request->attributes->get('_controller');
-
- return $controller();
- }));
- $request = Request::create('/');
- $event = new GetResponseForExceptionEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST, new \Exception('foo'));
-
- $listener->onKernelException($event);
- $this->assertNull($event->getResponse());
-
- $listener->onKernelException($event);
- $this->assertContains('Whoops, looks like something went wrong.', $event->getResponse()->getContent());
- }
}
class TestLogger extends Logger implements DebugLoggerInterface
diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/LocaleListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/LocaleListenerTest.php
index 1cf4b72c69d78..5f96f7f7c660b 100644
--- a/src/Symfony/Component/HttpKernel/Tests/EventListener/LocaleListenerTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/LocaleListenerTest.php
@@ -55,7 +55,7 @@ public function testLocaleSetForRoutingContext()
$context->expects($this->once())->method('setParameter')->with('_locale', 'es');
$router = $this->getMockBuilder('Symfony\Component\Routing\Router')->setMethods(['getContext'])->disableOriginalConstructor()->getMock();
- $router->expects($this->once())->method('getContext')->will($this->returnValue($context));
+ $router->expects($this->once())->method('getContext')->willReturn($context);
$request = Request::create('/');
@@ -71,12 +71,12 @@ public function testRouterResetWithParentRequestOnKernelFinishRequest()
$context->expects($this->once())->method('setParameter')->with('_locale', 'es');
$router = $this->getMockBuilder('Symfony\Component\Routing\Router')->setMethods(['getContext'])->disableOriginalConstructor()->getMock();
- $router->expects($this->once())->method('getContext')->will($this->returnValue($context));
+ $router->expects($this->once())->method('getContext')->willReturn($context);
$parentRequest = Request::create('/');
$parentRequest->setLocale('es');
- $this->requestStack->expects($this->once())->method('getParentRequest')->will($this->returnValue($parentRequest));
+ $this->requestStack->expects($this->once())->method('getParentRequest')->willReturn($parentRequest);
$event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\FinishRequestEvent')->disableOriginalConstructor()->getMock();
diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/ProfilerListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/ProfilerListenerTest.php
index 392aa2fc35816..7808578882fcd 100644
--- a/src/Symfony/Component/HttpKernel/Tests/EventListener/ProfilerListenerTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/ProfilerListenerTest.php
@@ -36,7 +36,7 @@ public function testKernelTerminate()
$profiler->expects($this->once())
->method('collect')
- ->will($this->returnValue($profile));
+ ->willReturn($profile);
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/RouterListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/RouterListenerTest.php
index c27b341300763..e2d211608c5c9 100644
--- a/src/Symfony/Component/HttpKernel/Tests/EventListener/RouterListenerTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/RouterListenerTest.php
@@ -49,7 +49,7 @@ public function testPort($defaultHttpPort, $defaultHttpsPort, $uri, $expectedHtt
$context->setHttpsPort($defaultHttpsPort);
$urlMatcher->expects($this->any())
->method('getContext')
- ->will($this->returnValue($context));
+ ->willReturn($context);
$listener = new RouterListener($urlMatcher, $this->requestStack);
$event = $this->createGetResponseEventForUri($uri);
@@ -97,7 +97,7 @@ public function testRequestMatcher()
$requestMatcher->expects($this->once())
->method('matchRequest')
->with($this->isInstanceOf('Symfony\Component\HttpFoundation\Request'))
- ->will($this->returnValue([]));
+ ->willReturn([]);
$listener = new RouterListener($requestMatcher, $this->requestStack, new RequestContext());
$listener->onKernelRequest($event);
@@ -113,7 +113,7 @@ public function testSubRequestWithDifferentMethod()
$requestMatcher->expects($this->any())
->method('matchRequest')
->with($this->isInstanceOf('Symfony\Component\HttpFoundation\Request'))
- ->will($this->returnValue([]));
+ ->willReturn([]);
$context = new RequestContext();
@@ -138,7 +138,7 @@ public function testLoggingParameter($parameter, $log, $parameters)
$requestMatcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\RequestMatcherInterface')->getMock();
$requestMatcher->expects($this->once())
->method('matchRequest')
- ->will($this->returnValue($parameter));
+ ->willReturn($parameter);
$logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
$logger->expects($this->once())
diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/TestSessionListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/TestSessionListenerTest.php
index 9f6a5ef759aca..cabe2a615b753 100644
--- a/src/Symfony/Component/HttpKernel/Tests/EventListener/TestSessionListenerTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/TestSessionListenerTest.php
@@ -46,7 +46,7 @@ protected function setUp()
$this->session = $this->getSession();
$this->listener->expects($this->any())
->method('getSession')
- ->will($this->returnValue($this->session));
+ ->willReturn($this->session);
}
public function testShouldSaveMasterRequestSession()
@@ -183,28 +183,28 @@ private function sessionHasBeenStarted()
{
$this->session->expects($this->once())
->method('isStarted')
- ->will($this->returnValue(true));
+ ->willReturn(true);
}
private function sessionHasNotBeenStarted()
{
$this->session->expects($this->once())
->method('isStarted')
- ->will($this->returnValue(false));
+ ->willReturn(false);
}
private function sessionIsEmpty()
{
$this->session->expects($this->once())
->method('isEmpty')
- ->will($this->returnValue(true));
+ ->willReturn(true);
}
private function fixSessionId($sessionId)
{
$this->session->expects($this->any())
->method('getId')
- ->will($this->returnValue($sessionId));
+ ->willReturn($sessionId);
}
private function getSession()
@@ -214,7 +214,7 @@ private function getSession()
->getMock();
// set return value for getName()
- $mock->expects($this->any())->method('getName')->will($this->returnValue('MOCKSESSID'));
+ $mock->expects($this->any())->method('getName')->willReturn('MOCKSESSID');
return $mock;
}
diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/TranslatorListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/TranslatorListenerTest.php
index c75e7b980f464..796039533717d 100644
--- a/src/Symfony/Component/HttpKernel/Tests/EventListener/TranslatorListenerTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/TranslatorListenerTest.php
@@ -114,6 +114,6 @@ private function setMasterRequest($request)
$this->requestStack
->expects($this->any())
->method('getParentRequest')
- ->will($this->returnValue($request));
+ ->willReturn($request);
}
}
diff --git a/src/Symfony/Component/HttpKernel/Tests/Fixtures/TestEventDispatcher.php b/src/Symfony/Component/HttpKernel/Tests/Fixtures/TestEventDispatcher.php
deleted file mode 100644
index a0665ef991839..0000000000000
--- a/src/Symfony/Component/HttpKernel/Tests/Fixtures/TestEventDispatcher.php
+++ /dev/null
@@ -1,36 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Component\HttpKernel\Tests\Fixtures;
-
-use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher;
-
-class TestEventDispatcher extends TraceableEventDispatcher
-{
- public function getCalledListeners()
- {
- return ['foo'];
- }
-
- public function getNotCalledListeners()
- {
- return ['bar'];
- }
-
- public function reset()
- {
- }
-
- public function getOrphanedEvents()
- {
- return [];
- }
-}
diff --git a/src/Symfony/Component/HttpKernel/Tests/Fragment/FragmentHandlerTest.php b/src/Symfony/Component/HttpKernel/Tests/Fragment/FragmentHandlerTest.php
index bc7236f0a84e9..e2e72df00c140 100644
--- a/src/Symfony/Component/HttpKernel/Tests/Fragment/FragmentHandlerTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/Fragment/FragmentHandlerTest.php
@@ -32,7 +32,7 @@ protected function setUp()
$this->requestStack
->expects($this->any())
->method('getCurrentRequest')
- ->will($this->returnValue(Request::create('/')))
+ ->willReturn(Request::create('/'))
;
}
@@ -79,7 +79,7 @@ protected function getHandler($returnValue, $arguments = [])
$renderer
->expects($this->any())
->method('getName')
- ->will($this->returnValue('foo'))
+ ->willReturn('foo')
;
$e = $renderer
->expects($this->any())
diff --git a/src/Symfony/Component/HttpKernel/Tests/Fragment/InlineFragmentRendererTest.php b/src/Symfony/Component/HttpKernel/Tests/Fragment/InlineFragmentRendererTest.php
index 155493d7f448e..eda8b891ea9ce 100644
--- a/src/Symfony/Component/HttpKernel/Tests/Fragment/InlineFragmentRendererTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/Fragment/InlineFragmentRendererTest.php
@@ -118,18 +118,18 @@ public function testExceptionInSubRequestsDoesNotMangleOutputBuffers()
$controllerResolver
->expects($this->once())
->method('getController')
- ->will($this->returnValue(function () {
+ ->willReturn(function () {
ob_start();
echo 'bar';
throw new \RuntimeException();
- }))
+ })
;
$argumentResolver = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Controller\\ArgumentResolverInterface')->getMock();
$argumentResolver
->expects($this->once())
->method('getArguments')
- ->will($this->returnValue([]))
+ ->willReturn([])
;
$kernel = new HttpKernel(new EventDispatcher(), $controllerResolver, new RequestStack(), $argumentResolver);
diff --git a/src/Symfony/Component/HttpKernel/Tests/HttpCache/EsiTest.php b/src/Symfony/Component/HttpKernel/Tests/HttpCache/EsiTest.php
index 2049a1771a877..ef717c63f51b1 100644
--- a/src/Symfony/Component/HttpKernel/Tests/HttpCache/EsiTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/HttpCache/EsiTest.php
@@ -229,7 +229,7 @@ protected function getCache($request, $response)
$cache = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpCache\HttpCache')->setMethods(['getRequest', 'handle'])->disableOriginalConstructor()->getMock();
$cache->expects($this->any())
->method('getRequest')
- ->will($this->returnValue($request))
+ ->willReturn($request)
;
if (\is_array($response)) {
$cache->expects($this->any())
@@ -239,7 +239,7 @@ protected function getCache($request, $response)
} else {
$cache->expects($this->any())
->method('handle')
- ->will($this->returnValue($response))
+ ->willReturn($response)
;
}
diff --git a/src/Symfony/Component/HttpKernel/Tests/HttpCache/SsiTest.php b/src/Symfony/Component/HttpKernel/Tests/HttpCache/SsiTest.php
index 2b9d352c7c087..4411427028131 100644
--- a/src/Symfony/Component/HttpKernel/Tests/HttpCache/SsiTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/HttpCache/SsiTest.php
@@ -196,7 +196,7 @@ protected function getCache($request, $response)
$cache = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpCache\HttpCache')->setMethods(['getRequest', 'handle'])->disableOriginalConstructor()->getMock();
$cache->expects($this->any())
->method('getRequest')
- ->will($this->returnValue($request))
+ ->willReturn($request)
;
if (\is_array($response)) {
$cache->expects($this->any())
@@ -206,7 +206,7 @@ protected function getCache($request, $response)
} else {
$cache->expects($this->any())
->method('handle')
- ->will($this->returnValue($response))
+ ->willReturn($response)
;
}
diff --git a/src/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php b/src/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php
index 4d1e267e3acdd..d1819146a6589 100644
--- a/src/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php
@@ -354,13 +354,13 @@ private function getHttpKernel(EventDispatcherInterface $eventDispatcher, $contr
$controllerResolver
->expects($this->any())
->method('getController')
- ->will($this->returnValue($controller));
+ ->willReturn($controller);
$argumentResolver = $this->getMockBuilder(ArgumentResolverInterface::class)->getMock();
$argumentResolver
->expects($this->any())
->method('getArguments')
- ->will($this->returnValue($arguments));
+ ->willReturn($arguments);
return new HttpKernel($eventDispatcher, $controllerResolver, $requestStack, $argumentResolver);
}
diff --git a/src/Symfony/Component/HttpKernel/Tests/KernelTest.php b/src/Symfony/Component/HttpKernel/Tests/KernelTest.php
index 57bd704c92d3e..97f369ebb36fc 100644
--- a/src/Symfony/Component/HttpKernel/Tests/KernelTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/KernelTest.php
@@ -109,7 +109,7 @@ public function testBootSetsTheContainerToTheBundles()
$kernel = $this->getKernel(['initializeBundles', 'initializeContainer', 'getBundles']);
$kernel->expects($this->once())
->method('getBundles')
- ->will($this->returnValue([$bundle]));
+ ->willReturn([$bundle]);
$kernel->boot();
}
@@ -164,7 +164,7 @@ public function testShutdownGivesNullContainerToAllBundles()
$kernel = $this->getKernel(['getBundles']);
$kernel->expects($this->any())
->method('getBundles')
- ->will($this->returnValue([$bundle]));
+ ->willReturn([$bundle]);
$kernel->boot();
$kernel->shutdown();
@@ -187,7 +187,7 @@ public function testHandleCallsHandleOnHttpKernel()
$kernel = $this->getKernel(['getHttpKernel']);
$kernel->expects($this->once())
->method('getHttpKernel')
- ->will($this->returnValue($httpKernelMock));
+ ->willReturn($httpKernelMock);
$kernel->handle($request, $type, $catch);
}
@@ -205,7 +205,7 @@ public function testHandleBootsTheKernel()
$kernel = $this->getKernel(['getHttpKernel', 'boot']);
$kernel->expects($this->once())
->method('getHttpKernel')
- ->will($this->returnValue($httpKernelMock));
+ ->willReturn($httpKernelMock);
$kernel->expects($this->once())
->method('boot');
@@ -368,7 +368,7 @@ public function testLocateResourceThrowsExceptionWhenResourceDoesNotExist()
$kernel
->expects($this->once())
->method('getBundle')
- ->will($this->returnValue($this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle')))
+ ->willReturn($this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle'))
;
$kernel->locateResource('@Bundle1Bundle/config/routing.xml');
@@ -380,7 +380,7 @@ public function testLocateResourceReturnsTheFirstThatMatches()
$kernel
->expects($this->once())
->method('getBundle')
- ->will($this->returnValue($this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle')))
+ ->willReturn($this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle'))
;
$this->assertEquals(__DIR__.'/Fixtures/Bundle1Bundle/foo.txt', $kernel->locateResource('@Bundle1Bundle/foo.txt'));
@@ -392,7 +392,7 @@ public function testLocateResourceIgnoresDirOnNonResource()
$kernel
->expects($this->once())
->method('getBundle')
- ->will($this->returnValue($this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle')))
+ ->willReturn($this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle'))
;
$this->assertEquals(
@@ -407,7 +407,7 @@ public function testLocateResourceReturnsTheDirOneForResources()
$kernel
->expects($this->once())
->method('getBundle')
- ->will($this->returnValue($this->getBundle(__DIR__.'/Fixtures/FooBundle', null, null, 'FooBundle')))
+ ->willReturn($this->getBundle(__DIR__.'/Fixtures/FooBundle', null, null, 'FooBundle'))
;
$this->assertEquals(
@@ -422,7 +422,7 @@ public function testLocateResourceOnDirectories()
$kernel
->expects($this->exactly(2))
->method('getBundle')
- ->will($this->returnValue($this->getBundle(__DIR__.'/Fixtures/FooBundle', null, null, 'FooBundle')))
+ ->willReturn($this->getBundle(__DIR__.'/Fixtures/FooBundle', null, null, 'FooBundle'))
;
$this->assertEquals(
@@ -438,7 +438,7 @@ public function testLocateResourceOnDirectories()
$kernel
->expects($this->exactly(2))
->method('getBundle')
- ->will($this->returnValue($this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle', null, null, 'Bundle1Bundle')))
+ ->willReturn($this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle', null, null, 'Bundle1Bundle'))
;
$this->assertEquals(
@@ -501,7 +501,7 @@ public function testTerminateDelegatesTerminationOnlyForTerminableInterface()
$kernel = $this->getKernel(['getHttpKernel']);
$kernel->expects($this->exactly(2))
->method('getHttpKernel')
- ->will($this->returnValue($httpKernelMock));
+ ->willReturn($httpKernelMock);
$kernel->boot();
$kernel->terminate(Request::create('/'), new Response());
@@ -627,19 +627,19 @@ protected function getBundle($dir = null, $parent = null, $className = null, $bu
$bundle
->expects($this->any())
->method('getName')
- ->will($this->returnValue(null === $bundleName ? \get_class($bundle) : $bundleName))
+ ->willReturn(null === $bundleName ? \get_class($bundle) : $bundleName)
;
$bundle
->expects($this->any())
->method('getPath')
- ->will($this->returnValue($dir))
+ ->willReturn($dir)
;
$bundle
->expects($this->any())
->method('getParent')
- ->will($this->returnValue($parent))
+ ->willReturn($parent)
;
return $bundle;
@@ -665,7 +665,7 @@ protected function getKernel(array $methods = [], array $bundles = [])
;
$kernel->expects($this->any())
->method('registerBundles')
- ->will($this->returnValue($bundles))
+ ->willReturn($bundles)
;
$p = new \ReflectionProperty($kernel, 'rootDir');
$p->setAccessible(true);
diff --git a/src/Symfony/Component/HttpKernel/Tests/Log/LoggerTest.php b/src/Symfony/Component/HttpKernel/Tests/Log/LoggerTest.php
index 17865203f2c96..3a5a8ade54156 100644
--- a/src/Symfony/Component/HttpKernel/Tests/Log/LoggerTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/Log/LoggerTest.php
@@ -149,7 +149,7 @@ public function testObjectCastToString()
}
$dummy->expects($this->atLeastOnce())
->method('__toString')
- ->will($this->returnValue('DUMMY'));
+ ->willReturn('DUMMY');
$this->logger->warning($dummy);
diff --git a/src/Symfony/Component/Intl/Data/Generator/LocaleDataGenerator.php b/src/Symfony/Component/Intl/Data/Generator/LocaleDataGenerator.php
index 9d57b070696e3..eda413a12b14f 100644
--- a/src/Symfony/Component/Intl/Data/Generator/LocaleDataGenerator.php
+++ b/src/Symfony/Component/Intl/Data/Generator/LocaleDataGenerator.php
@@ -65,9 +65,9 @@ protected function compileTemporaryBundles(BundleCompilerInterface $compiler, $s
protected function preGenerate()
{
// Write parents locale file for the Translation component
- \file_put_contents(
+ file_put_contents(
__DIR__.'/../../../Translation/Resources/data/parents.json',
- \json_encode($this->localeParents, \JSON_PRETTY_PRINT).\PHP_EOL
+ json_encode($this->localeParents, \JSON_PRETTY_PRINT).\PHP_EOL
);
}
diff --git a/src/Symfony/Component/Intl/Data/Util/LocaleScanner.php b/src/Symfony/Component/Intl/Data/Util/LocaleScanner.php
index 2d56ff9d0cf1f..49aec06b1fdfc 100644
--- a/src/Symfony/Component/Intl/Data/Util/LocaleScanner.php
+++ b/src/Symfony/Component/Intl/Data/Util/LocaleScanner.php
@@ -92,10 +92,10 @@ public function scanParents(string $sourceDir): array
$fallbacks = [];
foreach ($locales as $locale) {
- $content = \file_get_contents($sourceDir.'/'.$locale.'.txt');
+ $content = file_get_contents($sourceDir.'/'.$locale.'.txt');
// Aliases contain the text "%%PARENT" followed by the aliased locale
- if (\preg_match('/%%Parent{"([^"]+)"}/', $content, $matches)) {
+ if (preg_match('/%%Parent{"([^"]+)"}/', $content, $matches)) {
$fallbacks[$locale] = $matches[1];
}
}
diff --git a/src/Symfony/Component/Intl/DateFormatter/DateFormat/DayOfYearTransformer.php b/src/Symfony/Component/Intl/DateFormatter/DateFormat/DayOfYearTransformer.php
index c021ad5cbcb45..93c09d8b22da3 100644
--- a/src/Symfony/Component/Intl/DateFormatter/DateFormat/DayOfYearTransformer.php
+++ b/src/Symfony/Component/Intl/DateFormatter/DateFormat/DayOfYearTransformer.php
@@ -25,7 +25,7 @@ class DayOfYearTransformer extends Transformer
*/
public function format(\DateTime $dateTime, int $length): string
{
- $dayOfYear = $dateTime->format('z') + 1;
+ $dayOfYear = (int) $dateTime->format('z') + 1;
return $this->padLeft($dayOfYear, $length);
}
diff --git a/src/Symfony/Component/Intl/DateFormatter/DateFormat/FullTransformer.php b/src/Symfony/Component/Intl/DateFormatter/DateFormat/FullTransformer.php
index 6ff96ec1ac478..2ae6e7a992d32 100644
--- a/src/Symfony/Component/Intl/DateFormatter/DateFormat/FullTransformer.php
+++ b/src/Symfony/Component/Intl/DateFormatter/DateFormat/FullTransformer.php
@@ -315,7 +315,7 @@ protected function calculateUnixTimestamp(\DateTime $dateTime, array $options)
preg_match_all($this->regExp, $this->pattern, $matches);
if (\in_array('yy', $matches[0])) {
$dateTime->setTimestamp(time());
- $year = $year > $dateTime->format('y') + 20 ? 1900 + $year : 2000 + $year;
+ $year = $year > (int) $dateTime->format('y') + 20 ? 1900 + $year : 2000 + $year;
}
$dateTime->setDate($year, $month, $day);
diff --git a/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/BundleEntryReaderTest.php b/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/BundleEntryReaderTest.php
index 766611ed027d6..3357b039ea814 100644
--- a/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/BundleEntryReaderTest.php
+++ b/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/BundleEntryReaderTest.php
@@ -72,7 +72,7 @@ public function testForwardCallToRead()
$this->readerImpl->expects($this->once())
->method('read')
->with(self::RES_DIR, 'root')
- ->will($this->returnValue(self::$data));
+ ->willReturn(self::$data);
$this->assertSame(self::$data, $this->reader->read(self::RES_DIR, 'root'));
}
@@ -82,12 +82,12 @@ public function testReadEntireDataFileIfNoIndicesGiven()
$this->readerImpl->expects($this->at(0))
->method('read')
->with(self::RES_DIR, 'en')
- ->will($this->returnValue(self::$data));
+ ->willReturn(self::$data);
$this->readerImpl->expects($this->at(1))
->method('read')
->with(self::RES_DIR, 'root')
- ->will($this->returnValue(self::$fallbackData));
+ ->willReturn(self::$fallbackData);
$this->assertSame(self::$mergedData, $this->reader->readEntry(self::RES_DIR, 'en', []));
}
@@ -97,7 +97,7 @@ public function testReadExistingEntry()
$this->readerImpl->expects($this->once())
->method('read')
->with(self::RES_DIR, 'root')
- ->will($this->returnValue(self::$data));
+ ->willReturn(self::$data);
$this->assertSame('Bar', $this->reader->readEntry(self::RES_DIR, 'root', ['Entries', 'Foo']));
}
@@ -110,7 +110,7 @@ public function testReadNonExistingEntry()
$this->readerImpl->expects($this->once())
->method('read')
->with(self::RES_DIR, 'root')
- ->will($this->returnValue(self::$data));
+ ->willReturn(self::$data);
$this->reader->readEntry(self::RES_DIR, 'root', ['Entries', 'NonExisting']);
}
@@ -120,12 +120,12 @@ public function testFallbackIfEntryDoesNotExist()
$this->readerImpl->expects($this->at(0))
->method('read')
->with(self::RES_DIR, 'en_GB')
- ->will($this->returnValue(self::$data));
+ ->willReturn(self::$data);
$this->readerImpl->expects($this->at(1))
->method('read')
->with(self::RES_DIR, 'en')
- ->will($this->returnValue(self::$fallbackData));
+ ->willReturn(self::$fallbackData);
$this->assertSame('Lah', $this->reader->readEntry(self::RES_DIR, 'en_GB', ['Entries', 'Bam']));
}
@@ -138,7 +138,7 @@ public function testDontFallbackIfEntryDoesNotExistAndFallbackDisabled()
$this->readerImpl->expects($this->once())
->method('read')
->with(self::RES_DIR, 'en_GB')
- ->will($this->returnValue(self::$data));
+ ->willReturn(self::$data);
$this->reader->readEntry(self::RES_DIR, 'en_GB', ['Entries', 'Bam'], false);
}
@@ -153,7 +153,7 @@ public function testFallbackIfLocaleDoesNotExist()
$this->readerImpl->expects($this->at(1))
->method('read')
->with(self::RES_DIR, 'en')
- ->will($this->returnValue(self::$fallbackData));
+ ->willReturn(self::$fallbackData);
$this->assertSame('Lah', $this->reader->readEntry(self::RES_DIR, 'en_GB', ['Entries', 'Bam']));
}
@@ -193,17 +193,17 @@ public function testMergeDataWithFallbackData($childData, $parentData, $result)
$this->readerImpl->expects($this->at(0))
->method('read')
->with(self::RES_DIR, 'en')
- ->will($this->returnValue($childData));
+ ->willReturn($childData);
$this->readerImpl->expects($this->at(1))
->method('read')
->with(self::RES_DIR, 'root')
- ->will($this->returnValue($parentData));
+ ->willReturn($parentData);
} else {
$this->readerImpl->expects($this->once())
->method('read')
->with(self::RES_DIR, 'en')
- ->will($this->returnValue($childData));
+ ->willReturn($childData);
}
$this->assertSame($result, $this->reader->readEntry(self::RES_DIR, 'en', [], true));
@@ -217,7 +217,7 @@ public function testDontMergeDataIfFallbackDisabled($childData, $parentData, $re
$this->readerImpl->expects($this->once())
->method('read')
->with(self::RES_DIR, 'en_GB')
- ->will($this->returnValue($childData));
+ ->willReturn($childData);
$this->assertSame($childData, $this->reader->readEntry(self::RES_DIR, 'en_GB', [], false));
}
@@ -231,17 +231,17 @@ public function testMergeExistingEntryWithExistingFallbackEntry($childData, $par
$this->readerImpl->expects($this->at(0))
->method('read')
->with(self::RES_DIR, 'en')
- ->will($this->returnValue(['Foo' => ['Bar' => $childData]]));
+ ->willReturn(['Foo' => ['Bar' => $childData]]);
$this->readerImpl->expects($this->at(1))
->method('read')
->with(self::RES_DIR, 'root')
- ->will($this->returnValue(['Foo' => ['Bar' => $parentData]]));
+ ->willReturn(['Foo' => ['Bar' => $parentData]]);
} else {
$this->readerImpl->expects($this->once())
->method('read')
->with(self::RES_DIR, 'en')
- ->will($this->returnValue(['Foo' => ['Bar' => $childData]]));
+ ->willReturn(['Foo' => ['Bar' => $childData]]);
}
$this->assertSame($result, $this->reader->readEntry(self::RES_DIR, 'en', ['Foo', 'Bar'], true));
@@ -255,12 +255,12 @@ public function testMergeNonExistingEntryWithExistingFallbackEntry($childData, $
$this->readerImpl->expects($this->at(0))
->method('read')
->with(self::RES_DIR, 'en_GB')
- ->will($this->returnValue(['Foo' => 'Baz']));
+ ->willReturn(['Foo' => 'Baz']);
$this->readerImpl->expects($this->at(1))
->method('read')
->with(self::RES_DIR, 'en')
- ->will($this->returnValue(['Foo' => ['Bar' => $parentData]]));
+ ->willReturn(['Foo' => ['Bar' => $parentData]]);
$this->assertSame($parentData, $this->reader->readEntry(self::RES_DIR, 'en_GB', ['Foo', 'Bar'], true));
}
@@ -274,17 +274,17 @@ public function testMergeExistingEntryWithNonExistingFallbackEntry($childData, $
$this->readerImpl->expects($this->at(0))
->method('read')
->with(self::RES_DIR, 'en_GB')
- ->will($this->returnValue(['Foo' => ['Bar' => $childData]]));
+ ->willReturn(['Foo' => ['Bar' => $childData]]);
$this->readerImpl->expects($this->at(1))
->method('read')
->with(self::RES_DIR, 'en')
- ->will($this->returnValue(['Foo' => 'Bar']));
+ ->willReturn(['Foo' => 'Bar']);
} else {
$this->readerImpl->expects($this->once())
->method('read')
->with(self::RES_DIR, 'en_GB')
- ->will($this->returnValue(['Foo' => ['Bar' => $childData]]));
+ ->willReturn(['Foo' => ['Bar' => $childData]]);
}
$this->assertSame($childData, $this->reader->readEntry(self::RES_DIR, 'en_GB', ['Foo', 'Bar'], true));
@@ -298,12 +298,12 @@ public function testFailIfEntryFoundNeitherInParentNorChild()
$this->readerImpl->expects($this->at(0))
->method('read')
->with(self::RES_DIR, 'en_GB')
- ->will($this->returnValue(['Foo' => 'Baz']));
+ ->willReturn(['Foo' => 'Baz']);
$this->readerImpl->expects($this->at(1))
->method('read')
->with(self::RES_DIR, 'en')
- ->will($this->returnValue(['Foo' => 'Bar']));
+ ->willReturn(['Foo' => 'Bar']);
$this->reader->readEntry(self::RES_DIR, 'en_GB', ['Foo', 'Bar'], true);
}
@@ -320,17 +320,17 @@ public function testMergeTraversables($childData, $parentData, $result)
$this->readerImpl->expects($this->at(0))
->method('read')
->with(self::RES_DIR, 'en_GB')
- ->will($this->returnValue(['Foo' => ['Bar' => $childData]]));
+ ->willReturn(['Foo' => ['Bar' => $childData]]);
$this->readerImpl->expects($this->at(1))
->method('read')
->with(self::RES_DIR, 'en')
- ->will($this->returnValue(['Foo' => ['Bar' => $parentData]]));
+ ->willReturn(['Foo' => ['Bar' => $parentData]]);
} else {
$this->readerImpl->expects($this->once())
->method('read')
->with(self::RES_DIR, 'en_GB')
- ->will($this->returnValue(['Foo' => ['Bar' => $childData]]));
+ ->willReturn(['Foo' => ['Bar' => $childData]]);
}
$this->assertSame($result, $this->reader->readEntry(self::RES_DIR, 'en_GB', ['Foo', 'Bar'], true));
@@ -347,18 +347,18 @@ public function testFollowLocaleAliases($childData, $parentData, $result)
$this->readerImpl->expects($this->at(0))
->method('read')
->with(self::RES_DIR, 'ro_MD')
- ->will($this->returnValue(['Foo' => ['Bar' => $childData]]));
+ ->willReturn(['Foo' => ['Bar' => $childData]]);
// Read fallback locale of aliased locale ("ro_MD" -> "ro")
$this->readerImpl->expects($this->at(1))
->method('read')
->with(self::RES_DIR, 'ro')
- ->will($this->returnValue(['Foo' => ['Bar' => $parentData]]));
+ ->willReturn(['Foo' => ['Bar' => $parentData]]);
} else {
$this->readerImpl->expects($this->once())
->method('read')
->with(self::RES_DIR, 'ro_MD')
- ->will($this->returnValue(['Foo' => ['Bar' => $childData]]));
+ ->willReturn(['Foo' => ['Bar' => $childData]]);
}
$this->assertSame($result, $this->reader->readEntry(self::RES_DIR, 'mo', ['Foo', 'Bar'], true));
diff --git a/src/Symfony/Component/Ldap/Tests/LdapTest.php b/src/Symfony/Component/Ldap/Tests/LdapTest.php
index acc845222587a..0d6961c267ac1 100644
--- a/src/Symfony/Component/Ldap/Tests/LdapTest.php
+++ b/src/Symfony/Component/Ldap/Tests/LdapTest.php
@@ -42,7 +42,7 @@ public function testLdapBind()
$this->adapter
->expects($this->once())
->method('getConnection')
- ->will($this->returnValue($connection))
+ ->willReturn($connection)
;
$this->ldap->bind('foo', 'bar');
}
diff --git a/src/Symfony/Component/Lock/Lock.php b/src/Symfony/Component/Lock/Lock.php
index 97117a8204174..db185c374dd55 100644
--- a/src/Symfony/Component/Lock/Lock.php
+++ b/src/Symfony/Component/Lock/Lock.php
@@ -83,6 +83,11 @@ public function acquire($blocking = false)
}
if ($this->key->isExpired()) {
+ try {
+ $this->release();
+ } catch (\Exception $e) {
+ // swallow exception to not hide the original issue
+ }
throw new LockExpiredException(sprintf('Failed to store the "%s" lock.', $this->key));
}
@@ -120,6 +125,11 @@ public function refresh($ttl = null)
$this->dirty = true;
if ($this->key->isExpired()) {
+ try {
+ $this->release();
+ } catch (\Exception $e) {
+ // swallow exception to not hide the original issue
+ }
throw new LockExpiredException(sprintf('Failed to put off the expiration of the "%s" lock within the specified time.', $this->key));
}
diff --git a/src/Symfony/Component/Lock/Store/CombinedStore.php b/src/Symfony/Component/Lock/Store/CombinedStore.php
index 38f3f35e750e9..6038b3be93d31 100644
--- a/src/Symfony/Component/Lock/Store/CombinedStore.php
+++ b/src/Symfony/Component/Lock/Store/CombinedStore.php
@@ -16,7 +16,6 @@
use Psr\Log\NullLogger;
use Symfony\Component\Lock\Exception\InvalidArgumentException;
use Symfony\Component\Lock\Exception\LockConflictedException;
-use Symfony\Component\Lock\Exception\LockExpiredException;
use Symfony\Component\Lock\Exception\NotSupportedException;
use Symfony\Component\Lock\Key;
use Symfony\Component\Lock\StoreInterface;
@@ -30,6 +29,7 @@
class CombinedStore implements StoreInterface, LoggerAwareInterface
{
use LoggerAwareTrait;
+ use ExpiringStoreTrait;
/** @var StoreInterface[] */
private $stores;
@@ -78,6 +78,8 @@ public function save(Key $key)
}
}
+ $this->checkNotExpired($key);
+
if ($this->strategy->isMet($successCount, $storesCount)) {
return;
}
@@ -125,9 +127,7 @@ public function putOffExpiration(Key $key, $ttl)
}
}
- if ($key->isExpired()) {
- throw new LockExpiredException(sprintf('Failed to put off the expiration of the "%s" lock within the specified time.', $key));
- }
+ $this->checkNotExpired($key);
if ($this->strategy->isMet($successCount, $storesCount)) {
return;
diff --git a/src/Symfony/Component/Lock/Store/ExpiringStoreTrait.php b/src/Symfony/Component/Lock/Store/ExpiringStoreTrait.php
new file mode 100644
index 0000000000000..e22c4405e4151
--- /dev/null
+++ b/src/Symfony/Component/Lock/Store/ExpiringStoreTrait.php
@@ -0,0 +1,30 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Lock\Store;
+
+use Symfony\Component\Lock\Exception\LockExpiredException;
+use Symfony\Component\Lock\Key;
+
+trait ExpiringStoreTrait
+{
+ private function checkNotExpired(Key $key)
+ {
+ if ($key->isExpired()) {
+ try {
+ $this->delete($key);
+ } catch (\Exception $e) {
+ // swallow exception to not hide the original issue
+ }
+ throw new LockExpiredException(sprintf('Failed to store the "%s" lock.', $key));
+ }
+ }
+}
diff --git a/src/Symfony/Component/Lock/Store/MemcachedStore.php b/src/Symfony/Component/Lock/Store/MemcachedStore.php
index 92f84450a9e52..9b84303fc38f0 100644
--- a/src/Symfony/Component/Lock/Store/MemcachedStore.php
+++ b/src/Symfony/Component/Lock/Store/MemcachedStore.php
@@ -13,7 +13,6 @@
use Symfony\Component\Lock\Exception\InvalidArgumentException;
use Symfony\Component\Lock\Exception\LockConflictedException;
-use Symfony\Component\Lock\Exception\LockExpiredException;
use Symfony\Component\Lock\Key;
use Symfony\Component\Lock\StoreInterface;
@@ -24,6 +23,8 @@
*/
class MemcachedStore implements StoreInterface
{
+ use ExpiringStoreTrait;
+
private $memcached;
private $initialTtl;
/** @var bool */
@@ -64,9 +65,7 @@ public function save(Key $key)
$this->putOffExpiration($key, $this->initialTtl);
}
- if ($key->isExpired()) {
- throw new LockExpiredException(sprintf('Failed to store the "%s" lock.', $key));
- }
+ $this->checkNotExpired($key);
}
public function waitAndSave(Key $key)
@@ -110,9 +109,7 @@ public function putOffExpiration(Key $key, $ttl)
throw new LockConflictedException();
}
- if ($key->isExpired()) {
- throw new LockExpiredException(sprintf('Failed to put off the expiration of the "%s" lock within the specified time.', $key));
- }
+ $this->checkNotExpired($key);
}
/**
diff --git a/src/Symfony/Component/Lock/Store/PdoStore.php b/src/Symfony/Component/Lock/Store/PdoStore.php
index 8066501166227..0cf3dd35f7a19 100644
--- a/src/Symfony/Component/Lock/Store/PdoStore.php
+++ b/src/Symfony/Component/Lock/Store/PdoStore.php
@@ -16,7 +16,6 @@
use Doctrine\DBAL\Schema\Schema;
use Symfony\Component\Lock\Exception\InvalidArgumentException;
use Symfony\Component\Lock\Exception\LockConflictedException;
-use Symfony\Component\Lock\Exception\LockExpiredException;
use Symfony\Component\Lock\Exception\NotSupportedException;
use Symfony\Component\Lock\Key;
use Symfony\Component\Lock\StoreInterface;
@@ -36,6 +35,8 @@
*/
class PdoStore implements StoreInterface
{
+ use ExpiringStoreTrait;
+
private $conn;
private $dsn;
private $driver;
@@ -123,11 +124,6 @@ public function save(Key $key)
try {
$stmt->execute();
- if ($key->isExpired()) {
- throw new LockExpiredException(sprintf('Failed to put off the expiration of the "%s" lock within the specified time.', $key));
- }
-
- return;
} catch (DBALException $e) {
// the lock is already acquired. It could be us. Let's try to put off.
$this->putOffExpiration($key, $this->initialTtl);
@@ -136,13 +132,11 @@ public function save(Key $key)
$this->putOffExpiration($key, $this->initialTtl);
}
- if ($key->isExpired()) {
- throw new LockExpiredException(sprintf('Failed to store the "%s" lock.', $key));
- }
-
if ($this->gcProbability > 0 && (1.0 === $this->gcProbability || (random_int(0, PHP_INT_MAX) / PHP_INT_MAX) <= $this->gcProbability)) {
$this->prune();
}
+
+ $this->checkNotExpired($key);
}
/**
@@ -178,9 +172,7 @@ public function putOffExpiration(Key $key, $ttl)
throw new LockConflictedException();
}
- if ($key->isExpired()) {
- throw new LockExpiredException(sprintf('Failed to put off the expiration of the "%s" lock within the specified time.', $key));
- }
+ $this->checkNotExpired($key);
}
/**
@@ -294,7 +286,7 @@ public function createTable(): void
}
/**
- * Cleanups the table by removing all expired locks.
+ * Cleans up the table by removing all expired locks.
*/
private function prune(): void
{
diff --git a/src/Symfony/Component/Lock/Store/RedisStore.php b/src/Symfony/Component/Lock/Store/RedisStore.php
index d07a2ce27f7fe..39360de45c47d 100644
--- a/src/Symfony/Component/Lock/Store/RedisStore.php
+++ b/src/Symfony/Component/Lock/Store/RedisStore.php
@@ -15,7 +15,6 @@
use Symfony\Component\Cache\Traits\RedisProxy;
use Symfony\Component\Lock\Exception\InvalidArgumentException;
use Symfony\Component\Lock\Exception\LockConflictedException;
-use Symfony\Component\Lock\Exception\LockExpiredException;
use Symfony\Component\Lock\Key;
use Symfony\Component\Lock\StoreInterface;
@@ -26,6 +25,8 @@
*/
class RedisStore implements StoreInterface
{
+ use ExpiringStoreTrait;
+
private $redis;
private $initialTtl;
@@ -67,11 +68,12 @@ public function save(Key $key)
throw new LockConflictedException();
}
- if ($key->isExpired()) {
- throw new LockExpiredException(sprintf('Failed to store the "%s" lock.', $key));
- }
+ $this->checkNotExpired($key);
}
+ /**
+ * {@inheritdoc}
+ */
public function waitAndSave(Key $key)
{
throw new InvalidArgumentException(sprintf('The store "%s" does not supports blocking locks.', \get_class($this)));
@@ -95,9 +97,7 @@ public function putOffExpiration(Key $key, $ttl)
throw new LockConflictedException();
}
- if ($key->isExpired()) {
- throw new LockExpiredException(sprintf('Failed to put off the expiration of the "%s" lock within the specified time.', $key));
- }
+ $this->checkNotExpired($key);
}
/**
diff --git a/src/Symfony/Component/Lock/Store/ZookeeperStore.php b/src/Symfony/Component/Lock/Store/ZookeeperStore.php
index c755ce1a1c4a3..4f8b4ee374e86 100644
--- a/src/Symfony/Component/Lock/Store/ZookeeperStore.php
+++ b/src/Symfony/Component/Lock/Store/ZookeeperStore.php
@@ -127,8 +127,8 @@ private function getKeyResource(Key $key): string
// For example: foo/bar will become /foo-bar and /foo/bar will become /-foo-bar
$resource = (string) $key;
- if (false !== \strpos($resource, '/')) {
- $resource = \strtr($resource, ['/' => '-']).'-'.sha1($resource);
+ if (false !== strpos($resource, '/')) {
+ $resource = strtr($resource, ['/' => '-']).'-'.sha1($resource);
}
if ('' === $resource) {
diff --git a/src/Symfony/Component/Lock/Tests/Store/ExpiringStoreTestTrait.php b/src/Symfony/Component/Lock/Tests/Store/ExpiringStoreTestTrait.php
index f523780ce1444..bc96ff66f5dfb 100644
--- a/src/Symfony/Component/Lock/Tests/Store/ExpiringStoreTestTrait.php
+++ b/src/Symfony/Component/Lock/Tests/Store/ExpiringStoreTestTrait.php
@@ -11,6 +11,7 @@
namespace Symfony\Component\Lock\Tests\Store;
+use Symfony\Component\Lock\Exception\LockExpiredException;
use Symfony\Component\Lock\Key;
use Symfony\Component\Lock\StoreInterface;
@@ -105,4 +106,28 @@ public function testSetExpiration()
$this->assertGreaterThanOrEqual(0, $key->getRemainingLifetime());
$this->assertLessThanOrEqual(1, $key->getRemainingLifetime());
}
+
+ public function testExpiredLockCleaned()
+ {
+ $resource = uniqid(__METHOD__, true);
+
+ $key1 = new Key($resource);
+ $key2 = new Key($resource);
+
+ /** @var StoreInterface $store */
+ $store = $this->getStore();
+ $key1->reduceLifetime(0);
+
+ $this->assertTrue($key1->isExpired());
+ try {
+ $store->save($key1);
+ $this->fail('The store shouldn\'t have save an expired key');
+ } catch (LockExpiredException $e) {
+ }
+
+ $this->assertFalse($store->exists($key1));
+
+ $store->save($key2);
+ $this->assertTrue($store->exists($key2));
+ }
}
diff --git a/src/Symfony/Component/Messenger/Tests/MessageBusTest.php b/src/Symfony/Component/Messenger/Tests/MessageBusTest.php
index 1d56d1010425e..a1afb97891cc4 100644
--- a/src/Symfony/Component/Messenger/Tests/MessageBusTest.php
+++ b/src/Symfony/Component/Messenger/Tests/MessageBusTest.php
@@ -47,9 +47,9 @@ public function testItCallsMiddleware()
$firstMiddleware->expects($this->once())
->method('handle')
->with($envelope, $this->anything())
- ->will($this->returnCallback(function ($envelope, $stack) {
+ ->willReturnCallback(function ($envelope, $stack) {
return $stack->next()->handle($envelope, $stack);
- }));
+ });
$secondMiddleware = $this->getMockBuilder(MiddlewareInterface::class)->getMock();
$secondMiddleware->expects($this->once())
@@ -76,17 +76,17 @@ public function testThatAMiddlewareCanAddSomeStampsToTheEnvelope()
$firstMiddleware->expects($this->once())
->method('handle')
->with($envelope, $this->anything())
- ->will($this->returnCallback(function ($envelope, $stack) {
+ ->willReturnCallback(function ($envelope, $stack) {
return $stack->next()->handle($envelope->with(new AnEnvelopeStamp()), $stack);
- }));
+ });
$secondMiddleware = $this->getMockBuilder(MiddlewareInterface::class)->getMock();
$secondMiddleware->expects($this->once())
->method('handle')
->with($envelopeWithAnotherStamp, $this->anything())
- ->will($this->returnCallback(function ($envelope, $stack) {
+ ->willReturnCallback(function ($envelope, $stack) {
return $stack->next()->handle($envelope, $stack);
- }));
+ });
$thirdMiddleware = $this->getMockBuilder(MiddlewareInterface::class)->getMock();
$thirdMiddleware->expects($this->once())
@@ -116,9 +116,9 @@ public function testThatAMiddlewareCanUpdateTheMessageWhileKeepingTheEnvelopeSta
$firstMiddleware->expects($this->once())
->method('handle')
->with($envelope, $this->anything())
- ->will($this->returnCallback(function ($envelope, $stack) use ($expectedEnvelope) {
+ ->willReturnCallback(function ($envelope, $stack) use ($expectedEnvelope) {
return $stack->next()->handle($expectedEnvelope, $stack);
- }));
+ });
$secondMiddleware = $this->getMockBuilder(MiddlewareInterface::class)->getMock();
$secondMiddleware->expects($this->once())
diff --git a/src/Symfony/Component/Messenger/Tests/Middleware/TraceableMiddlewareTest.php b/src/Symfony/Component/Messenger/Tests/Middleware/TraceableMiddlewareTest.php
index 35a8ad34f5ca5..9e1c1dcafbe7d 100644
--- a/src/Symfony/Component/Messenger/Tests/Middleware/TraceableMiddlewareTest.php
+++ b/src/Symfony/Component/Messenger/Tests/Middleware/TraceableMiddlewareTest.php
@@ -34,9 +34,9 @@ public function testHandle()
$middleware->expects($this->once())
->method('handle')
->with($envelope, $this->anything())
- ->will($this->returnCallback(function ($envelope, StackInterface $stack) {
+ ->willReturnCallback(function ($envelope, StackInterface $stack) {
return $stack->next()->handle($envelope, $stack);
- }))
+ })
;
$stopwatch = $this->createMock(Stopwatch::class);
diff --git a/src/Symfony/Component/Messenger/Tests/Transport/AmqpExt/Fixtures/long_receiver.php b/src/Symfony/Component/Messenger/Tests/Transport/AmqpExt/Fixtures/long_receiver.php
index a7d4d8dcd758c..92897d2b357d3 100644
--- a/src/Symfony/Component/Messenger/Tests/Transport/AmqpExt/Fixtures/long_receiver.php
+++ b/src/Symfony/Component/Messenger/Tests/Transport/AmqpExt/Fixtures/long_receiver.php
@@ -32,7 +32,7 @@
$worker = new Worker($receiver, new class() implements MessageBusInterface {
public function dispatch($envelope): Envelope
{
- echo 'Get envelope with message: '.\get_class($envelope->getMessage())."\n";
+ echo 'Get envelope with message: '.get_class($envelope->getMessage())."\n";
echo sprintf("with stamps: %s\n", json_encode(array_keys($envelope->all()), JSON_PRETTY_PRINT));
sleep(30);
diff --git a/src/Symfony/Component/Messenger/Transport/AmqpExt/Connection.php b/src/Symfony/Component/Messenger/Transport/AmqpExt/Connection.php
index 19415c7aede7c..abe383c9e344f 100644
--- a/src/Symfony/Component/Messenger/Transport/AmqpExt/Connection.php
+++ b/src/Symfony/Component/Messenger/Transport/AmqpExt/Connection.php
@@ -114,7 +114,7 @@ private static function normalizeQueueArguments(array $arguments): array
continue;
}
- if (!\is_numeric($arguments[$key])) {
+ if (!is_numeric($arguments[$key])) {
throw new InvalidArgumentException(sprintf('Integer expected for queue argument "%s", %s given.', $key, \gettype($arguments[$key])));
}
diff --git a/src/Symfony/Component/Messenger/Transport/Receiver/StopWhenMemoryUsageIsExceededReceiver.php b/src/Symfony/Component/Messenger/Transport/Receiver/StopWhenMemoryUsageIsExceededReceiver.php
index e61fe5937af78..929d4e43b281a 100644
--- a/src/Symfony/Component/Messenger/Transport/Receiver/StopWhenMemoryUsageIsExceededReceiver.php
+++ b/src/Symfony/Component/Messenger/Transport/Receiver/StopWhenMemoryUsageIsExceededReceiver.php
@@ -32,7 +32,7 @@ public function __construct(ReceiverInterface $decoratedReceiver, int $memoryLim
$this->memoryLimit = $memoryLimit;
$this->logger = $logger;
$this->memoryResolver = $memoryResolver ?: function () {
- return \memory_get_usage(true);
+ return memory_get_usage(true);
};
}
diff --git a/src/Symfony/Component/OptionsResolver/Options.php b/src/Symfony/Component/OptionsResolver/Options.php
index d18374cb91f6b..d444ec4230d51 100644
--- a/src/Symfony/Component/OptionsResolver/Options.php
+++ b/src/Symfony/Component/OptionsResolver/Options.php
@@ -16,8 +16,6 @@
*
* @author Bernhard Schussek
* @author Tobias Schultze
- *
- * @method mixed offsetGet(string $option, bool $triggerDeprecation = true)
*/
interface Options extends \ArrayAccess, \Countable
{
diff --git a/src/Symfony/Component/OptionsResolver/OptionsResolver.php b/src/Symfony/Component/OptionsResolver/OptionsResolver.php
index eb0a6c2480601..7b9adc44f2d4f 100644
--- a/src/Symfony/Component/OptionsResolver/OptionsResolver.php
+++ b/src/Symfony/Component/OptionsResolver/OptionsResolver.php
@@ -797,7 +797,7 @@ public function offsetGet($option/*, bool $triggerDeprecation = true*/)
throw new AccessException('Array access is only supported within closures of lazy options and normalizers.');
}
- $triggerDeprecation = 1 === \func_num_args() || \func_get_arg(1);
+ $triggerDeprecation = 1 === \func_num_args() || func_get_arg(1);
// Shortcut for resolved options
if (isset($this->resolved[$option]) || \array_key_exists($option, $this->resolved)) {
diff --git a/src/Symfony/Component/Process/Tests/ProcessFailedExceptionTest.php b/src/Symfony/Component/Process/Tests/ProcessFailedExceptionTest.php
index 2467c960e8408..ba085bdd84f65 100644
--- a/src/Symfony/Component/Process/Tests/ProcessFailedExceptionTest.php
+++ b/src/Symfony/Component/Process/Tests/ProcessFailedExceptionTest.php
@@ -27,7 +27,7 @@ public function testProcessFailedExceptionThrowsException()
$process = $this->getMockBuilder('Symfony\Component\Process\Process')->setMethods(['isSuccessful'])->setConstructorArgs([['php']])->getMock();
$process->expects($this->once())
->method('isSuccessful')
- ->will($this->returnValue(true));
+ ->willReturn(true);
if (method_exists($this, 'expectException')) {
$this->expectException(\InvalidArgumentException::class);
@@ -55,31 +55,31 @@ public function testProcessFailedExceptionPopulatesInformationFromProcessOutput(
$process = $this->getMockBuilder('Symfony\Component\Process\Process')->setMethods(['isSuccessful', 'getOutput', 'getErrorOutput', 'getExitCode', 'getExitCodeText', 'isOutputDisabled', 'getWorkingDirectory'])->setConstructorArgs([[$cmd]])->getMock();
$process->expects($this->once())
->method('isSuccessful')
- ->will($this->returnValue(false));
+ ->willReturn(false);
$process->expects($this->once())
->method('getOutput')
- ->will($this->returnValue($output));
+ ->willReturn($output);
$process->expects($this->once())
->method('getErrorOutput')
- ->will($this->returnValue($errorOutput));
+ ->willReturn($errorOutput);
$process->expects($this->once())
->method('getExitCode')
- ->will($this->returnValue($exitCode));
+ ->willReturn($exitCode);
$process->expects($this->once())
->method('getExitCodeText')
- ->will($this->returnValue($exitText));
+ ->willReturn($exitText);
$process->expects($this->once())
->method('isOutputDisabled')
- ->will($this->returnValue(false));
+ ->willReturn(false);
$process->expects($this->once())
->method('getWorkingDirectory')
- ->will($this->returnValue($workingDirectory));
+ ->willReturn($workingDirectory);
$exception = new ProcessFailedException($process);
@@ -103,7 +103,7 @@ public function testDisabledOutputInFailedExceptionDoesNotPopulateOutput()
$process = $this->getMockBuilder('Symfony\Component\Process\Process')->setMethods(['isSuccessful', 'isOutputDisabled', 'getExitCode', 'getExitCodeText', 'getOutput', 'getErrorOutput', 'getWorkingDirectory'])->setConstructorArgs([[$cmd]])->getMock();
$process->expects($this->once())
->method('isSuccessful')
- ->will($this->returnValue(false));
+ ->willReturn(false);
$process->expects($this->never())
->method('getOutput');
@@ -113,19 +113,19 @@ public function testDisabledOutputInFailedExceptionDoesNotPopulateOutput()
$process->expects($this->once())
->method('getExitCode')
- ->will($this->returnValue($exitCode));
+ ->willReturn($exitCode);
$process->expects($this->once())
->method('getExitCodeText')
- ->will($this->returnValue($exitText));
+ ->willReturn($exitText);
$process->expects($this->once())
->method('isOutputDisabled')
- ->will($this->returnValue(true));
+ ->willReturn(true);
$process->expects($this->once())
->method('getWorkingDirectory')
- ->will($this->returnValue($workingDirectory));
+ ->willReturn($workingDirectory);
$exception = new ProcessFailedException($process);
diff --git a/src/Symfony/Component/PropertyAccess/PropertyAccessorInterface.php b/src/Symfony/Component/PropertyAccess/PropertyAccessorInterface.php
index 51fa0cc76f7db..aa81bfc42d983 100644
--- a/src/Symfony/Component/PropertyAccess/PropertyAccessorInterface.php
+++ b/src/Symfony/Component/PropertyAccess/PropertyAccessorInterface.php
@@ -58,7 +58,7 @@ public function setValue(&$objectOrArray, $propertyPath, $value);
*
* $propertyAccessor = PropertyAccess::createPropertyAccessor();
*
- * echo $propertyAccessor->getValue($object, 'child.name);
+ * echo $propertyAccessor->getValue($object, 'child.name');
* // equals echo $object->getChild()->getName();
*
* This method first tries to find a public getter for each property in the
diff --git a/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorCollectionTest.php b/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorCollectionTest.php
index 1aee259a76c8f..b91d1e62ebb95 100644
--- a/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorCollectionTest.php
+++ b/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorCollectionTest.php
@@ -128,11 +128,11 @@ public function testSetValueCallsAdderAndRemoverForNestedCollections()
$car->expects($this->any())
->method('getStructure')
- ->will($this->returnValue($structure));
+ ->willReturn($structure);
$structure->expects($this->at(0))
->method('getAxes')
- ->will($this->returnValue($axesBefore));
+ ->willReturn($axesBefore);
$structure->expects($this->at(1))
->method('removeAxis')
->with('fourth');
@@ -158,7 +158,7 @@ public function testSetValueFailsIfNoAdderNorRemoverFound()
$car->expects($this->any())
->method('getAxes')
- ->will($this->returnValue($axesBefore));
+ ->willReturn($axesBefore);
$this->propertyAccessor->setValue($car, 'axes', $axesAfter);
}
diff --git a/src/Symfony/Component/Routing/Generator/UrlGenerator.php b/src/Symfony/Component/Routing/Generator/UrlGenerator.php
index 1bc720bbbaadb..462caf0c07358 100644
--- a/src/Symfony/Component/Routing/Generator/UrlGenerator.php
+++ b/src/Symfony/Component/Routing/Generator/UrlGenerator.php
@@ -239,16 +239,18 @@ protected function doGenerate($variables, $defaults, $requirements, $tokens, $pa
}
}
- if ((self::ABSOLUTE_URL === $referenceType || self::NETWORK_PATH === $referenceType) && !empty($host)) {
- $port = '';
- if ('http' === $scheme && 80 != $this->context->getHttpPort()) {
- $port = ':'.$this->context->getHttpPort();
- } elseif ('https' === $scheme && 443 != $this->context->getHttpsPort()) {
- $port = ':'.$this->context->getHttpsPort();
- }
+ if (self::ABSOLUTE_URL === $referenceType || self::NETWORK_PATH === $referenceType) {
+ if ('' !== $host || ('' !== $scheme && 'http' !== $scheme && 'https' !== $scheme)) {
+ $port = '';
+ if ('http' === $scheme && 80 !== $this->context->getHttpPort()) {
+ $port = ':'.$this->context->getHttpPort();
+ } elseif ('https' === $scheme && 443 !== $this->context->getHttpsPort()) {
+ $port = ':'.$this->context->getHttpsPort();
+ }
- $schemeAuthority = self::NETWORK_PATH === $referenceType ? '//' : "$scheme://";
- $schemeAuthority .= $host.$port;
+ $schemeAuthority = self::NETWORK_PATH === $referenceType || '' === $scheme ? '//' : "$scheme://";
+ $schemeAuthority .= $host.$port;
+ }
}
if (self::RELATIVE_PATH === $referenceType) {
diff --git a/src/Symfony/Component/Routing/Generator/UrlGeneratorInterface.php b/src/Symfony/Component/Routing/Generator/UrlGeneratorInterface.php
index f7d37b2564b12..64714d354dba2 100644
--- a/src/Symfony/Component/Routing/Generator/UrlGeneratorInterface.php
+++ b/src/Symfony/Component/Routing/Generator/UrlGeneratorInterface.php
@@ -71,9 +71,9 @@ interface UrlGeneratorInterface extends RequestContextAwareInterface
*
* The special parameter _fragment will be used as the document fragment suffixed to the final URL.
*
- * @param string $name The name of the route
- * @param mixed $parameters An array of parameters
- * @param int $referenceType The type of reference to be generated (one of the constants)
+ * @param string $name The name of the route
+ * @param mixed[] $parameters An array of parameters
+ * @param int $referenceType The type of reference to be generated (one of the constants)
*
* @return string The generated URL
*
diff --git a/src/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php b/src/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php
index c7cfb2852e178..fe7baf4d9833c 100644
--- a/src/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php
+++ b/src/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php
@@ -579,28 +579,27 @@ public function testHostIsCaseInsensitive()
public function testDefaultHostIsUsedWhenContextHostIsEmpty()
{
- $routes = $this->getRoutes('test', new Route('/route', ['domain' => 'my.fallback.host'], ['domain' => '.+'], [], '{domain}', ['http']));
+ $routes = $this->getRoutes('test', new Route('/path', ['domain' => 'my.fallback.host'], ['domain' => '.+'], [], '{domain}'));
$generator = $this->getGenerator($routes);
$generator->getContext()->setHost('');
- $this->assertSame('http://my.fallback.host/app.php/route', $generator->generate('test', [], UrlGeneratorInterface::ABSOLUTE_URL));
+ $this->assertSame('http://my.fallback.host/app.php/path', $generator->generate('test', [], UrlGeneratorInterface::ABSOLUTE_URL));
}
- public function testDefaultHostIsUsedWhenContextHostIsEmptyAndSchemeIsNot()
+ public function testDefaultHostIsUsedWhenContextHostIsEmptyAndPathReferenceType()
{
- $routes = $this->getRoutes('test', new Route('/route', ['domain' => 'my.fallback.host'], ['domain' => '.+'], [], '{domain}', ['http', 'https']));
+ $routes = $this->getRoutes('test', new Route('/path', ['domain' => 'my.fallback.host'], ['domain' => '.+'], [], '{domain}'));
$generator = $this->getGenerator($routes);
$generator->getContext()->setHost('');
- $generator->getContext()->setScheme('https');
- $this->assertSame('https://my.fallback.host/app.php/route', $generator->generate('test', [], UrlGeneratorInterface::ABSOLUTE_URL));
+ $this->assertSame('//my.fallback.host/app.php/path', $generator->generate('test', [], UrlGeneratorInterface::ABSOLUTE_PATH));
}
- public function testAbsoluteUrlFallbackToRelativeIfHostIsEmptyAndSchemeIsNot()
+ public function testAbsoluteUrlFallbackToPathIfHostIsEmptyAndSchemeIsHttp()
{
- $routes = $this->getRoutes('test', new Route('/route', [], [], [], '', ['http', 'https']));
+ $routes = $this->getRoutes('test', new Route('/route'));
$generator = $this->getGenerator($routes);
$generator->getContext()->setHost('');
@@ -609,6 +608,39 @@ public function testAbsoluteUrlFallbackToRelativeIfHostIsEmptyAndSchemeIsNot()
$this->assertSame('/app.php/route', $generator->generate('test', [], UrlGeneratorInterface::ABSOLUTE_URL));
}
+ public function testAbsoluteUrlFallbackToNetworkIfSchemeIsEmptyAndHostIsNot()
+ {
+ $routes = $this->getRoutes('test', new Route('/path'));
+
+ $generator = $this->getGenerator($routes);
+ $generator->getContext()->setHost('example.com');
+ $generator->getContext()->setScheme('');
+
+ $this->assertSame('//example.com/app.php/path', $generator->generate('test', [], UrlGeneratorInterface::ABSOLUTE_URL));
+ }
+
+ public function testAbsoluteUrlFallbackToPathIfSchemeAndHostAreEmpty()
+ {
+ $routes = $this->getRoutes('test', new Route('/path'));
+
+ $generator = $this->getGenerator($routes);
+ $generator->getContext()->setHost('');
+ $generator->getContext()->setScheme('');
+
+ $this->assertSame('/app.php/path', $generator->generate('test', [], UrlGeneratorInterface::ABSOLUTE_URL));
+ }
+
+ public function testAbsoluteUrlWithNonHttpSchemeAndEmptyHost()
+ {
+ $routes = $this->getRoutes('test', new Route('/path', [], [], [], '', ['file']));
+
+ $generator = $this->getGenerator($routes);
+ $generator->getContext()->setBaseUrl('');
+ $generator->getContext()->setHost('');
+
+ $this->assertSame('file:///path', $generator->generate('test', [], UrlGeneratorInterface::ABSOLUTE_URL));
+ }
+
public function testGenerateNetworkPath()
{
$routes = $this->getRoutes('test', new Route('/{name}', [], [], [], '{locale}.example.com', ['http']));
diff --git a/src/Symfony/Component/Routing/Tests/Loader/AnnotationClassLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/AnnotationClassLoaderTest.php
index 40c9219a1aa5e..2a61e2b3d90af 100644
--- a/src/Symfony/Component/Routing/Tests/Loader/AnnotationClassLoaderTest.php
+++ b/src/Symfony/Component/Routing/Tests/Loader/AnnotationClassLoaderTest.php
@@ -205,12 +205,12 @@ public function testInvokableClassMultipleRouteLoad()
$reader
->expects($this->exactly(1))
->method('getClassAnnotations')
- ->will($this->returnValue([new RouteAnnotation($classRouteData1), new RouteAnnotation($classRouteData2)]))
+ ->willReturn([new RouteAnnotation($classRouteData1), new RouteAnnotation($classRouteData2)])
;
$reader
->expects($this->once())
->method('getMethodAnnotations')
- ->will($this->returnValue([]))
+ ->willReturn([])
;
$loader = new class($reader) extends AnnotationClassLoader {
protected function configureRoute(Route $route, \ReflectionClass $class, \ReflectionMethod $method, $annot)
@@ -291,7 +291,7 @@ public function testDefaultRouteName()
$reader
->expects($this->once())
->method('getMethodAnnotations')
- ->will($this->returnValue([new RouteAnnotation($methodRouteData)]))
+ ->willReturn([new RouteAnnotation($methodRouteData)])
;
$loader = new class($reader) extends AnnotationClassLoader {
diff --git a/src/Symfony/Component/Routing/Tests/Loader/AnnotationDirectoryLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/AnnotationDirectoryLoaderTest.php
index 9465ef05df23c..df96a679e40f9 100644
--- a/src/Symfony/Component/Routing/Tests/Loader/AnnotationDirectoryLoaderTest.php
+++ b/src/Symfony/Component/Routing/Tests/Loader/AnnotationDirectoryLoaderTest.php
@@ -34,13 +34,13 @@ public function testLoad()
$this->reader
->expects($this->any())
->method('getMethodAnnotations')
- ->will($this->returnValue([]))
+ ->willReturn([])
;
$this->reader
->expects($this->any())
->method('getClassAnnotations')
- ->will($this->returnValue([]))
+ ->willReturn([])
;
$this->loader->load(__DIR__.'/../Fixtures/AnnotatedClasses');
@@ -58,13 +58,13 @@ public function testLoadIgnoresHiddenDirectories()
$this->reader
->expects($this->any())
->method('getMethodAnnotations')
- ->will($this->returnValue([]))
+ ->willReturn([])
;
$this->reader
->expects($this->any())
->method('getClassAnnotations')
- ->will($this->returnValue([]))
+ ->willReturn([])
;
$this->loader->load(__DIR__.'/../Fixtures/AnnotatedClasses');
@@ -93,7 +93,7 @@ public function testLoadFileIfLocatedResourceIsFile()
$this->reader
->expects($this->any())
->method('getMethodAnnotations')
- ->will($this->returnValue([]))
+ ->willReturn([])
;
$this->loader->load(__DIR__.'/../Fixtures/AnnotatedClasses/FooClass.php');
diff --git a/src/Symfony/Component/Routing/Tests/Loader/AnnotationFileLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/AnnotationFileLoaderTest.php
index e3c1a3318bb76..b52deaf70c8b1 100644
--- a/src/Symfony/Component/Routing/Tests/Loader/AnnotationFileLoaderTest.php
+++ b/src/Symfony/Component/Routing/Tests/Loader/AnnotationFileLoaderTest.php
@@ -56,7 +56,7 @@ public function testLoadVariadic()
$route = new Route(['path' => '/path/to/{id}']);
$this->reader->expects($this->once())->method('getClassAnnotation');
$this->reader->expects($this->once())->method('getMethodAnnotations')
- ->will($this->returnValue([$route]));
+ ->willReturn([$route]);
$this->loader->load(__DIR__.'/../Fixtures/OtherAnnotatedClasses/VariadicClass.php');
}
diff --git a/src/Symfony/Component/Routing/Tests/Loader/ObjectRouteLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/ObjectRouteLoaderTest.php
index 0e9289bee467d..a67e98420fdd0 100644
--- a/src/Symfony/Component/Routing/Tests/Loader/ObjectRouteLoaderTest.php
+++ b/src/Symfony/Component/Routing/Tests/Loader/ObjectRouteLoaderTest.php
@@ -114,7 +114,7 @@ public function testExceptionOnMethodNotReturningCollection()
->getMock();
$service->expects($this->once())
->method('loadRoutes')
- ->will($this->returnValue('NOT_A_COLLECTION'));
+ ->willReturn('NOT_A_COLLECTION');
$loader = new ObjectRouteLoaderForTest();
$loader->loaderMap = ['my_service' => $service];
diff --git a/src/Symfony/Component/Routing/Tests/Matcher/RedirectableUrlMatcherTest.php b/src/Symfony/Component/Routing/Tests/Matcher/RedirectableUrlMatcherTest.php
index f5ac21db90f3c..426958e07ef59 100644
--- a/src/Symfony/Component/Routing/Tests/Matcher/RedirectableUrlMatcherTest.php
+++ b/src/Symfony/Component/Routing/Tests/Matcher/RedirectableUrlMatcherTest.php
@@ -23,7 +23,7 @@ public function testMissingTrailingSlash()
$coll->add('foo', new Route('/foo/'));
$matcher = $this->getUrlMatcher($coll);
- $matcher->expects($this->once())->method('redirect')->will($this->returnValue([]));
+ $matcher->expects($this->once())->method('redirect')->willReturn([]);
$matcher->match('/foo');
}
@@ -33,7 +33,7 @@ public function testExtraTrailingSlash()
$coll->add('foo', new Route('/foo'));
$matcher = $this->getUrlMatcher($coll);
- $matcher->expects($this->once())->method('redirect')->will($this->returnValue([]));
+ $matcher->expects($this->once())->method('redirect')->willReturn([]);
$matcher->match('/foo/');
}
@@ -61,7 +61,7 @@ public function testSchemeRedirectRedirectsToFirstScheme()
->expects($this->once())
->method('redirect')
->with('/foo', 'foo', 'ftp')
- ->will($this->returnValue(['_route' => 'foo']))
+ ->willReturn(['_route' => 'foo'])
;
$matcher->match('/foo');
}
@@ -88,7 +88,7 @@ public function testSchemeRedirectWithParams()
->expects($this->once())
->method('redirect')
->with('/foo/baz', 'foo', 'https')
- ->will($this->returnValue(['redirect' => 'value']))
+ ->willReturn(['redirect' => 'value'])
;
$this->assertEquals(['_route' => 'foo', 'bar' => 'baz', 'redirect' => 'value'], $matcher->match('/foo/baz'));
}
@@ -103,7 +103,7 @@ public function testSchemeRedirectForRoot()
->expects($this->once())
->method('redirect')
->with('/', 'foo', 'https')
- ->will($this->returnValue(['redirect' => 'value']));
+ ->willReturn(['redirect' => 'value']);
$this->assertEquals(['_route' => 'foo', 'redirect' => 'value'], $matcher->match('/'));
}
@@ -117,7 +117,7 @@ public function testSlashRedirectWithParams()
->expects($this->once())
->method('redirect')
->with('/foo/baz/', 'foo', null)
- ->will($this->returnValue(['redirect' => 'value']))
+ ->willReturn(['redirect' => 'value'])
;
$this->assertEquals(['_route' => 'foo', 'bar' => 'baz', 'redirect' => 'value'], $matcher->match('/foo/baz'));
}
@@ -148,7 +148,7 @@ public function testFallbackPage()
$coll->add('bar', new Route('/{name}'));
$matcher = $this->getUrlMatcher($coll);
- $matcher->expects($this->once())->method('redirect')->with('/foo/', 'foo')->will($this->returnValue(['_route' => 'foo']));
+ $matcher->expects($this->once())->method('redirect')->with('/foo/', 'foo')->willReturn(['_route' => 'foo']);
$this->assertSame(['_route' => 'foo'], $matcher->match('/foo'));
$coll = new RouteCollection();
@@ -156,7 +156,7 @@ public function testFallbackPage()
$coll->add('bar', new Route('/{name}/'));
$matcher = $this->getUrlMatcher($coll);
- $matcher->expects($this->once())->method('redirect')->with('/foo', 'foo')->will($this->returnValue(['_route' => 'foo']));
+ $matcher->expects($this->once())->method('redirect')->with('/foo', 'foo')->willReturn(['_route' => 'foo']);
$this->assertSame(['_route' => 'foo'], $matcher->match('/foo/'));
}
@@ -166,7 +166,7 @@ public function testMissingTrailingSlashAndScheme()
$coll->add('foo', (new Route('/foo/'))->setSchemes(['https']));
$matcher = $this->getUrlMatcher($coll);
- $matcher->expects($this->once())->method('redirect')->with('/foo/', 'foo', 'https')->will($this->returnValue([]));
+ $matcher->expects($this->once())->method('redirect')->with('/foo/', 'foo', 'https')->willReturn([]);
$matcher->match('/foo');
}
diff --git a/src/Symfony/Component/Routing/Tests/RouteCollectionBuilderTest.php b/src/Symfony/Component/Routing/Tests/RouteCollectionBuilderTest.php
index 20afdff484f8a..11d9453e09093 100644
--- a/src/Symfony/Component/Routing/Tests/RouteCollectionBuilderTest.php
+++ b/src/Symfony/Component/Routing/Tests/RouteCollectionBuilderTest.php
@@ -28,7 +28,7 @@ public function testImport()
$resolver->expects($this->once())
->method('resolve')
->with('admin_routing.yml', 'yaml')
- ->will($this->returnValue($resolvedLoader));
+ ->willReturn($resolvedLoader);
$originalRoute = new Route('/foo/path');
$expectedCollection = new RouteCollection();
@@ -39,12 +39,12 @@ public function testImport()
->expects($this->once())
->method('load')
->with('admin_routing.yml', 'yaml')
- ->will($this->returnValue($expectedCollection));
+ ->willReturn($expectedCollection);
$loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock();
$loader->expects($this->any())
->method('getResolver')
- ->will($this->returnValue($resolver));
+ ->willReturn($resolver);
// import the file!
$routes = new RouteCollectionBuilder($loader);
@@ -107,11 +107,11 @@ public function testFlushOrdering()
// make this loader able to do the import - keeps mocking simple
$loader->expects($this->any())
->method('supports')
- ->will($this->returnValue(true));
+ ->willReturn(true);
$loader
->expects($this->once())
->method('load')
- ->will($this->returnValue($importedCollection));
+ ->willReturn($importedCollection);
$routes = new RouteCollectionBuilder($loader);
@@ -296,11 +296,11 @@ public function testFlushSetsPrefixedWithMultipleLevels()
// make this loader able to do the import - keeps mocking simple
$loader->expects($this->any())
->method('supports')
- ->will($this->returnValue(true));
+ ->willReturn(true);
$loader
->expects($this->any())
->method('load')
- ->will($this->returnValue($importedCollection));
+ ->willReturn($importedCollection);
// import this from the /admin route builder
$adminRoutes->import('admin.yml', '/imported');
@@ -347,11 +347,11 @@ public function testAddsThePrefixOnlyOnceWhenLoadingMultipleCollections()
$loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock();
$loader->expects($this->any())
->method('supports')
- ->will($this->returnValue(true));
+ ->willReturn(true);
$loader
->expects($this->any())
->method('load')
- ->will($this->returnValue([$firstCollection, $secondCollection]));
+ ->willReturn([$firstCollection, $secondCollection]);
$routeCollectionBuilder = new RouteCollectionBuilder($loader);
$routeCollectionBuilder->import('/directory/recurse/*', '/other/', 'glob');
diff --git a/src/Symfony/Component/Routing/Tests/RouterTest.php b/src/Symfony/Component/Routing/Tests/RouterTest.php
index 589ce5403ac2b..0f46e5317b68c 100644
--- a/src/Symfony/Component/Routing/Tests/RouterTest.php
+++ b/src/Symfony/Component/Routing/Tests/RouterTest.php
@@ -88,7 +88,7 @@ public function testThatRouteCollectionIsLoaded()
$this->loader->expects($this->once())
->method('load')->with('routing.yml', 'ResourceType')
- ->will($this->returnValue($routeCollection));
+ ->willReturn($routeCollection);
$this->assertSame($routeCollection, $this->router->getRouteCollection());
}
@@ -102,7 +102,7 @@ public function testMatcherIsCreatedIfCacheIsNotConfigured($option)
$this->loader->expects($this->once())
->method('load')->with('routing.yml', null)
- ->will($this->returnValue(new RouteCollection()));
+ ->willReturn(new RouteCollection());
$this->assertInstanceOf('Symfony\\Component\\Routing\\Matcher\\UrlMatcher', $this->router->getMatcher());
}
@@ -124,7 +124,7 @@ public function testGeneratorIsCreatedIfCacheIsNotConfigured($option)
$this->loader->expects($this->once())
->method('load')->with('routing.yml', null)
- ->will($this->returnValue(new RouteCollection()));
+ ->willReturn(new RouteCollection());
$this->assertInstanceOf('Symfony\\Component\\Routing\\Generator\\UrlGenerator', $this->router->getGenerator());
}
diff --git a/src/Symfony/Component/Security/Core/Authentication/Token/AbstractToken.php b/src/Symfony/Component/Security/Core/Authentication/Token/AbstractToken.php
index 9a65709e381ad..50ffe04f46494 100644
--- a/src/Symfony/Component/Security/Core/Authentication/Token/AbstractToken.php
+++ b/src/Symfony/Component/Security/Core/Authentication/Token/AbstractToken.php
@@ -138,7 +138,7 @@ public function serialize()
{
$serialized = [$this->user, $this->authenticated, $this->roles, $this->attributes];
- return $this->doSerialize($serialized, \func_num_args() ? \func_get_arg(0) : null);
+ return $this->doSerialize($serialized, \func_num_args() ? func_get_arg(0) : null);
}
/**
diff --git a/src/Symfony/Component/Security/Core/Authentication/Token/AnonymousToken.php b/src/Symfony/Component/Security/Core/Authentication/Token/AnonymousToken.php
index 328d3043d27ca..07b8fe4442929 100644
--- a/src/Symfony/Component/Security/Core/Authentication/Token/AnonymousToken.php
+++ b/src/Symfony/Component/Security/Core/Authentication/Token/AnonymousToken.php
@@ -61,7 +61,7 @@ public function serialize()
{
$serialized = [$this->secret, parent::serialize(true)];
- return $this->doSerialize($serialized, \func_num_args() ? \func_get_arg(0) : null);
+ return $this->doSerialize($serialized, \func_num_args() ? func_get_arg(0) : null);
}
/**
diff --git a/src/Symfony/Component/Security/Core/Authentication/Token/PreAuthenticatedToken.php b/src/Symfony/Component/Security/Core/Authentication/Token/PreAuthenticatedToken.php
index bc6c0ce5224b5..8f32778b4dfae 100644
--- a/src/Symfony/Component/Security/Core/Authentication/Token/PreAuthenticatedToken.php
+++ b/src/Symfony/Component/Security/Core/Authentication/Token/PreAuthenticatedToken.php
@@ -81,7 +81,7 @@ public function serialize()
{
$serialized = [$this->credentials, $this->providerKey, parent::serialize(true)];
- return $this->doSerialize($serialized, \func_num_args() ? \func_get_arg(0) : null);
+ return $this->doSerialize($serialized, \func_num_args() ? func_get_arg(0) : null);
}
/**
diff --git a/src/Symfony/Component/Security/Core/Authentication/Token/RememberMeToken.php b/src/Symfony/Component/Security/Core/Authentication/Token/RememberMeToken.php
index 21a190d6b38da..dcf3879749e0c 100644
--- a/src/Symfony/Component/Security/Core/Authentication/Token/RememberMeToken.php
+++ b/src/Symfony/Component/Security/Core/Authentication/Token/RememberMeToken.php
@@ -96,7 +96,7 @@ public function serialize()
{
$serialized = [$this->secret, $this->providerKey, parent::serialize(true)];
- return $this->doSerialize($serialized, \func_num_args() ? \func_get_arg(0) : null);
+ return $this->doSerialize($serialized, \func_num_args() ? func_get_arg(0) : null);
}
/**
diff --git a/src/Symfony/Component/Security/Core/Authentication/Token/UsernamePasswordToken.php b/src/Symfony/Component/Security/Core/Authentication/Token/UsernamePasswordToken.php
index 8a70047a48e75..5e614bcbfbb70 100644
--- a/src/Symfony/Component/Security/Core/Authentication/Token/UsernamePasswordToken.php
+++ b/src/Symfony/Component/Security/Core/Authentication/Token/UsernamePasswordToken.php
@@ -93,7 +93,7 @@ public function serialize()
{
$serialized = [$this->credentials, $this->providerKey, parent::serialize(true)];
- return $this->doSerialize($serialized, \func_num_args() ? \func_get_arg(0) : null);
+ return $this->doSerialize($serialized, \func_num_args() ? func_get_arg(0) : null);
}
/**
diff --git a/src/Symfony/Component/Security/Core/Encoder/Argon2iPasswordEncoder.php b/src/Symfony/Component/Security/Core/Encoder/Argon2iPasswordEncoder.php
index 333d3ddb1165a..df6d40ce55d0b 100644
--- a/src/Symfony/Component/Security/Core/Encoder/Argon2iPasswordEncoder.php
+++ b/src/Symfony/Component/Security/Core/Encoder/Argon2iPasswordEncoder.php
@@ -47,10 +47,6 @@ public static function isSupported()
return true;
}
- if (\class_exists('ParagonIE_Sodium_Compat') && \method_exists('ParagonIE_Sodium_Compat', 'crypto_pwhash_is_available')) {
- return \ParagonIE_Sodium_Compat::crypto_pwhash_is_available();
- }
-
return \function_exists('sodium_crypto_pwhash_str') || \extension_loaded('libsodium');
}
@@ -87,8 +83,8 @@ public function isPasswordValid($encoded, $raw, $salt)
return !$this->isPasswordTooLong($raw) && password_verify($raw, $encoded);
}
if (\function_exists('sodium_crypto_pwhash_str_verify')) {
- $valid = !$this->isPasswordTooLong($raw) && \sodium_crypto_pwhash_str_verify($encoded, $raw);
- \sodium_memzero($raw);
+ $valid = !$this->isPasswordTooLong($raw) && sodium_crypto_pwhash_str_verify($encoded, $raw);
+ sodium_memzero($raw);
return $valid;
}
@@ -109,12 +105,12 @@ private function encodePasswordNative($raw)
private function encodePasswordSodiumFunction($raw)
{
- $hash = \sodium_crypto_pwhash_str(
+ $hash = sodium_crypto_pwhash_str(
$raw,
\SODIUM_CRYPTO_PWHASH_OPSLIMIT_INTERACTIVE,
\SODIUM_CRYPTO_PWHASH_MEMLIMIT_INTERACTIVE
);
- \sodium_memzero($raw);
+ sodium_memzero($raw);
return $hash;
}
diff --git a/src/Symfony/Component/Security/Core/Encoder/BasePasswordEncoder.php b/src/Symfony/Component/Security/Core/Encoder/BasePasswordEncoder.php
index 3c3ea1aa17366..3a5c4f0c4ba81 100644
--- a/src/Symfony/Component/Security/Core/Encoder/BasePasswordEncoder.php
+++ b/src/Symfony/Component/Security/Core/Encoder/BasePasswordEncoder.php
@@ -48,8 +48,8 @@ protected function demergePasswordAndSalt($mergedPasswordSalt)
/**
* Merges a password and a salt.
*
- * @param string $password The password to be used
- * @param string $salt The salt to be used
+ * @param string $password The password to be used
+ * @param string|null $salt The salt to be used
*
* @return string a merged password and salt
*
diff --git a/src/Symfony/Component/Security/Core/Encoder/PasswordEncoderInterface.php b/src/Symfony/Component/Security/Core/Encoder/PasswordEncoderInterface.php
index e0573051eb273..03cdaca44aef7 100644
--- a/src/Symfony/Component/Security/Core/Encoder/PasswordEncoderInterface.php
+++ b/src/Symfony/Component/Security/Core/Encoder/PasswordEncoderInterface.php
@@ -23,8 +23,8 @@ interface PasswordEncoderInterface
/**
* Encodes the raw password.
*
- * @param string $raw The password to encode
- * @param string $salt The salt
+ * @param string $raw The password to encode
+ * @param string|null $salt The salt
*
* @return string The encoded password
*
@@ -36,9 +36,9 @@ public function encodePassword($raw, $salt);
/**
* Checks a raw password against an encoded password.
*
- * @param string $encoded An encoded password
- * @param string $raw A raw password
- * @param string $salt The salt
+ * @param string $encoded An encoded password
+ * @param string $raw A raw password
+ * @param string|null $salt The salt
*
* @return bool true if the password is valid, false otherwise
*
diff --git a/src/Symfony/Component/Security/Core/Exception/AccountStatusException.php b/src/Symfony/Component/Security/Core/Exception/AccountStatusException.php
index cb91b42364bc4..60aea70269a68 100644
--- a/src/Symfony/Component/Security/Core/Exception/AccountStatusException.php
+++ b/src/Symfony/Component/Security/Core/Exception/AccountStatusException.php
@@ -46,7 +46,7 @@ public function serialize()
{
$serialized = [$this->user, parent::serialize(true)];
- return $this->doSerialize($serialized, \func_num_args() ? \func_get_arg(0) : null);
+ return $this->doSerialize($serialized, \func_num_args() ? func_get_arg(0) : null);
}
/**
diff --git a/src/Symfony/Component/Security/Core/Exception/AuthenticationException.php b/src/Symfony/Component/Security/Core/Exception/AuthenticationException.php
index a8989c068702b..8894731db4dce 100644
--- a/src/Symfony/Component/Security/Core/Exception/AuthenticationException.php
+++ b/src/Symfony/Component/Security/Core/Exception/AuthenticationException.php
@@ -26,7 +26,7 @@ class AuthenticationException extends RuntimeException implements \Serializable
/**
* Get the token.
*
- * @return TokenInterface
+ * @return TokenInterface|null
*/
public function getToken()
{
@@ -51,7 +51,7 @@ public function serialize()
$this->line,
];
- return $this->doSerialize($serialized, \func_num_args() ? \func_get_arg(0) : null);
+ return $this->doSerialize($serialized, \func_num_args() ? func_get_arg(0) : null);
}
/**
diff --git a/src/Symfony/Component/Security/Core/Exception/CustomUserMessageAuthenticationException.php b/src/Symfony/Component/Security/Core/Exception/CustomUserMessageAuthenticationException.php
index 5db47013d454d..41732f275a227 100644
--- a/src/Symfony/Component/Security/Core/Exception/CustomUserMessageAuthenticationException.php
+++ b/src/Symfony/Component/Security/Core/Exception/CustomUserMessageAuthenticationException.php
@@ -62,7 +62,7 @@ public function serialize()
{
$serialized = [parent::serialize(true), $this->messageKey, $this->messageData];
- return $this->doSerialize($serialized, \func_num_args() ? \func_get_arg(0) : null);
+ return $this->doSerialize($serialized, \func_num_args() ? func_get_arg(0) : null);
}
/**
diff --git a/src/Symfony/Component/Security/Core/Exception/UsernameNotFoundException.php b/src/Symfony/Component/Security/Core/Exception/UsernameNotFoundException.php
index b4b8047f341f9..c5e517d01d612 100644
--- a/src/Symfony/Component/Security/Core/Exception/UsernameNotFoundException.php
+++ b/src/Symfony/Component/Security/Core/Exception/UsernameNotFoundException.php
@@ -56,7 +56,7 @@ public function serialize()
{
$serialized = [$this->username, parent::serialize(true)];
- return $this->doSerialize($serialized, \func_num_args() ? \func_get_arg(0) : null);
+ return $this->doSerialize($serialized, \func_num_args() ? func_get_arg(0) : null);
}
/**
diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/AuthenticationProviderManagerTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/AuthenticationProviderManagerTest.php
index fd2de0ca25d4e..379da4bb61329 100644
--- a/src/Symfony/Component/Security/Core/Tests/Authentication/AuthenticationProviderManagerTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/Authentication/AuthenticationProviderManagerTest.php
@@ -177,13 +177,13 @@ protected function getAuthenticationProvider($supports, $token = null, $exceptio
$provider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface')->getMock();
$provider->expects($this->once())
->method('supports')
- ->will($this->returnValue($supports))
+ ->willReturn($supports)
;
if (null !== $token) {
$provider->expects($this->once())
->method('authenticate')
- ->will($this->returnValue($token))
+ ->willReturn($token)
;
} elseif (null !== $exception) {
$provider->expects($this->once())
diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/AnonymousAuthenticationProviderTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/AnonymousAuthenticationProviderTest.php
index 92441ba5fc617..a888d2bf81b9d 100644
--- a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/AnonymousAuthenticationProviderTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/AnonymousAuthenticationProviderTest.php
@@ -58,7 +58,7 @@ protected function getSupportedToken($secret)
$token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\AnonymousToken')->setMethods(['getSecret'])->disableOriginalConstructor()->getMock();
$token->expects($this->any())
->method('getSecret')
- ->will($this->returnValue($secret))
+ ->willReturn($secret)
;
return $token;
diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/DaoAuthenticationProviderTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/DaoAuthenticationProviderTest.php
index 55814a994c577..53ff170554222 100644
--- a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/DaoAuthenticationProviderTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/DaoAuthenticationProviderTest.php
@@ -77,7 +77,7 @@ public function testRetrieveUserReturnsUserFromTokenOnReauthentication()
$token = $this->getSupportedToken();
$token->expects($this->once())
->method('getUser')
- ->will($this->returnValue($user))
+ ->willReturn($user)
;
$provider = new DaoAuthenticationProvider($userProvider, $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserCheckerInterface')->getMock(), 'key', $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface')->getMock());
@@ -95,7 +95,7 @@ public function testRetrieveUser()
$userProvider = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface')->getMock();
$userProvider->expects($this->once())
->method('loadUserByUsername')
- ->will($this->returnValue($user))
+ ->willReturn($user)
;
$provider = new DaoAuthenticationProvider($userProvider, $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserCheckerInterface')->getMock(), 'key', $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface')->getMock());
@@ -124,7 +124,7 @@ public function testCheckAuthenticationWhenCredentialsAreEmpty()
$token
->expects($this->once())
->method('getCredentials')
- ->will($this->returnValue(''))
+ ->willReturn('')
;
$method->invoke(
@@ -140,7 +140,7 @@ public function testCheckAuthenticationWhenCredentialsAre0()
$encoder
->expects($this->once())
->method('isPasswordValid')
- ->will($this->returnValue(true))
+ ->willReturn(true)
;
$provider = $this->getProvider(null, null, $encoder);
@@ -151,7 +151,7 @@ public function testCheckAuthenticationWhenCredentialsAre0()
$token
->expects($this->once())
->method('getCredentials')
- ->will($this->returnValue('0'))
+ ->willReturn('0')
;
$method->invoke(
@@ -169,7 +169,7 @@ public function testCheckAuthenticationWhenCredentialsAreNotValid()
$encoder = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\PasswordEncoderInterface')->getMock();
$encoder->expects($this->once())
->method('isPasswordValid')
- ->will($this->returnValue(false))
+ ->willReturn(false)
;
$provider = $this->getProvider(null, null, $encoder);
@@ -179,7 +179,7 @@ public function testCheckAuthenticationWhenCredentialsAreNotValid()
$token = $this->getSupportedToken();
$token->expects($this->once())
->method('getCredentials')
- ->will($this->returnValue('foo'))
+ ->willReturn('foo')
;
$method->invoke($provider, $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock(), $token);
@@ -193,18 +193,18 @@ public function testCheckAuthenticationDoesNotReauthenticateWhenPasswordHasChang
$user = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock();
$user->expects($this->once())
->method('getPassword')
- ->will($this->returnValue('foo'))
+ ->willReturn('foo')
;
$token = $this->getSupportedToken();
$token->expects($this->once())
->method('getUser')
- ->will($this->returnValue($user));
+ ->willReturn($user);
$dbUser = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock();
$dbUser->expects($this->once())
->method('getPassword')
- ->will($this->returnValue('newFoo'))
+ ->willReturn('newFoo')
;
$provider = $this->getProvider();
@@ -218,18 +218,18 @@ public function testCheckAuthenticationWhenTokenNeedsReauthenticationWorksWithou
$user = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock();
$user->expects($this->once())
->method('getPassword')
- ->will($this->returnValue('foo'))
+ ->willReturn('foo')
;
$token = $this->getSupportedToken();
$token->expects($this->once())
->method('getUser')
- ->will($this->returnValue($user));
+ ->willReturn($user);
$dbUser = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock();
$dbUser->expects($this->once())
->method('getPassword')
- ->will($this->returnValue('foo'))
+ ->willReturn('foo')
;
$provider = $this->getProvider();
@@ -243,7 +243,7 @@ public function testCheckAuthentication()
$encoder = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\PasswordEncoderInterface')->getMock();
$encoder->expects($this->once())
->method('isPasswordValid')
- ->will($this->returnValue(true))
+ ->willReturn(true)
;
$provider = $this->getProvider(null, null, $encoder);
@@ -253,7 +253,7 @@ public function testCheckAuthentication()
$token = $this->getSupportedToken();
$token->expects($this->once())
->method('getCredentials')
- ->will($this->returnValue('foo'))
+ ->willReturn('foo')
;
$method->invoke($provider, $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock(), $token);
@@ -265,7 +265,7 @@ protected function getSupportedToken()
$mock
->expects($this->any())
->method('getProviderKey')
- ->will($this->returnValue('key'))
+ ->willReturn('key')
;
return $mock;
@@ -277,7 +277,7 @@ protected function getProvider($user = null, $userChecker = null, $passwordEncod
if (null !== $user) {
$userProvider->expects($this->once())
->method('loadUserByUsername')
- ->will($this->returnValue($user))
+ ->willReturn($user)
;
}
@@ -293,7 +293,7 @@ protected function getProvider($user = null, $userChecker = null, $passwordEncod
$encoderFactory
->expects($this->any())
->method('getEncoder')
- ->will($this->returnValue($passwordEncoder))
+ ->willReturn($passwordEncoder)
;
return new DaoAuthenticationProvider($userProvider, $userChecker, 'key', $encoderFactory);
diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/LdapBindAuthenticationProviderTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/LdapBindAuthenticationProviderTest.php
index ef19bc2c32739..bad3072f4a9af 100644
--- a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/LdapBindAuthenticationProviderTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/LdapBindAuthenticationProviderTest.php
@@ -113,7 +113,7 @@ public function testQueryForDn()
$query
->expects($this->once())
->method('execute')
- ->will($this->returnValue($collection))
+ ->willReturn($collection)
;
$ldap = $this->getMockBuilder(LdapInterface::class)->getMock();
@@ -121,13 +121,13 @@ public function testQueryForDn()
->expects($this->once())
->method('escape')
->with('foo', '')
- ->will($this->returnValue('foo'))
+ ->willReturn('foo')
;
$ldap
->expects($this->once())
->method('query')
->with('{username}', 'foobar')
- ->will($this->returnValue($query))
+ ->willReturn($query)
;
$userChecker = $this->getMockBuilder(UserCheckerInterface::class)->getMock();
@@ -153,14 +153,14 @@ public function testEmptyQueryResultShouldThrowAnException()
$query
->expects($this->once())
->method('execute')
- ->will($this->returnValue($collection))
+ ->willReturn($collection)
;
$ldap = $this->getMockBuilder(LdapInterface::class)->getMock();
$ldap
->expects($this->once())
->method('query')
- ->will($this->returnValue($query))
+ ->willReturn($query)
;
$userChecker = $this->getMockBuilder(UserCheckerInterface::class)->getMock();
diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/PreAuthenticatedAuthenticationProviderTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/PreAuthenticatedAuthenticationProviderTest.php
index a101208d681cc..57bce20f5b20c 100644
--- a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/PreAuthenticatedAuthenticationProviderTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/PreAuthenticatedAuthenticationProviderTest.php
@@ -31,7 +31,7 @@ public function testSupports()
$token
->expects($this->once())
->method('getProviderKey')
- ->will($this->returnValue('foo'))
+ ->willReturn('foo')
;
$this->assertFalse($provider->supports($token));
}
@@ -62,7 +62,7 @@ public function testAuthenticate()
$user
->expects($this->once())
->method('getRoles')
- ->will($this->returnValue([]))
+ ->willReturn([])
;
$provider = $this->getProvider($user);
@@ -99,20 +99,20 @@ protected function getSupportedToken($user = false, $credentials = false)
if (false !== $user) {
$token->expects($this->once())
->method('getUser')
- ->will($this->returnValue($user))
+ ->willReturn($user)
;
}
if (false !== $credentials) {
$token->expects($this->once())
->method('getCredentials')
- ->will($this->returnValue($credentials))
+ ->willReturn($credentials)
;
}
$token
->expects($this->any())
->method('getProviderKey')
- ->will($this->returnValue('key'))
+ ->willReturn('key')
;
$token->setAttributes(['foo' => 'bar']);
@@ -126,7 +126,7 @@ protected function getProvider($user = null, $userChecker = null)
if (null !== $user) {
$userProvider->expects($this->once())
->method('loadUserByUsername')
- ->will($this->returnValue($user))
+ ->willReturn($user)
;
}
diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/RememberMeAuthenticationProviderTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/RememberMeAuthenticationProviderTest.php
index 26287693d6b08..6ac7438a064a2 100644
--- a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/RememberMeAuthenticationProviderTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/RememberMeAuthenticationProviderTest.php
@@ -69,7 +69,7 @@ public function testAuthenticate()
$user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
$user->expects($this->exactly(2))
->method('getRoles')
- ->will($this->returnValue(['ROLE_FOO']));
+ ->willReturn(['ROLE_FOO']);
$provider = $this->getProvider();
@@ -89,14 +89,14 @@ protected function getSupportedToken($user = null, $secret = 'test')
$user
->expects($this->any())
->method('getRoles')
- ->will($this->returnValue([]));
+ ->willReturn([]);
}
$token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\RememberMeToken')->setMethods(['getProviderKey'])->setConstructorArgs([$user, 'foo', $secret])->getMock();
$token
->expects($this->once())
->method('getProviderKey')
- ->will($this->returnValue('foo'));
+ ->willReturn('foo');
return $token;
}
diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/SimpleAuthenticationProviderTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/SimpleAuthenticationProviderTest.php
index 8f36073946a25..995c2c19f8d9e 100644
--- a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/SimpleAuthenticationProviderTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/SimpleAuthenticationProviderTest.php
@@ -32,7 +32,7 @@ public function testAuthenticateWhenPreChecksFails()
$token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
$token->expects($this->any())
->method('getUser')
- ->will($this->returnValue($user));
+ ->willReturn($user);
$userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock();
$userChecker->expects($this->once())
@@ -42,7 +42,7 @@ public function testAuthenticateWhenPreChecksFails()
$authenticator = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface')->getMock();
$authenticator->expects($this->once())
->method('authenticateToken')
- ->will($this->returnValue($token));
+ ->willReturn($token);
$provider = $this->getProvider($authenticator, null, $userChecker);
@@ -59,7 +59,7 @@ public function testAuthenticateWhenPostChecksFails()
$token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
$token->expects($this->any())
->method('getUser')
- ->will($this->returnValue($user));
+ ->willReturn($user);
$userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock();
$userChecker->expects($this->once())
@@ -69,7 +69,7 @@ public function testAuthenticateWhenPostChecksFails()
$authenticator = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface')->getMock();
$authenticator->expects($this->once())
->method('authenticateToken')
- ->will($this->returnValue($token));
+ ->willReturn($token);
$provider = $this->getProvider($authenticator, null, $userChecker);
@@ -81,11 +81,11 @@ public function testAuthenticateSkipsUserChecksForNonUserInterfaceObjects()
$token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
$token->expects($this->any())
->method('getUser')
- ->will($this->returnValue('string-user'));
+ ->willReturn('string-user');
$authenticator = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface')->getMock();
$authenticator->expects($this->once())
->method('authenticateToken')
- ->will($this->returnValue($token));
+ ->willReturn($token);
$this->assertSame($token, $this->getProvider($authenticator, null, new UserChecker())->authenticate($token));
}
diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/UserAuthenticationProviderTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/UserAuthenticationProviderTest.php
index 7c306d2f1f0f6..e959d18c53409 100644
--- a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/UserAuthenticationProviderTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/UserAuthenticationProviderTest.php
@@ -76,7 +76,7 @@ public function testAuthenticateWhenProviderDoesNotReturnAnUserInterface()
$provider = $this->getProvider(false, true);
$provider->expects($this->once())
->method('retrieveUser')
- ->will($this->returnValue(null))
+ ->willReturn(null)
;
$provider->authenticate($this->getSupportedToken());
@@ -96,7 +96,7 @@ public function testAuthenticateWhenPreChecksFails()
$provider = $this->getProvider($userChecker);
$provider->expects($this->once())
->method('retrieveUser')
- ->will($this->returnValue($this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock()))
+ ->willReturn($this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock())
;
$provider->authenticate($this->getSupportedToken());
@@ -116,7 +116,7 @@ public function testAuthenticateWhenPostChecksFails()
$provider = $this->getProvider($userChecker);
$provider->expects($this->once())
->method('retrieveUser')
- ->will($this->returnValue($this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock()))
+ ->willReturn($this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock())
;
$provider->authenticate($this->getSupportedToken());
@@ -131,7 +131,7 @@ public function testAuthenticateWhenPostCheckAuthenticationFails()
$provider = $this->getProvider();
$provider->expects($this->once())
->method('retrieveUser')
- ->will($this->returnValue($this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock()))
+ ->willReturn($this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock())
;
$provider->expects($this->once())
->method('checkAuthentication')
@@ -150,7 +150,7 @@ public function testAuthenticateWhenPostCheckAuthenticationFailsWithHideFalse()
$provider = $this->getProvider(false, false);
$provider->expects($this->once())
->method('retrieveUser')
- ->will($this->returnValue($this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock()))
+ ->willReturn($this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock())
;
$provider->expects($this->once())
->method('checkAuthentication')
@@ -165,24 +165,24 @@ public function testAuthenticate()
$user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
$user->expects($this->once())
->method('getRoles')
- ->will($this->returnValue(['ROLE_FOO']))
+ ->willReturn(['ROLE_FOO'])
;
$provider = $this->getProvider();
$provider->expects($this->once())
->method('retrieveUser')
- ->will($this->returnValue($user))
+ ->willReturn($user)
;
$token = $this->getSupportedToken();
$token->expects($this->once())
->method('getCredentials')
- ->will($this->returnValue('foo'))
+ ->willReturn('foo')
;
$token->expects($this->once())
->method('getRoles')
- ->will($this->returnValue([]))
+ ->willReturn([])
;
$authToken = $provider->authenticate($token);
@@ -199,25 +199,25 @@ public function testAuthenticateWithPreservingRoleSwitchUserRole()
$user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
$user->expects($this->once())
->method('getRoles')
- ->will($this->returnValue(['ROLE_FOO']))
+ ->willReturn(['ROLE_FOO'])
;
$provider = $this->getProvider();
$provider->expects($this->once())
->method('retrieveUser')
- ->will($this->returnValue($user))
+ ->willReturn($user)
;
$token = $this->getSupportedToken();
$token->expects($this->once())
->method('getCredentials')
- ->will($this->returnValue('foo'))
+ ->willReturn('foo')
;
$switchUserRole = new SwitchUserRole('foo', $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock());
$token->expects($this->once())
->method('getRoles')
- ->will($this->returnValue([$switchUserRole]))
+ ->willReturn([$switchUserRole])
;
$authToken = $provider->authenticate($token);
@@ -236,7 +236,7 @@ protected function getSupportedToken()
$mock
->expects($this->any())
->method('getProviderKey')
- ->will($this->returnValue('key'))
+ ->willReturn('key')
;
$mock->setAttributes(['foo' => 'bar']);
diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Token/AbstractTokenTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Token/AbstractTokenTest.php
index 066ca6892ce53..b753b4d70694d 100644
--- a/src/Symfony/Component/Security/Core/Tests/Authentication/Token/AbstractTokenTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Token/AbstractTokenTest.php
@@ -50,7 +50,7 @@ public function serialize()
{
$serialized = [$this->credentials, parent::serialize(true)];
- return $this->doSerialize($serialized, \func_num_args() ? \func_get_arg(0) : null);
+ return $this->doSerialize($serialized, \func_num_args() ? func_get_arg(0) : null);
}
public function unserialize($serialized)
@@ -76,7 +76,7 @@ public function testGetUsername()
$this->assertEquals('fabien', $token->getUsername());
$user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
- $user->expects($this->once())->method('getUsername')->will($this->returnValue('fabien'));
+ $user->expects($this->once())->method('getUsername')->willReturn('fabien');
$token->setUser($user);
$this->assertEquals('fabien', $token->getUsername());
}
diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Token/RememberMeTokenTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Token/RememberMeTokenTest.php
index 8fa0307108f54..160fdad101cf3 100644
--- a/src/Symfony/Component/Security/Core/Tests/Authentication/Token/RememberMeTokenTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Token/RememberMeTokenTest.php
@@ -47,7 +47,7 @@ protected function getUser($roles = ['ROLE_FOO'])
$user
->expects($this->any())
->method('getRoles')
- ->will($this->returnValue($roles))
+ ->willReturn($roles)
;
return $user;
diff --git a/src/Symfony/Component/Security/Core/Tests/Authorization/AccessDecisionManagerTest.php b/src/Symfony/Component/Security/Core/Tests/Authorization/AccessDecisionManagerTest.php
index 1725ef8c486ad..d7012239328eb 100644
--- a/src/Symfony/Component/Security/Core/Tests/Authorization/AccessDecisionManagerTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/Authorization/AccessDecisionManagerTest.php
@@ -69,10 +69,10 @@ protected function getVoterFor2Roles($token, $vote1, $vote2)
$voter = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\Voter\VoterInterface')->getMock();
$voter->expects($this->any())
->method('vote')
- ->will($this->returnValueMap([
+ ->willReturnMap([
[$token, null, ['ROLE_FOO'], $vote1],
[$token, null, ['ROLE_BAR'], $vote2],
- ]))
+ ])
;
return $voter;
@@ -134,7 +134,7 @@ protected function getVoter($vote)
$voter = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\Voter\VoterInterface')->getMock();
$voter->expects($this->any())
->method('vote')
- ->will($this->returnValue($vote));
+ ->willReturn($vote);
return $voter;
}
diff --git a/src/Symfony/Component/Security/Core/Tests/Authorization/AuthorizationCheckerTest.php b/src/Symfony/Component/Security/Core/Tests/Authorization/AuthorizationCheckerTest.php
index 6a07c94f2039c..b4986b0177863 100644
--- a/src/Symfony/Component/Security/Core/Tests/Authorization/AuthorizationCheckerTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/Authorization/AuthorizationCheckerTest.php
@@ -46,7 +46,7 @@ public function testVoteAuthenticatesTokenIfNecessary()
->expects($this->once())
->method('authenticate')
->with($this->equalTo($token))
- ->will($this->returnValue($newToken));
+ ->willReturn($newToken);
// default with() isn't a strict check
$tokenComparison = function ($value) use ($newToken) {
@@ -58,7 +58,7 @@ public function testVoteAuthenticatesTokenIfNecessary()
->expects($this->once())
->method('decide')
->with($this->callback($tokenComparison))
- ->will($this->returnValue(true));
+ ->willReturn(true);
// first run the token has not been re-authenticated yet, after isGranted is called, it should be equal
$this->assertNotSame($newToken, $this->tokenStorage->getToken());
@@ -83,12 +83,12 @@ public function testIsGranted($decide)
$token
->expects($this->once())
->method('isAuthenticated')
- ->will($this->returnValue(true));
+ ->willReturn(true);
$this->accessDecisionManager
->expects($this->once())
->method('decide')
- ->will($this->returnValue($decide));
+ ->willReturn($decide);
$this->tokenStorage->setToken($token);
$this->assertSame($decide, $this->authorizationChecker->isGranted('ROLE_FOO'));
}
diff --git a/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/ExpressionVoterTest.php b/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/ExpressionVoterTest.php
index 632c6d0ab07ca..a23120436959e 100644
--- a/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/ExpressionVoterTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/ExpressionVoterTest.php
@@ -52,7 +52,7 @@ protected function getToken(array $roles, $tokenExpectsGetRoles = true)
if ($tokenExpectsGetRoles) {
$token->expects($this->once())
->method('getRoles')
- ->will($this->returnValue($roles));
+ ->willReturn($roles);
}
return $token;
@@ -65,7 +65,7 @@ protected function createExpressionLanguage($expressionLanguageExpectsEvaluate =
if ($expressionLanguageExpectsEvaluate) {
$mock->expects($this->once())
->method('evaluate')
- ->will($this->returnValue(true));
+ ->willReturn(true);
}
return $mock;
diff --git a/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/RoleVoterTest.php b/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/RoleVoterTest.php
index 5fb45e08b3925..955ab842e139f 100644
--- a/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/RoleVoterTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/RoleVoterTest.php
@@ -54,7 +54,7 @@ protected function getToken(array $roles)
$token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
$token->expects($this->once())
->method('getRoles')
- ->will($this->returnValue($roles));
+ ->willReturn($roles);
return $token;
}
diff --git a/src/Symfony/Component/Security/Core/Tests/Encoder/UserPasswordEncoderTest.php b/src/Symfony/Component/Security/Core/Tests/Encoder/UserPasswordEncoderTest.php
index 3328837ef1f74..41a602f976047 100644
--- a/src/Symfony/Component/Security/Core/Tests/Encoder/UserPasswordEncoderTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/Encoder/UserPasswordEncoderTest.php
@@ -21,19 +21,19 @@ public function testEncodePassword()
$userMock = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
$userMock->expects($this->any())
->method('getSalt')
- ->will($this->returnValue('userSalt'));
+ ->willReturn('userSalt');
$mockEncoder = $this->getMockBuilder('Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface')->getMock();
$mockEncoder->expects($this->any())
->method('encodePassword')
->with($this->equalTo('plainPassword'), $this->equalTo('userSalt'))
- ->will($this->returnValue('encodedPassword'));
+ ->willReturn('encodedPassword');
$mockEncoderFactory = $this->getMockBuilder('Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface')->getMock();
$mockEncoderFactory->expects($this->any())
->method('getEncoder')
->with($this->equalTo($userMock))
- ->will($this->returnValue($mockEncoder));
+ ->willReturn($mockEncoder);
$passwordEncoder = new UserPasswordEncoder($mockEncoderFactory);
@@ -46,22 +46,22 @@ public function testIsPasswordValid()
$userMock = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
$userMock->expects($this->any())
->method('getSalt')
- ->will($this->returnValue('userSalt'));
+ ->willReturn('userSalt');
$userMock->expects($this->any())
->method('getPassword')
- ->will($this->returnValue('encodedPassword'));
+ ->willReturn('encodedPassword');
$mockEncoder = $this->getMockBuilder('Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface')->getMock();
$mockEncoder->expects($this->any())
->method('isPasswordValid')
->with($this->equalTo('encodedPassword'), $this->equalTo('plainPassword'), $this->equalTo('userSalt'))
- ->will($this->returnValue(true));
+ ->willReturn(true);
$mockEncoderFactory = $this->getMockBuilder('Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface')->getMock();
$mockEncoderFactory->expects($this->any())
->method('getEncoder')
->with($this->equalTo($userMock))
- ->will($this->returnValue($mockEncoder));
+ ->willReturn($mockEncoder);
$passwordEncoder = new UserPasswordEncoder($mockEncoderFactory);
diff --git a/src/Symfony/Component/Security/Core/Tests/SecurityTest.php b/src/Symfony/Component/Security/Core/Tests/SecurityTest.php
index 83d876623b8c0..e30b14e7f97a9 100644
--- a/src/Symfony/Component/Security/Core/Tests/SecurityTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/SecurityTest.php
@@ -29,7 +29,7 @@ public function testGetToken()
$tokenStorage->expects($this->once())
->method('getToken')
- ->will($this->returnValue($token));
+ ->willReturn($token);
$container = $this->createContainer('security.token_storage', $tokenStorage);
@@ -45,12 +45,12 @@ public function testGetUser($userInToken, $expectedUser)
$token = $this->getMockBuilder(TokenInterface::class)->getMock();
$token->expects($this->any())
->method('getUser')
- ->will($this->returnValue($userInToken));
+ ->willReturn($userInToken);
$tokenStorage = $this->getMockBuilder(TokenStorageInterface::class)->getMock();
$tokenStorage->expects($this->once())
->method('getToken')
- ->will($this->returnValue($token));
+ ->willReturn($token);
$container = $this->createContainer('security.token_storage', $tokenStorage);
@@ -79,12 +79,12 @@ public function testGetUserLegacy()
$token = $this->getMockBuilder(TokenInterface::class)->getMock();
$token->expects($this->any())
->method('getUser')
- ->will($this->returnValue($user = new StringishUser()));
+ ->willReturn($user = new StringishUser());
$tokenStorage = $this->getMockBuilder(TokenStorageInterface::class)->getMock();
$tokenStorage->expects($this->once())
->method('getToken')
- ->will($this->returnValue($token));
+ ->willReturn($token);
$container = $this->createContainer('security.token_storage', $tokenStorage);
@@ -99,7 +99,7 @@ public function testIsGranted()
$authorizationChecker->expects($this->once())
->method('isGranted')
->with('SOME_ATTRIBUTE', 'SOME_SUBJECT')
- ->will($this->returnValue(true));
+ ->willReturn(true);
$container = $this->createContainer('security.authorization_checker', $authorizationChecker);
@@ -114,7 +114,7 @@ private function createContainer($serviceId, $serviceObject)
$container->expects($this->atLeastOnce())
->method('get')
->with($serviceId)
- ->will($this->returnValue($serviceObject));
+ ->willReturn($serviceObject);
return $container;
}
diff --git a/src/Symfony/Component/Security/Core/Tests/User/ChainUserProviderTest.php b/src/Symfony/Component/Security/Core/Tests/User/ChainUserProviderTest.php
index 067eef2497b83..05a7fbba19d88 100644
--- a/src/Symfony/Component/Security/Core/Tests/User/ChainUserProviderTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/User/ChainUserProviderTest.php
@@ -33,7 +33,7 @@ public function testLoadUserByUsername()
->expects($this->once())
->method('loadUserByUsername')
->with($this->equalTo('foo'))
- ->will($this->returnValue($account = $this->getAccount()))
+ ->willReturn($account = $this->getAccount())
;
$provider = new ChainUserProvider([$provider1, $provider2]);
@@ -78,7 +78,7 @@ public function testRefreshUser()
$provider2
->expects($this->once())
->method('refreshUser')
- ->will($this->returnValue($account = $this->getAccount()))
+ ->willReturn($account = $this->getAccount())
;
$provider = new ChainUserProvider([$provider1, $provider2]);
@@ -98,7 +98,7 @@ public function testRefreshUserAgain()
$provider2
->expects($this->once())
->method('refreshUser')
- ->will($this->returnValue($account = $this->getAccount()))
+ ->willReturn($account = $this->getAccount())
;
$provider = new ChainUserProvider([$provider1, $provider2]);
@@ -135,7 +135,7 @@ public function testSupportsClass()
->expects($this->once())
->method('supportsClass')
->with($this->equalTo('foo'))
- ->will($this->returnValue(false))
+ ->willReturn(false)
;
$provider2 = $this->getProvider();
@@ -143,7 +143,7 @@ public function testSupportsClass()
->expects($this->once())
->method('supportsClass')
->with($this->equalTo('foo'))
- ->will($this->returnValue(true))
+ ->willReturn(true)
;
$provider = new ChainUserProvider([$provider1, $provider2]);
@@ -157,7 +157,7 @@ public function testSupportsClassWhenNotSupported()
->expects($this->once())
->method('supportsClass')
->with($this->equalTo('foo'))
- ->will($this->returnValue(false))
+ ->willReturn(false)
;
$provider2 = $this->getProvider();
@@ -165,7 +165,7 @@ public function testSupportsClassWhenNotSupported()
->expects($this->once())
->method('supportsClass')
->with($this->equalTo('foo'))
- ->will($this->returnValue(false))
+ ->willReturn(false)
;
$provider = new ChainUserProvider([$provider1, $provider2]);
@@ -185,7 +185,7 @@ public function testAcceptsTraversable()
$provider2
->expects($this->once())
->method('refreshUser')
- ->will($this->returnValue($account = $this->getAccount()))
+ ->willReturn($account = $this->getAccount())
;
$provider = new ChainUserProvider(new \ArrayObject([$provider1, $provider2]));
diff --git a/src/Symfony/Component/Security/Core/Tests/User/LdapUserProviderTest.php b/src/Symfony/Component/Security/Core/Tests/User/LdapUserProviderTest.php
index 418475ac9381c..39a346433e463 100644
--- a/src/Symfony/Component/Security/Core/Tests/User/LdapUserProviderTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/User/LdapUserProviderTest.php
@@ -50,23 +50,23 @@ public function testLoadUserByUsernameFailsIfNoLdapEntries()
$query
->expects($this->once())
->method('execute')
- ->will($this->returnValue($result))
+ ->willReturn($result)
;
$result
->expects($this->once())
->method('count')
- ->will($this->returnValue(0))
+ ->willReturn(0)
;
$ldap = $this->getMockBuilder(LdapInterface::class)->getMock();
$ldap
->expects($this->once())
->method('escape')
- ->will($this->returnValue('foo'))
+ ->willReturn('foo')
;
$ldap
->expects($this->once())
->method('query')
- ->will($this->returnValue($query))
+ ->willReturn($query)
;
$provider = new LdapUserProvider($ldap, 'ou=MyBusiness,dc=symfony,dc=com');
@@ -83,23 +83,23 @@ public function testLoadUserByUsernameFailsIfMoreThanOneLdapEntry()
$query
->expects($this->once())
->method('execute')
- ->will($this->returnValue($result))
+ ->willReturn($result)
;
$result
->expects($this->once())
->method('count')
- ->will($this->returnValue(2))
+ ->willReturn(2)
;
$ldap = $this->getMockBuilder(LdapInterface::class)->getMock();
$ldap
->expects($this->once())
->method('escape')
- ->will($this->returnValue('foo'))
+ ->willReturn('foo')
;
$ldap
->expects($this->once())
->method('query')
- ->will($this->returnValue($query))
+ ->willReturn($query)
;
$provider = new LdapUserProvider($ldap, 'ou=MyBusiness,dc=symfony,dc=com');
@@ -116,33 +116,33 @@ public function testLoadUserByUsernameFailsIfMoreThanOneLdapPasswordsInEntry()
$query
->expects($this->once())
->method('execute')
- ->will($this->returnValue($result))
+ ->willReturn($result)
;
$ldap = $this->getMockBuilder(LdapInterface::class)->getMock();
$result
->expects($this->once())
->method('offsetGet')
->with(0)
- ->will($this->returnValue(new Entry('foo', [
+ ->willReturn(new Entry('foo', [
'sAMAccountName' => ['foo'],
'userpassword' => ['bar', 'baz'],
]
- )))
+ ))
;
$result
->expects($this->once())
->method('count')
- ->will($this->returnValue(1))
+ ->willReturn(1)
;
$ldap
->expects($this->once())
->method('escape')
- ->will($this->returnValue('foo'))
+ ->willReturn('foo')
;
$ldap
->expects($this->once())
->method('query')
- ->will($this->returnValue($query))
+ ->willReturn($query)
;
$provider = new LdapUserProvider($ldap, 'ou=MyBusiness,dc=symfony,dc=com', null, null, [], 'sAMAccountName', '({uid_key}={username})', 'userpassword');
@@ -159,29 +159,29 @@ public function testLoadUserByUsernameShouldNotFailIfEntryHasNoUidKeyAttribute()
$query
->expects($this->once())
->method('execute')
- ->will($this->returnValue($result))
+ ->willReturn($result)
;
$ldap = $this->getMockBuilder(LdapInterface::class)->getMock();
$result
->expects($this->once())
->method('offsetGet')
->with(0)
- ->will($this->returnValue(new Entry('foo', [])))
+ ->willReturn(new Entry('foo', []))
;
$result
->expects($this->once())
->method('count')
- ->will($this->returnValue(1))
+ ->willReturn(1)
;
$ldap
->expects($this->once())
->method('escape')
- ->will($this->returnValue('foo'))
+ ->willReturn('foo')
;
$ldap
->expects($this->once())
->method('query')
- ->will($this->returnValue($query))
+ ->willReturn($query)
;
$provider = new LdapUserProvider($ldap, 'ou=MyBusiness,dc=symfony,dc=com', null, null, [], 'sAMAccountName', '({uid_key}={username})');
@@ -201,32 +201,32 @@ public function testLoadUserByUsernameFailsIfEntryHasNoPasswordAttribute()
$query
->expects($this->once())
->method('execute')
- ->will($this->returnValue($result))
+ ->willReturn($result)
;
$ldap = $this->getMockBuilder(LdapInterface::class)->getMock();
$result
->expects($this->once())
->method('offsetGet')
->with(0)
- ->will($this->returnValue(new Entry('foo', [
+ ->willReturn(new Entry('foo', [
'sAMAccountName' => ['foo'],
]
- )))
+ ))
;
$result
->expects($this->once())
->method('count')
- ->will($this->returnValue(1))
+ ->willReturn(1)
;
$ldap
->expects($this->once())
->method('escape')
- ->will($this->returnValue('foo'))
+ ->willReturn('foo')
;
$ldap
->expects($this->once())
->method('query')
- ->will($this->returnValue($query))
+ ->willReturn($query)
;
$provider = new LdapUserProvider($ldap, 'ou=MyBusiness,dc=symfony,dc=com', null, null, [], 'sAMAccountName', '({uid_key}={username})', 'userpassword');
@@ -243,32 +243,32 @@ public function testLoadUserByUsernameIsSuccessfulWithoutPasswordAttribute()
$query
->expects($this->once())
->method('execute')
- ->will($this->returnValue($result))
+ ->willReturn($result)
;
$ldap = $this->getMockBuilder(LdapInterface::class)->getMock();
$result
->expects($this->once())
->method('offsetGet')
->with(0)
- ->will($this->returnValue(new Entry('foo', [
+ ->willReturn(new Entry('foo', [
'sAMAccountName' => ['foo'],
]
- )))
+ ))
;
$result
->expects($this->once())
->method('count')
- ->will($this->returnValue(1))
+ ->willReturn(1)
;
$ldap
->expects($this->once())
->method('escape')
- ->will($this->returnValue('foo'))
+ ->willReturn('foo')
;
$ldap
->expects($this->once())
->method('query')
- ->will($this->returnValue($query))
+ ->willReturn($query)
;
$provider = new LdapUserProvider($ldap, 'ou=MyBusiness,dc=symfony,dc=com');
@@ -285,32 +285,32 @@ public function testLoadUserByUsernameIsSuccessfulWithoutPasswordAttributeAndWro
$query
->expects($this->once())
->method('execute')
- ->will($this->returnValue($result))
+ ->willReturn($result)
;
$ldap = $this->getMockBuilder(LdapInterface::class)->getMock();
$result
->expects($this->once())
->method('offsetGet')
->with(0)
- ->will($this->returnValue(new Entry('foo', [
+ ->willReturn(new Entry('foo', [
'sAMAccountName' => ['foo'],
]
- )))
+ ))
;
$result
->expects($this->once())
->method('count')
- ->will($this->returnValue(1))
+ ->willReturn(1)
;
$ldap
->expects($this->once())
->method('escape')
- ->will($this->returnValue('Foo'))
+ ->willReturn('Foo')
;
$ldap
->expects($this->once())
->method('query')
- ->will($this->returnValue($query))
+ ->willReturn($query)
;
$provider = new LdapUserProvider($ldap, 'ou=MyBusiness,dc=symfony,dc=com');
@@ -324,33 +324,33 @@ public function testLoadUserByUsernameIsSuccessfulWithPasswordAttribute()
$query
->expects($this->once())
->method('execute')
- ->will($this->returnValue($result))
+ ->willReturn($result)
;
$ldap = $this->getMockBuilder(LdapInterface::class)->getMock();
$result
->expects($this->once())
->method('offsetGet')
->with(0)
- ->will($this->returnValue(new Entry('foo', [
+ ->willReturn(new Entry('foo', [
'sAMAccountName' => ['foo'],
'userpassword' => ['bar'],
]
- )))
+ ))
;
$result
->expects($this->once())
->method('count')
- ->will($this->returnValue(1))
+ ->willReturn(1)
;
$ldap
->expects($this->once())
->method('escape')
- ->will($this->returnValue('foo'))
+ ->willReturn('foo')
;
$ldap
->expects($this->once())
->method('query')
- ->will($this->returnValue($query))
+ ->willReturn($query)
;
$provider = new LdapUserProvider($ldap, 'ou=MyBusiness,dc=symfony,dc=com', null, null, [], 'sAMAccountName', '({uid_key}={username})', 'userpassword');
diff --git a/src/Symfony/Component/Security/Core/Tests/User/UserCheckerTest.php b/src/Symfony/Component/Security/Core/Tests/User/UserCheckerTest.php
index ceacb3b2a3754..a1f62aa5db904 100644
--- a/src/Symfony/Component/Security/Core/Tests/User/UserCheckerTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/User/UserCheckerTest.php
@@ -39,7 +39,7 @@ public function testCheckPostAuthPassAdvancedUser()
$checker = new UserChecker();
$account = $this->getMockBuilder('Symfony\Component\Security\Core\User\AdvancedUserInterface')->getMock();
- $account->expects($this->once())->method('isCredentialsNonExpired')->will($this->returnValue(true));
+ $account->expects($this->once())->method('isCredentialsNonExpired')->willReturn(true);
$this->assertNull($checker->checkPostAuth($account));
}
@@ -63,7 +63,7 @@ public function testCheckPostAuthCredentialsExpiredAdvancedUser()
$checker = new UserChecker();
$account = $this->getMockBuilder('Symfony\Component\Security\Core\User\AdvancedUserInterface')->getMock();
- $account->expects($this->once())->method('isCredentialsNonExpired')->will($this->returnValue(false));
+ $account->expects($this->once())->method('isCredentialsNonExpired')->willReturn(false);
$checker->checkPostAuth($account);
}
@@ -77,9 +77,9 @@ public function testCheckPreAuthPassAdvancedUser()
$checker = new UserChecker();
$account = $this->getMockBuilder('Symfony\Component\Security\Core\User\AdvancedUserInterface')->getMock();
- $account->expects($this->once())->method('isAccountNonLocked')->will($this->returnValue(true));
- $account->expects($this->once())->method('isEnabled')->will($this->returnValue(true));
- $account->expects($this->once())->method('isAccountNonExpired')->will($this->returnValue(true));
+ $account->expects($this->once())->method('isAccountNonLocked')->willReturn(true);
+ $account->expects($this->once())->method('isEnabled')->willReturn(true);
+ $account->expects($this->once())->method('isAccountNonExpired')->willReturn(true);
$this->assertNull($checker->checkPreAuth($account));
}
@@ -103,7 +103,7 @@ public function testCheckPreAuthAccountLockedAdvancedUser()
$checker = new UserChecker();
$account = $this->getMockBuilder('Symfony\Component\Security\Core\User\AdvancedUserInterface')->getMock();
- $account->expects($this->once())->method('isAccountNonLocked')->will($this->returnValue(false));
+ $account->expects($this->once())->method('isAccountNonLocked')->willReturn(false);
$checker->checkPreAuth($account);
}
@@ -127,8 +127,8 @@ public function testCheckPreAuthDisabledAdvancedUser()
$checker = new UserChecker();
$account = $this->getMockBuilder('Symfony\Component\Security\Core\User\AdvancedUserInterface')->getMock();
- $account->expects($this->once())->method('isAccountNonLocked')->will($this->returnValue(true));
- $account->expects($this->once())->method('isEnabled')->will($this->returnValue(false));
+ $account->expects($this->once())->method('isAccountNonLocked')->willReturn(true);
+ $account->expects($this->once())->method('isEnabled')->willReturn(false);
$checker->checkPreAuth($account);
}
@@ -152,9 +152,9 @@ public function testCheckPreAuthAccountExpiredAdvancedUser()
$checker = new UserChecker();
$account = $this->getMockBuilder('Symfony\Component\Security\Core\User\AdvancedUserInterface')->getMock();
- $account->expects($this->once())->method('isAccountNonLocked')->will($this->returnValue(true));
- $account->expects($this->once())->method('isEnabled')->will($this->returnValue(true));
- $account->expects($this->once())->method('isAccountNonExpired')->will($this->returnValue(false));
+ $account->expects($this->once())->method('isAccountNonLocked')->willReturn(true);
+ $account->expects($this->once())->method('isEnabled')->willReturn(true);
+ $account->expects($this->once())->method('isAccountNonExpired')->willReturn(false);
$checker->checkPreAuth($account);
}
diff --git a/src/Symfony/Component/Security/Core/Tests/Validator/Constraints/UserPasswordValidatorTest.php b/src/Symfony/Component/Security/Core/Tests/Validator/Constraints/UserPasswordValidatorTest.php
index 24c2c7adda187..305b665ea32c9 100644
--- a/src/Symfony/Component/Security/Core/Tests/Validator/Constraints/UserPasswordValidatorTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/Validator/Constraints/UserPasswordValidatorTest.php
@@ -65,7 +65,7 @@ public function testPasswordIsValid()
$this->encoder->expects($this->once())
->method('isPasswordValid')
->with(static::PASSWORD, 'secret', static::SALT)
- ->will($this->returnValue(true));
+ ->willReturn(true);
$this->validator->validate('secret', $constraint);
@@ -81,7 +81,7 @@ public function testPasswordIsNotValid()
$this->encoder->expects($this->once())
->method('isPasswordValid')
->with(static::PASSWORD, 'secret', static::SALT)
- ->will($this->returnValue(false));
+ ->willReturn(false);
$this->validator->validate('secret', $constraint);
@@ -133,13 +133,13 @@ protected function createUser()
$mock
->expects($this->any())
->method('getPassword')
- ->will($this->returnValue(static::PASSWORD))
+ ->willReturn(static::PASSWORD)
;
$mock
->expects($this->any())
->method('getSalt')
- ->will($this->returnValue(static::SALT))
+ ->willReturn(static::SALT)
;
return $mock;
@@ -157,7 +157,7 @@ protected function createEncoderFactory($encoder = null)
$mock
->expects($this->any())
->method('getEncoder')
- ->will($this->returnValue($encoder))
+ ->willReturn($encoder)
;
return $mock;
@@ -171,7 +171,7 @@ protected function createTokenStorage($user = null)
$mock
->expects($this->any())
->method('getToken')
- ->will($this->returnValue($token))
+ ->willReturn($token)
;
return $mock;
@@ -183,7 +183,7 @@ protected function createAuthenticationToken($user = null)
$mock
->expects($this->any())
->method('getUser')
- ->will($this->returnValue($user))
+ ->willReturn($user)
;
return $mock;
diff --git a/src/Symfony/Component/Security/Csrf/Tests/CsrfTokenManagerTest.php b/src/Symfony/Component/Security/Csrf/Tests/CsrfTokenManagerTest.php
index b954fc037b907..631c36a0db0ac 100644
--- a/src/Symfony/Component/Security/Csrf/Tests/CsrfTokenManagerTest.php
+++ b/src/Symfony/Component/Security/Csrf/Tests/CsrfTokenManagerTest.php
@@ -30,11 +30,11 @@ public function testGetNonExistingToken($namespace, $manager, $storage, $generat
$storage->expects($this->once())
->method('hasToken')
->with($namespace.'token_id')
- ->will($this->returnValue(false));
+ ->willReturn(false);
$generator->expects($this->once())
->method('generateToken')
- ->will($this->returnValue('TOKEN'));
+ ->willReturn('TOKEN');
$storage->expects($this->once())
->method('setToken')
@@ -55,12 +55,12 @@ public function testUseExistingTokenIfAvailable($namespace, $manager, $storage)
$storage->expects($this->once())
->method('hasToken')
->with($namespace.'token_id')
- ->will($this->returnValue(true));
+ ->willReturn(true);
$storage->expects($this->once())
->method('getToken')
->with($namespace.'token_id')
- ->will($this->returnValue('TOKEN'));
+ ->willReturn('TOKEN');
$token = $manager->getToken('token_id');
@@ -79,7 +79,7 @@ public function testRefreshTokenAlwaysReturnsNewToken($namespace, $manager, $sto
$generator->expects($this->once())
->method('generateToken')
- ->will($this->returnValue('TOKEN'));
+ ->willReturn('TOKEN');
$storage->expects($this->once())
->method('setToken')
@@ -100,12 +100,12 @@ public function testMatchingTokenIsValid($namespace, $manager, $storage)
$storage->expects($this->once())
->method('hasToken')
->with($namespace.'token_id')
- ->will($this->returnValue(true));
+ ->willReturn(true);
$storage->expects($this->once())
->method('getToken')
->with($namespace.'token_id')
- ->will($this->returnValue('TOKEN'));
+ ->willReturn('TOKEN');
$this->assertTrue($manager->isTokenValid(new CsrfToken('token_id', 'TOKEN')));
}
@@ -118,12 +118,12 @@ public function testNonMatchingTokenIsNotValid($namespace, $manager, $storage)
$storage->expects($this->once())
->method('hasToken')
->with($namespace.'token_id')
- ->will($this->returnValue(true));
+ ->willReturn(true);
$storage->expects($this->once())
->method('getToken')
->with($namespace.'token_id')
- ->will($this->returnValue('TOKEN'));
+ ->willReturn('TOKEN');
$this->assertFalse($manager->isTokenValid(new CsrfToken('token_id', 'FOOBAR')));
}
@@ -136,7 +136,7 @@ public function testNonExistingTokenIsNotValid($namespace, $manager, $storage)
$storage->expects($this->once())
->method('hasToken')
->with($namespace.'token_id')
- ->will($this->returnValue(false));
+ ->willReturn(false);
$storage->expects($this->never())
->method('getToken');
@@ -152,7 +152,7 @@ public function testRemoveToken($namespace, $manager, $storage)
$storage->expects($this->once())
->method('removeToken')
->with($namespace.'token_id')
- ->will($this->returnValue('REMOVED_TOKEN'));
+ ->willReturn('REMOVED_TOKEN');
$this->assertSame('REMOVED_TOKEN', $manager->removeToken('token_id'));
}
diff --git a/src/Symfony/Component/Security/Guard/Tests/Firewall/GuardAuthenticationListenerTest.php b/src/Symfony/Component/Security/Guard/Tests/Firewall/GuardAuthenticationListenerTest.php
index 5a95eb6ae750e..258f3a5bb06ce 100644
--- a/src/Symfony/Component/Security/Guard/Tests/Firewall/GuardAuthenticationListenerTest.php
+++ b/src/Symfony/Component/Security/Guard/Tests/Firewall/GuardAuthenticationListenerTest.php
@@ -49,7 +49,7 @@ public function testHandleSuccess()
->expects($this->once())
->method('getCredentials')
->with($this->equalTo($this->request))
- ->will($this->returnValue($credentials));
+ ->willReturn($credentials);
// a clone of the token that should be created internally
$uniqueGuardKey = 'my_firewall_0';
@@ -59,7 +59,7 @@ public function testHandleSuccess()
->expects($this->once())
->method('authenticate')
->with($this->equalTo($nonAuthedToken))
- ->will($this->returnValue($authenticateToken));
+ ->willReturn($authenticateToken);
$this->guardAuthenticatorHandler
->expects($this->once())
@@ -137,18 +137,18 @@ public function testHandleSuccessWithRememberMe()
->expects($this->once())
->method('getCredentials')
->with($this->equalTo($this->request))
- ->will($this->returnValue(['username' => 'anything_not_empty']));
+ ->willReturn(['username' => 'anything_not_empty']);
$this->authenticationManager
->expects($this->once())
->method('authenticate')
- ->will($this->returnValue($authenticateToken));
+ ->willReturn($authenticateToken);
$successResponse = new Response('Success!');
$this->guardAuthenticatorHandler
->expects($this->once())
->method('handleAuthenticationSuccess')
- ->will($this->returnValue($successResponse));
+ ->willReturn($successResponse);
$listener = new GuardAuthenticationListener(
$this->guardAuthenticatorHandler,
@@ -161,7 +161,7 @@ public function testHandleSuccessWithRememberMe()
$listener->setRememberMeServices($this->rememberMeServices);
$authenticator->expects($this->once())
->method('supportsRememberMe')
- ->will($this->returnValue(true));
+ ->willReturn(true);
// should be called - we do have a success Response
$this->rememberMeServices
->expects($this->once())
@@ -214,7 +214,7 @@ public function testSupportsReturnFalseSkipAuth()
$authenticator
->expects($this->once())
->method('supports')
- ->will($this->returnValue(false));
+ ->willReturn(false);
// this is not called
$authenticator
@@ -243,13 +243,13 @@ public function testReturnNullFromGetCredentials()
$authenticator
->expects($this->once())
->method('supports')
- ->will($this->returnValue(true));
+ ->willReturn(true);
// this will raise exception
$authenticator
->expects($this->once())
->method('getCredentials')
- ->will($this->returnValue(null));
+ ->willReturn(null);
$listener = new GuardAuthenticationListener(
$this->guardAuthenticatorHandler,
@@ -281,7 +281,7 @@ protected function setUp()
$this->event
->expects($this->any())
->method('getRequest')
- ->will($this->returnValue($this->request));
+ ->willReturn($this->request);
$this->logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
$this->rememberMeServices = $this->getMockBuilder('Symfony\Component\Security\Http\RememberMe\RememberMeServicesInterface')->getMock();
diff --git a/src/Symfony/Component/Security/Guard/Tests/GuardAuthenticatorHandlerTest.php b/src/Symfony/Component/Security/Guard/Tests/GuardAuthenticatorHandlerTest.php
index 9950426de9e2f..3bf204ec7f5c0 100644
--- a/src/Symfony/Component/Security/Guard/Tests/GuardAuthenticatorHandlerTest.php
+++ b/src/Symfony/Component/Security/Guard/Tests/GuardAuthenticatorHandlerTest.php
@@ -54,7 +54,7 @@ public function testHandleAuthenticationSuccess()
$this->guardAuthenticator->expects($this->once())
->method('onAuthenticationSuccess')
->with($this->request, $this->token, $providerKey)
- ->will($this->returnValue($response));
+ ->willReturn($response);
$handler = new GuardAuthenticatorHandler($this->tokenStorage, $this->dispatcher);
$actualResponse = $handler->handleAuthenticationSuccess($this->token, $this->request, $this->guardAuthenticator, $providerKey);
@@ -73,7 +73,7 @@ public function testHandleAuthenticationFailure()
$this->guardAuthenticator->expects($this->once())
->method('onAuthenticationFailure')
->with($this->request, $authException)
- ->will($this->returnValue($response));
+ ->willReturn($response);
$handler = new GuardAuthenticatorHandler($this->tokenStorage, $this->dispatcher);
$actualResponse = $handler->handleAuthenticationFailure($authException, $this->request, $this->guardAuthenticator, 'firewall_provider_key');
@@ -90,7 +90,7 @@ public function testHandleAuthenticationClearsToken($tokenClass, $tokenProviderK
->getMock();
$token->expects($this->any())
->method('getProviderKey')
- ->will($this->returnValue($tokenProviderKey));
+ ->willReturn($tokenProviderKey);
$this->tokenStorage->expects($this->never())
->method('setToken')
@@ -101,7 +101,7 @@ public function testHandleAuthenticationClearsToken($tokenClass, $tokenProviderK
$this->guardAuthenticator->expects($this->once())
->method('onAuthenticationFailure')
->with($this->request, $authException)
- ->will($this->returnValue($response));
+ ->willReturn($response);
$handler = new GuardAuthenticatorHandler($this->tokenStorage, $this->dispatcher);
$actualResponse = $handler->handleAuthenticationFailure($authException, $this->request, $this->guardAuthenticator, $actualProviderKey);
diff --git a/src/Symfony/Component/Security/Guard/Tests/Provider/GuardAuthenticationProviderTest.php b/src/Symfony/Component/Security/Guard/Tests/Provider/GuardAuthenticationProviderTest.php
index 622ab4336e53d..787958b5bf3de 100644
--- a/src/Symfony/Component/Security/Guard/Tests/Provider/GuardAuthenticationProviderTest.php
+++ b/src/Symfony/Component/Security/Guard/Tests/Provider/GuardAuthenticationProviderTest.php
@@ -41,7 +41,7 @@ public function testAuthenticate()
$this->preAuthenticationToken->expects($this->exactly(2))
->method('getGuardProviderKey')
// it will return the "1" index, which will match authenticatorB
- ->will($this->returnValue('my_cool_firewall_1'));
+ ->willReturn('my_cool_firewall_1');
$enteredCredentials = [
'username' => '_weaverryan_test_user',
@@ -49,7 +49,7 @@ public function testAuthenticate()
];
$this->preAuthenticationToken->expects($this->atLeastOnce())
->method('getCredentials')
- ->will($this->returnValue($enteredCredentials));
+ ->willReturn($enteredCredentials);
// authenticators A and C are never called
$authenticatorA->expects($this->never())
@@ -61,18 +61,18 @@ public function testAuthenticate()
$authenticatorB->expects($this->once())
->method('getUser')
->with($enteredCredentials, $this->userProvider)
- ->will($this->returnValue($mockedUser));
+ ->willReturn($mockedUser);
// checkCredentials is called
$authenticatorB->expects($this->once())
->method('checkCredentials')
->with($enteredCredentials, $mockedUser)
// authentication works!
- ->will($this->returnValue(true));
+ ->willReturn(true);
$authedToken = $this->getMockBuilder(TokenInterface::class)->getMock();
$authenticatorB->expects($this->once())
->method('createAuthenticatedToken')
->with($mockedUser, $providerKey)
- ->will($this->returnValue($authedToken));
+ ->willReturn($authedToken);
// user checker should be called
$this->userChecker->expects($this->once())
@@ -100,21 +100,21 @@ public function testCheckCredentialsReturningNonTrueFailsAuthentication()
$this->preAuthenticationToken->expects($this->any())
->method('getGuardProviderKey')
// the 0 index, to match the only authenticator
- ->will($this->returnValue('my_uncool_firewall_0'));
+ ->willReturn('my_uncool_firewall_0');
$this->preAuthenticationToken->expects($this->atLeastOnce())
->method('getCredentials')
- ->will($this->returnValue('non-null-value'));
+ ->willReturn('non-null-value');
$mockedUser = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
$authenticator->expects($this->once())
->method('getUser')
- ->will($this->returnValue($mockedUser));
+ ->willReturn($mockedUser);
// checkCredentials is called
$authenticator->expects($this->once())
->method('checkCredentials')
// authentication fails :(
- ->will($this->returnValue(null));
+ ->willReturn(null);
$provider = new GuardAuthenticationProvider([$authenticator], $this->userProvider, $providerKey, $this->userChecker);
$provider->authenticate($this->preAuthenticationToken);
diff --git a/src/Symfony/Component/Security/Guard/Token/PostAuthenticationGuardToken.php b/src/Symfony/Component/Security/Guard/Token/PostAuthenticationGuardToken.php
index f0ddc533d47ac..1be5886c443e0 100644
--- a/src/Symfony/Component/Security/Guard/Token/PostAuthenticationGuardToken.php
+++ b/src/Symfony/Component/Security/Guard/Token/PostAuthenticationGuardToken.php
@@ -78,7 +78,7 @@ public function serialize()
{
$serialized = [$this->providerKey, parent::serialize(true)];
- return $this->doSerialize($serialized, \func_num_args() ? \func_get_arg(0) : null);
+ return $this->doSerialize($serialized, \func_num_args() ? func_get_arg(0) : null);
}
/**
diff --git a/src/Symfony/Component/Security/Http/Firewall/SimpleFormAuthenticationListener.php b/src/Symfony/Component/Security/Http/Firewall/SimpleFormAuthenticationListener.php
index a8ccee0f7d557..3d1895f452b0e 100644
--- a/src/Symfony/Component/Security/Http/Firewall/SimpleFormAuthenticationListener.php
+++ b/src/Symfony/Component/Security/Http/Firewall/SimpleFormAuthenticationListener.php
@@ -97,7 +97,7 @@ protected function attemptAuthentication(Request $request)
$password = ParameterBagUtils::getRequestParameterValue($request, $this->options['password_parameter']);
}
- if (!\is_string($username) && (!\is_object($username) || !\method_exists($username, '__toString'))) {
+ if (!\is_string($username) && (!\is_object($username) || !method_exists($username, '__toString'))) {
throw new BadRequestHttpException(sprintf('The key "%s" must be a string, "%s" given.', $this->options['username_parameter'], \gettype($username)));
}
diff --git a/src/Symfony/Component/Security/Http/Firewall/UsernamePasswordFormAuthenticationListener.php b/src/Symfony/Component/Security/Http/Firewall/UsernamePasswordFormAuthenticationListener.php
index 2b8ab8d09f578..e466698ac4e9a 100644
--- a/src/Symfony/Component/Security/Http/Firewall/UsernamePasswordFormAuthenticationListener.php
+++ b/src/Symfony/Component/Security/Http/Firewall/UsernamePasswordFormAuthenticationListener.php
@@ -85,7 +85,7 @@ protected function attemptAuthentication(Request $request)
$password = ParameterBagUtils::getRequestParameterValue($request, $this->options['password_parameter']);
}
- if (!\is_string($username) && (!\is_object($username) || !\method_exists($username, '__toString'))) {
+ if (!\is_string($username) && (!\is_object($username) || !method_exists($username, '__toString'))) {
throw new BadRequestHttpException(sprintf('The key "%s" must be a string, "%s" given.', $this->options['username_parameter'], \gettype($username)));
}
diff --git a/src/Symfony/Component/Security/Http/Firewall/X509AuthenticationListener.php b/src/Symfony/Component/Security/Http/Firewall/X509AuthenticationListener.php
index 2d3c26f28c3cd..1958354702a52 100644
--- a/src/Symfony/Component/Security/Http/Firewall/X509AuthenticationListener.php
+++ b/src/Symfony/Component/Security/Http/Firewall/X509AuthenticationListener.php
@@ -44,7 +44,10 @@ protected function getPreAuthenticatedData(Request $request)
$user = null;
if ($request->server->has($this->userKey)) {
$user = $request->server->get($this->userKey);
- } elseif ($request->server->has($this->credentialKey) && preg_match('#/emailAddress=(.+\@.+\..+)(/|$)#', $request->server->get($this->credentialKey), $matches)) {
+ } elseif (
+ $request->server->has($this->credentialKey)
+ && preg_match('#emailAddress=(.+\@.+\.[^,/]+)($|,|/)#', $request->server->get($this->credentialKey), $matches)
+ ) {
$user = $matches[1];
}
diff --git a/src/Symfony/Component/Security/Http/Tests/AccessMapTest.php b/src/Symfony/Component/Security/Http/Tests/AccessMapTest.php
index 8ae9581e2c848..1f5356ba9ee58 100644
--- a/src/Symfony/Component/Security/Http/Tests/AccessMapTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/AccessMapTest.php
@@ -45,7 +45,7 @@ private function getRequestMatcher($request, $matches)
$requestMatcher = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestMatcherInterface')->getMock();
$requestMatcher->expects($this->once())
->method('matches')->with($request)
- ->will($this->returnValue($matches));
+ ->willReturn($matches);
return $requestMatcher;
}
diff --git a/src/Symfony/Component/Security/Http/Tests/Authentication/DefaultAuthenticationFailureHandlerTest.php b/src/Symfony/Component/Security/Http/Tests/Authentication/DefaultAuthenticationFailureHandlerTest.php
index a9c18f3475d5c..a71ad179a3551 100644
--- a/src/Symfony/Component/Security/Http/Tests/Authentication/DefaultAuthenticationFailureHandlerTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/Authentication/DefaultAuthenticationFailureHandlerTest.php
@@ -34,7 +34,7 @@ protected function setUp()
$this->session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock();
$this->request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
- $this->request->expects($this->any())->method('getSession')->will($this->returnValue($this->session));
+ $this->request->expects($this->any())->method('getSession')->willReturn($this->session);
$this->exception = $this->getMockBuilder('Symfony\Component\Security\Core\Exception\AuthenticationException')->setMethods(['getMessage'])->getMock();
}
@@ -47,12 +47,12 @@ public function testForward()
->method('set')->with(Security::AUTHENTICATION_ERROR, $this->exception);
$this->httpUtils->expects($this->once())
->method('createRequest')->with($this->request, '/login')
- ->will($this->returnValue($subRequest));
+ ->willReturn($subRequest);
$response = new Response();
$this->httpKernel->expects($this->once())
->method('handle')->with($subRequest, HttpKernelInterface::SUB_REQUEST)
- ->will($this->returnValue($response));
+ ->willReturn($response);
$handler = new DefaultAuthenticationFailureHandler($this->httpKernel, $this->httpUtils, $options, $this->logger);
$result = $handler->onAuthenticationFailure($this->request, $this->exception);
@@ -65,7 +65,7 @@ public function testRedirect()
$response = new Response();
$this->httpUtils->expects($this->once())
->method('createRedirectResponse')->with($this->request, '/login')
- ->will($this->returnValue($response));
+ ->willReturn($response);
$handler = new DefaultAuthenticationFailureHandler($this->httpKernel, $this->httpUtils, [], $this->logger);
$result = $handler->onAuthenticationFailure($this->request, $this->exception);
@@ -92,7 +92,7 @@ public function testExceptionIsPassedInRequestOnForward()
$this->httpUtils->expects($this->once())
->method('createRequest')->with($this->request, '/login')
- ->will($this->returnValue($subRequest));
+ ->willReturn($subRequest);
$this->session->expects($this->never())->method('set');
@@ -117,7 +117,7 @@ public function testForwardIsLogged()
$this->httpUtils->expects($this->once())
->method('createRequest')->with($this->request, '/login')
- ->will($this->returnValue($this->getRequest()));
+ ->willReturn($this->getRequest());
$this->logger
->expects($this->once())
@@ -143,7 +143,7 @@ public function testFailurePathCanBeOverwrittenWithRequest()
{
$this->request->expects($this->once())
->method('get')->with('_failure_path')
- ->will($this->returnValue('/auth/login'));
+ ->willReturn('/auth/login');
$this->httpUtils->expects($this->once())
->method('createRedirectResponse')->with($this->request, '/auth/login');
@@ -156,7 +156,7 @@ public function testFailurePathCanBeOverwrittenWithNestedAttributeInRequest()
{
$this->request->expects($this->once())
->method('get')->with('_failure_path')
- ->will($this->returnValue(['value' => '/auth/login']));
+ ->willReturn(['value' => '/auth/login']);
$this->httpUtils->expects($this->once())
->method('createRedirectResponse')->with($this->request, '/auth/login');
@@ -171,7 +171,7 @@ public function testFailurePathParameterCanBeOverwritten()
$this->request->expects($this->once())
->method('get')->with('_my_failure_path')
- ->will($this->returnValue('/auth/login'));
+ ->willReturn('/auth/login');
$this->httpUtils->expects($this->once())
->method('createRedirectResponse')->with($this->request, '/auth/login');
diff --git a/src/Symfony/Component/Security/Http/Tests/Authentication/DefaultAuthenticationSuccessHandlerTest.php b/src/Symfony/Component/Security/Http/Tests/Authentication/DefaultAuthenticationSuccessHandlerTest.php
index 531d49227f2c2..8f0ba0728c874 100644
--- a/src/Symfony/Component/Security/Http/Tests/Authentication/DefaultAuthenticationSuccessHandlerTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/Authentication/DefaultAuthenticationSuccessHandlerTest.php
@@ -24,7 +24,7 @@ class DefaultAuthenticationSuccessHandlerTest extends TestCase
public function testRequestRedirections(Request $request, $options, $redirectedUrl)
{
$urlGenerator = $this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')->getMock();
- $urlGenerator->expects($this->any())->method('generate')->will($this->returnValue('http://localhost/login'));
+ $urlGenerator->expects($this->any())->method('generate')->willReturn('http://localhost/login');
$httpUtils = new HttpUtils($urlGenerator);
$token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
$handler = new DefaultAuthenticationSuccessHandler($httpUtils, $options);
@@ -37,7 +37,7 @@ public function testRequestRedirections(Request $request, $options, $redirectedU
public function getRequestRedirections()
{
$session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock();
- $session->expects($this->once())->method('get')->with('_security.admin.target_path')->will($this->returnValue('/admin/dashboard'));
+ $session->expects($this->once())->method('get')->with('_security.admin.target_path')->willReturn('/admin/dashboard');
$session->expects($this->once())->method('remove')->with('_security.admin.target_path');
$requestWithSession = Request::create('/');
$requestWithSession->setSession($session);
diff --git a/src/Symfony/Component/Security/Http/Tests/Authentication/SimpleAuthenticationHandlerTest.php b/src/Symfony/Component/Security/Http/Tests/Authentication/SimpleAuthenticationHandlerTest.php
index 4fce98602973a..c1c1c66f8256a 100644
--- a/src/Symfony/Component/Security/Http/Tests/Authentication/SimpleAuthenticationHandlerTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/Authentication/SimpleAuthenticationHandlerTest.php
@@ -56,7 +56,7 @@ public function testOnAuthenticationSuccessFallsBackToDefaultHandlerIfSimpleIsNo
$this->successHandler->expects($this->once())
->method('onAuthenticationSuccess')
->with($this->request, $this->token)
- ->will($this->returnValue($this->response));
+ ->willReturn($this->response);
$handler = new SimpleAuthenticationHandler($authenticator, $this->successHandler, $this->failureHandler);
$result = $handler->onAuthenticationSuccess($this->request, $this->token);
@@ -73,7 +73,7 @@ public function testOnAuthenticationSuccessCallsSimpleAuthenticator()
$authenticator->expects($this->once())
->method('onAuthenticationSuccess')
->with($this->request, $this->token)
- ->will($this->returnValue($this->response));
+ ->willReturn($this->response);
$handler = new SimpleAuthenticationHandler($authenticator, $this->successHandler, $this->failureHandler);
$result = $handler->onAuthenticationSuccess($this->request, $this->token);
@@ -94,7 +94,7 @@ public function testOnAuthenticationSuccessThrowsAnExceptionIfNonResponseIsRetur
$authenticator->expects($this->once())
->method('onAuthenticationSuccess')
->with($this->request, $this->token)
- ->will($this->returnValue(new \stdClass()));
+ ->willReturn(new \stdClass());
$handler = new SimpleAuthenticationHandler($authenticator, $this->successHandler, $this->failureHandler);
$handler->onAuthenticationSuccess($this->request, $this->token);
@@ -105,13 +105,13 @@ public function testOnAuthenticationSuccessFallsBackToDefaultHandlerIfNullIsRetu
$this->successHandler->expects($this->once())
->method('onAuthenticationSuccess')
->with($this->request, $this->token)
- ->will($this->returnValue($this->response));
+ ->willReturn($this->response);
$authenticator = $this->getMockForAbstractClass('Symfony\Component\Security\Http\Tests\TestSuccessHandlerInterface');
$authenticator->expects($this->once())
->method('onAuthenticationSuccess')
->with($this->request, $this->token)
- ->will($this->returnValue(null));
+ ->willReturn(null);
$handler = new SimpleAuthenticationHandler($authenticator, $this->successHandler, $this->failureHandler);
$result = $handler->onAuthenticationSuccess($this->request, $this->token);
@@ -126,7 +126,7 @@ public function testOnAuthenticationFailureFallsBackToDefaultHandlerIfSimpleIsNo
$this->failureHandler->expects($this->once())
->method('onAuthenticationFailure')
->with($this->request, $this->authenticationException)
- ->will($this->returnValue($this->response));
+ ->willReturn($this->response);
$handler = new SimpleAuthenticationHandler($authenticator, $this->successHandler, $this->failureHandler);
$result = $handler->onAuthenticationFailure($this->request, $this->authenticationException);
@@ -143,7 +143,7 @@ public function testOnAuthenticationFailureCallsSimpleAuthenticator()
$authenticator->expects($this->once())
->method('onAuthenticationFailure')
->with($this->request, $this->authenticationException)
- ->will($this->returnValue($this->response));
+ ->willReturn($this->response);
$handler = new SimpleAuthenticationHandler($authenticator, $this->successHandler, $this->failureHandler);
$result = $handler->onAuthenticationFailure($this->request, $this->authenticationException);
@@ -164,7 +164,7 @@ public function testOnAuthenticationFailureThrowsAnExceptionIfNonResponseIsRetur
$authenticator->expects($this->once())
->method('onAuthenticationFailure')
->with($this->request, $this->authenticationException)
- ->will($this->returnValue(new \stdClass()));
+ ->willReturn(new \stdClass());
$handler = new SimpleAuthenticationHandler($authenticator, $this->successHandler, $this->failureHandler);
$handler->onAuthenticationFailure($this->request, $this->authenticationException);
@@ -175,13 +175,13 @@ public function testOnAuthenticationFailureFallsBackToDefaultHandlerIfNullIsRetu
$this->failureHandler->expects($this->once())
->method('onAuthenticationFailure')
->with($this->request, $this->authenticationException)
- ->will($this->returnValue($this->response));
+ ->willReturn($this->response);
$authenticator = $this->getMockForAbstractClass('Symfony\Component\Security\Http\Tests\TestFailureHandlerInterface');
$authenticator->expects($this->once())
->method('onAuthenticationFailure')
->with($this->request, $this->authenticationException)
- ->will($this->returnValue(null));
+ ->willReturn(null);
$handler = new SimpleAuthenticationHandler($authenticator, $this->successHandler, $this->failureHandler);
$result = $handler->onAuthenticationFailure($this->request, $this->authenticationException);
diff --git a/src/Symfony/Component/Security/Http/Tests/EntryPoint/FormAuthenticationEntryPointTest.php b/src/Symfony/Component/Security/Http/Tests/EntryPoint/FormAuthenticationEntryPointTest.php
index 2e43f4ba63d65..999ff728bf461 100644
--- a/src/Symfony/Component/Security/Http/Tests/EntryPoint/FormAuthenticationEntryPointTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/EntryPoint/FormAuthenticationEntryPointTest.php
@@ -29,7 +29,7 @@ public function testStart()
->expects($this->once())
->method('createRedirectResponse')
->with($this->equalTo($request), $this->equalTo('/the/login/path'))
- ->will($this->returnValue($response))
+ ->willReturn($response)
;
$entryPoint = new FormAuthenticationEntryPoint($httpKernel, $httpUtils, '/the/login/path', false);
@@ -48,7 +48,7 @@ public function testStartWithUseForward()
->expects($this->once())
->method('createRequest')
->with($this->equalTo($request), $this->equalTo('/the/login/path'))
- ->will($this->returnValue($subRequest))
+ ->willReturn($subRequest)
;
$httpKernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
@@ -56,7 +56,7 @@ public function testStartWithUseForward()
->expects($this->once())
->method('handle')
->with($this->equalTo($subRequest), $this->equalTo(HttpKernelInterface::SUB_REQUEST))
- ->will($this->returnValue($response))
+ ->willReturn($response)
;
$entryPoint = new FormAuthenticationEntryPoint($httpKernel, $httpUtils, '/the/login/path', true);
diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/AbstractPreAuthenticatedListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/AbstractPreAuthenticatedListenerTest.php
index 44bbf4423be5b..c4ccdd6a69b2e 100644
--- a/src/Symfony/Component/Security/Http/Tests/Firewall/AbstractPreAuthenticatedListenerTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/Firewall/AbstractPreAuthenticatedListenerTest.php
@@ -31,7 +31,7 @@ public function testHandleWithValidValues()
$tokenStorage
->expects($this->any())
->method('getToken')
- ->will($this->returnValue(null))
+ ->willReturn(null)
;
$tokenStorage
->expects($this->once())
@@ -44,7 +44,7 @@ public function testHandleWithValidValues()
->expects($this->once())
->method('authenticate')
->with($this->isInstanceOf('Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken'))
- ->will($this->returnValue($token))
+ ->willReturn($token)
;
$listener = $this->getMockForAbstractClass('Symfony\Component\Security\Http\Firewall\AbstractPreAuthenticatedListener', [
@@ -55,13 +55,13 @@ public function testHandleWithValidValues()
$listener
->expects($this->once())
->method('getPreAuthenticatedData')
- ->will($this->returnValue($userCredentials));
+ ->willReturn($userCredentials);
$event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock();
$event
->expects($this->any())
->method('getRequest')
- ->will($this->returnValue($request))
+ ->willReturn($request)
;
$listener->handle($event);
@@ -77,7 +77,7 @@ public function testHandleWhenAuthenticationFails()
$tokenStorage
->expects($this->any())
->method('getToken')
- ->will($this->returnValue(null))
+ ->willReturn(null)
;
$tokenStorage
->expects($this->never())
@@ -101,13 +101,13 @@ public function testHandleWhenAuthenticationFails()
$listener
->expects($this->once())
->method('getPreAuthenticatedData')
- ->will($this->returnValue($userCredentials));
+ ->willReturn($userCredentials);
$event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock();
$event
->expects($this->any())
->method('getRequest')
- ->will($this->returnValue($request))
+ ->willReturn($request)
;
$listener->handle($event);
@@ -125,7 +125,7 @@ public function testHandleWhenAuthenticationFailsWithDifferentToken()
$tokenStorage
->expects($this->any())
->method('getToken')
- ->will($this->returnValue($token))
+ ->willReturn($token)
;
$tokenStorage
->expects($this->never())
@@ -149,13 +149,13 @@ public function testHandleWhenAuthenticationFailsWithDifferentToken()
$listener
->expects($this->once())
->method('getPreAuthenticatedData')
- ->will($this->returnValue($userCredentials));
+ ->willReturn($userCredentials);
$event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock();
$event
->expects($this->any())
->method('getRequest')
- ->will($this->returnValue($request))
+ ->willReturn($request)
;
$listener->handle($event);
@@ -173,7 +173,7 @@ public function testHandleWithASimilarAuthenticatedToken()
$tokenStorage
->expects($this->any())
->method('getToken')
- ->will($this->returnValue($token))
+ ->willReturn($token)
;
$authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock();
@@ -190,13 +190,13 @@ public function testHandleWithASimilarAuthenticatedToken()
$listener
->expects($this->once())
->method('getPreAuthenticatedData')
- ->will($this->returnValue($userCredentials));
+ ->willReturn($userCredentials);
$event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock();
$event
->expects($this->any())
->method('getRequest')
- ->will($this->returnValue($request))
+ ->willReturn($request)
;
$listener->handle($event);
@@ -214,7 +214,7 @@ public function testHandleWithAnInvalidSimilarToken()
$tokenStorage
->expects($this->any())
->method('getToken')
- ->will($this->returnValue($token))
+ ->willReturn($token)
;
$tokenStorage
->expects($this->once())
@@ -239,13 +239,13 @@ public function testHandleWithAnInvalidSimilarToken()
$listener
->expects($this->once())
->method('getPreAuthenticatedData')
- ->will($this->returnValue($userCredentials));
+ ->willReturn($userCredentials);
$event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock();
$event
->expects($this->any())
->method('getRequest')
- ->will($this->returnValue($request))
+ ->willReturn($request)
;
$listener->handle($event);
diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/AccessListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/AccessListenerTest.php
index 92b2270877fbc..0bb27258befe0 100644
--- a/src/Symfony/Component/Security/Http/Tests/Firewall/AccessListenerTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/Firewall/AccessListenerTest.php
@@ -28,21 +28,21 @@ public function testHandleWhenTheAccessDecisionManagerDecidesToRefuseAccess()
->expects($this->any())
->method('getPatterns')
->with($this->equalTo($request))
- ->will($this->returnValue([['foo' => 'bar'], null]))
+ ->willReturn([['foo' => 'bar'], null])
;
$token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
$token
->expects($this->any())
->method('isAuthenticated')
- ->will($this->returnValue(true))
+ ->willReturn(true)
;
$tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
$tokenStorage
->expects($this->any())
->method('getToken')
- ->will($this->returnValue($token))
+ ->willReturn($token)
;
$accessDecisionManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface')->getMock();
@@ -50,7 +50,7 @@ public function testHandleWhenTheAccessDecisionManagerDecidesToRefuseAccess()
->expects($this->once())
->method('decide')
->with($this->equalTo($token), $this->equalTo(['foo' => 'bar']), $this->equalTo($request))
- ->will($this->returnValue(false))
+ ->willReturn(false)
;
$listener = new AccessListener(
@@ -64,7 +64,7 @@ public function testHandleWhenTheAccessDecisionManagerDecidesToRefuseAccess()
$event
->expects($this->any())
->method('getRequest')
- ->will($this->returnValue($request))
+ ->willReturn($request)
;
$listener->handle($event);
@@ -79,21 +79,21 @@ public function testHandleWhenTheTokenIsNotAuthenticated()
->expects($this->any())
->method('getPatterns')
->with($this->equalTo($request))
- ->will($this->returnValue([['foo' => 'bar'], null]))
+ ->willReturn([['foo' => 'bar'], null])
;
$notAuthenticatedToken = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
$notAuthenticatedToken
->expects($this->any())
->method('isAuthenticated')
- ->will($this->returnValue(false))
+ ->willReturn(false)
;
$authenticatedToken = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
$authenticatedToken
->expects($this->any())
->method('isAuthenticated')
- ->will($this->returnValue(true))
+ ->willReturn(true)
;
$authManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock();
@@ -101,14 +101,14 @@ public function testHandleWhenTheTokenIsNotAuthenticated()
->expects($this->once())
->method('authenticate')
->with($this->equalTo($notAuthenticatedToken))
- ->will($this->returnValue($authenticatedToken))
+ ->willReturn($authenticatedToken)
;
$tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
$tokenStorage
->expects($this->any())
->method('getToken')
- ->will($this->returnValue($notAuthenticatedToken))
+ ->willReturn($notAuthenticatedToken)
;
$tokenStorage
->expects($this->once())
@@ -121,7 +121,7 @@ public function testHandleWhenTheTokenIsNotAuthenticated()
->expects($this->once())
->method('decide')
->with($this->equalTo($authenticatedToken), $this->equalTo(['foo' => 'bar']), $this->equalTo($request))
- ->will($this->returnValue(true))
+ ->willReturn(true)
;
$listener = new AccessListener(
@@ -135,7 +135,7 @@ public function testHandleWhenTheTokenIsNotAuthenticated()
$event
->expects($this->any())
->method('getRequest')
- ->will($this->returnValue($request))
+ ->willReturn($request)
;
$listener->handle($event);
@@ -150,7 +150,7 @@ public function testHandleWhenThereIsNoAccessMapEntryMatchingTheRequest()
->expects($this->any())
->method('getPatterns')
->with($this->equalTo($request))
- ->will($this->returnValue([null, null]))
+ ->willReturn([null, null])
;
$token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
@@ -163,7 +163,7 @@ public function testHandleWhenThereIsNoAccessMapEntryMatchingTheRequest()
$tokenStorage
->expects($this->any())
->method('getToken')
- ->will($this->returnValue($token))
+ ->willReturn($token)
;
$listener = new AccessListener(
@@ -177,7 +177,7 @@ public function testHandleWhenThereIsNoAccessMapEntryMatchingTheRequest()
$event
->expects($this->any())
->method('getRequest')
- ->will($this->returnValue($request))
+ ->willReturn($request)
;
$listener->handle($event);
@@ -192,7 +192,7 @@ public function testHandleWhenTheSecurityTokenStorageHasNoToken()
$tokenStorage
->expects($this->any())
->method('getToken')
- ->will($this->returnValue(null))
+ ->willReturn(null)
;
$listener = new AccessListener(
diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/AnonymousAuthenticationListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/AnonymousAuthenticationListenerTest.php
index f6f36415d37e1..15b151a5cf828 100644
--- a/src/Symfony/Component/Security/Http/Tests/Firewall/AnonymousAuthenticationListenerTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/Firewall/AnonymousAuthenticationListenerTest.php
@@ -23,7 +23,7 @@ public function testHandleWithTokenStorageHavingAToken()
$tokenStorage
->expects($this->any())
->method('getToken')
- ->will($this->returnValue($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()))
+ ->willReturn($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock())
;
$tokenStorage
->expects($this->never())
@@ -46,7 +46,7 @@ public function testHandleWithTokenStorageHavingNoToken()
$tokenStorage
->expects($this->any())
->method('getToken')
- ->will($this->returnValue(null))
+ ->willReturn(null)
;
$anonymousToken = new AnonymousToken('TheSecret', 'anon.', []);
@@ -58,7 +58,7 @@ public function testHandleWithTokenStorageHavingNoToken()
->with($this->callback(function ($token) {
return 'TheSecret' === $token->getSecret();
}))
- ->will($this->returnValue($anonymousToken))
+ ->willReturn($anonymousToken)
;
$tokenStorage
diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/BasicAuthenticationListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/BasicAuthenticationListenerTest.php
index 2eec46b1d16a6..e331542369f53 100644
--- a/src/Symfony/Component/Security/Http/Tests/Firewall/BasicAuthenticationListenerTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/Firewall/BasicAuthenticationListenerTest.php
@@ -34,7 +34,7 @@ public function testHandleWithValidUsernameAndPasswordServerParameters()
$tokenStorage
->expects($this->any())
->method('getToken')
- ->will($this->returnValue(null))
+ ->willReturn(null)
;
$tokenStorage
->expects($this->once())
@@ -47,7 +47,7 @@ public function testHandleWithValidUsernameAndPasswordServerParameters()
->expects($this->once())
->method('authenticate')
->with($this->isInstanceOf('Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken'))
- ->will($this->returnValue($token))
+ ->willReturn($token)
;
$listener = new BasicAuthenticationListener(
@@ -61,7 +61,7 @@ public function testHandleWithValidUsernameAndPasswordServerParameters()
$event
->expects($this->any())
->method('getRequest')
- ->will($this->returnValue($request))
+ ->willReturn($request)
;
$listener->handle($event);
@@ -80,7 +80,7 @@ public function testHandleWhenAuthenticationFails()
$tokenStorage
->expects($this->any())
->method('getToken')
- ->will($this->returnValue(null))
+ ->willReturn(null)
;
$tokenStorage
->expects($this->never())
@@ -94,7 +94,7 @@ public function testHandleWhenAuthenticationFails()
->expects($this->any())
->method('start')
->with($this->equalTo($request), $this->isInstanceOf('Symfony\Component\Security\Core\Exception\AuthenticationException'))
- ->will($this->returnValue($response))
+ ->willReturn($response)
;
$listener = new BasicAuthenticationListener(
@@ -108,7 +108,7 @@ public function testHandleWhenAuthenticationFails()
$event
->expects($this->any())
->method('getRequest')
- ->will($this->returnValue($request))
+ ->willReturn($request)
;
$event
->expects($this->once())
@@ -140,7 +140,7 @@ public function testHandleWithNoUsernameServerParameter()
$event
->expects($this->any())
->method('getRequest')
- ->will($this->returnValue($request))
+ ->willReturn($request)
;
$listener->handle($event);
@@ -156,7 +156,7 @@ public function testHandleWithASimilarAuthenticatedToken()
$tokenStorage
->expects($this->any())
->method('getToken')
- ->will($this->returnValue($token))
+ ->willReturn($token)
;
$authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock();
@@ -176,7 +176,7 @@ public function testHandleWithASimilarAuthenticatedToken()
$event
->expects($this->any())
->method('getRequest')
- ->will($this->returnValue($request))
+ ->willReturn($request)
;
$listener->handle($event);
@@ -209,7 +209,7 @@ public function testHandleWithADifferentAuthenticatedToken()
$tokenStorage
->expects($this->any())
->method('getToken')
- ->will($this->returnValue($token))
+ ->willReturn($token)
;
$tokenStorage
->expects($this->never())
@@ -223,7 +223,7 @@ public function testHandleWithADifferentAuthenticatedToken()
->expects($this->any())
->method('start')
->with($this->equalTo($request), $this->isInstanceOf('Symfony\Component\Security\Core\Exception\AuthenticationException'))
- ->will($this->returnValue($response))
+ ->willReturn($response)
;
$listener = new BasicAuthenticationListener(
@@ -237,7 +237,7 @@ public function testHandleWithADifferentAuthenticatedToken()
$event
->expects($this->any())
->method('getRequest')
- ->will($this->returnValue($request))
+ ->willReturn($request)
;
$event
->expects($this->once())
diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/ChannelListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/ChannelListenerTest.php
index 3740faec8ba8e..3511c629c1d4e 100644
--- a/src/Symfony/Component/Security/Http/Tests/Firewall/ChannelListenerTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/Firewall/ChannelListenerTest.php
@@ -23,7 +23,7 @@ public function testHandleWithNotSecuredRequestAndHttpChannel()
$request
->expects($this->any())
->method('isSecure')
- ->will($this->returnValue(false))
+ ->willReturn(false)
;
$accessMap = $this->getMockBuilder('Symfony\Component\Security\Http\AccessMapInterface')->getMock();
@@ -31,7 +31,7 @@ public function testHandleWithNotSecuredRequestAndHttpChannel()
->expects($this->any())
->method('getPatterns')
->with($this->equalTo($request))
- ->will($this->returnValue([[], 'http']))
+ ->willReturn([[], 'http'])
;
$entryPoint = $this->getMockBuilder('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')->getMock();
@@ -44,7 +44,7 @@ public function testHandleWithNotSecuredRequestAndHttpChannel()
$event
->expects($this->any())
->method('getRequest')
- ->will($this->returnValue($request))
+ ->willReturn($request)
;
$event
->expects($this->never())
@@ -61,7 +61,7 @@ public function testHandleWithSecuredRequestAndHttpsChannel()
$request
->expects($this->any())
->method('isSecure')
- ->will($this->returnValue(true))
+ ->willReturn(true)
;
$accessMap = $this->getMockBuilder('Symfony\Component\Security\Http\AccessMapInterface')->getMock();
@@ -69,7 +69,7 @@ public function testHandleWithSecuredRequestAndHttpsChannel()
->expects($this->any())
->method('getPatterns')
->with($this->equalTo($request))
- ->will($this->returnValue([[], 'https']))
+ ->willReturn([[], 'https'])
;
$entryPoint = $this->getMockBuilder('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')->getMock();
@@ -82,7 +82,7 @@ public function testHandleWithSecuredRequestAndHttpsChannel()
$event
->expects($this->any())
->method('getRequest')
- ->will($this->returnValue($request))
+ ->willReturn($request)
;
$event
->expects($this->never())
@@ -99,7 +99,7 @@ public function testHandleWithNotSecuredRequestAndHttpsChannel()
$request
->expects($this->any())
->method('isSecure')
- ->will($this->returnValue(false))
+ ->willReturn(false)
;
$response = new Response();
@@ -109,7 +109,7 @@ public function testHandleWithNotSecuredRequestAndHttpsChannel()
->expects($this->any())
->method('getPatterns')
->with($this->equalTo($request))
- ->will($this->returnValue([[], 'https']))
+ ->willReturn([[], 'https'])
;
$entryPoint = $this->getMockBuilder('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')->getMock();
@@ -117,14 +117,14 @@ public function testHandleWithNotSecuredRequestAndHttpsChannel()
->expects($this->once())
->method('start')
->with($this->equalTo($request))
- ->will($this->returnValue($response))
+ ->willReturn($response)
;
$event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock();
$event
->expects($this->any())
->method('getRequest')
- ->will($this->returnValue($request))
+ ->willReturn($request)
;
$event
->expects($this->once())
@@ -142,7 +142,7 @@ public function testHandleWithSecuredRequestAndHttpChannel()
$request
->expects($this->any())
->method('isSecure')
- ->will($this->returnValue(true))
+ ->willReturn(true)
;
$response = new Response();
@@ -152,7 +152,7 @@ public function testHandleWithSecuredRequestAndHttpChannel()
->expects($this->any())
->method('getPatterns')
->with($this->equalTo($request))
- ->will($this->returnValue([[], 'http']))
+ ->willReturn([[], 'http'])
;
$entryPoint = $this->getMockBuilder('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')->getMock();
@@ -160,14 +160,14 @@ public function testHandleWithSecuredRequestAndHttpChannel()
->expects($this->once())
->method('start')
->with($this->equalTo($request))
- ->will($this->returnValue($response))
+ ->willReturn($response)
;
$event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock();
$event
->expects($this->any())
->method('getRequest')
- ->will($this->returnValue($request))
+ ->willReturn($request)
;
$event
->expects($this->once())
diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/ContextListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/ContextListenerTest.php
index e3c55d33ed1cd..002f48daa9cb0 100644
--- a/src/Symfony/Component/Security/Http/Tests/Firewall/ContextListenerTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/Firewall/ContextListenerTest.php
@@ -151,17 +151,17 @@ public function testInvalidTokenInSession($token)
$event->expects($this->any())
->method('getRequest')
- ->will($this->returnValue($request));
+ ->willReturn($request);
$request->expects($this->any())
->method('hasPreviousSession')
- ->will($this->returnValue(true));
+ ->willReturn(true);
$request->expects($this->any())
->method('getSession')
- ->will($this->returnValue($session));
+ ->willReturn($session);
$session->expects($this->any())
->method('get')
->with('_security_key123')
- ->will($this->returnValue($token));
+ ->willReturn($token);
$tokenStorage->expects($this->once())
->method('setToken')
->with(null);
@@ -193,10 +193,10 @@ public function testHandleAddsKernelResponseListener()
$event->expects($this->any())
->method('isMasterRequest')
- ->will($this->returnValue(true));
+ ->willReturn(true);
$event->expects($this->any())
->method('getRequest')
- ->will($this->returnValue($this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock()));
+ ->willReturn($this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock());
$dispatcher->expects($this->once())
->method('addListener')
@@ -218,14 +218,14 @@ public function testOnKernelResponseListenerRemovesItself()
$request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
$request->expects($this->any())
->method('hasSession')
- ->will($this->returnValue(true));
+ ->willReturn(true);
$event->expects($this->any())
->method('isMasterRequest')
- ->will($this->returnValue(true));
+ ->willReturn(true);
$event->expects($this->any())
->method('getRequest')
- ->will($this->returnValue($request));
+ ->willReturn($request);
$dispatcher->expects($this->once())
->method('removeListener')
@@ -237,12 +237,12 @@ public function testOnKernelResponseListenerRemovesItself()
public function testHandleRemovesTokenIfNoPreviousSessionWasFound()
{
$request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
- $request->expects($this->any())->method('hasPreviousSession')->will($this->returnValue(false));
+ $request->expects($this->any())->method('hasPreviousSession')->willReturn(false);
$event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')
->disableOriginalConstructor()
->getMock();
- $event->expects($this->any())->method('getRequest')->will($this->returnValue($request));
+ $event->expects($this->any())->method('getRequest')->willReturn($request);
$tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
$tokenStorage->expects($this->once())->method('setToken')->with(null);
diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/ExceptionListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/ExceptionListenerTest.php
index 53fedebcad705..1dda0ab968c78 100644
--- a/src/Symfony/Component/Security/Http/Tests/Firewall/ExceptionListenerTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/Firewall/ExceptionListenerTest.php
@@ -77,7 +77,7 @@ public function testExceptionWhenEntryPointReturnsBadValue()
$event = $this->createEvent(new AuthenticationException());
$entryPoint = $this->getMockBuilder('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')->getMock();
- $entryPoint->expects($this->once())->method('start')->will($this->returnValue('NOT A RESPONSE'));
+ $entryPoint->expects($this->once())->method('start')->willReturn('NOT A RESPONSE');
$listener = $this->createExceptionListener(null, null, null, $entryPoint);
$listener->onKernelException($event);
@@ -106,12 +106,12 @@ public function testAccessDeniedExceptionFullFledgedAndWithoutAccessDeniedHandle
public function testAccessDeniedExceptionFullFledgedAndWithoutAccessDeniedHandlerAndWithErrorPage(\Exception $exception, \Exception $eventException = null)
{
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
- $kernel->expects($this->once())->method('handle')->will($this->returnValue(new Response('Unauthorized', 401)));
+ $kernel->expects($this->once())->method('handle')->willReturn(new Response('Unauthorized', 401));
$event = $this->createEvent($exception, $kernel);
$httpUtils = $this->getMockBuilder('Symfony\Component\Security\Http\HttpUtils')->getMock();
- $httpUtils->expects($this->once())->method('createRequest')->will($this->returnValue(Request::create('/error')));
+ $httpUtils->expects($this->once())->method('createRequest')->willReturn(Request::create('/error'));
$listener = $this->createExceptionListener(null, $this->createTrustResolver(true), $httpUtils, null, '/error');
$listener->onKernelException($event);
@@ -131,7 +131,7 @@ public function testAccessDeniedExceptionFullFledgedAndWithAccessDeniedHandlerAn
$event = $this->createEvent($exception);
$accessDeniedHandler = $this->getMockBuilder('Symfony\Component\Security\Http\Authorization\AccessDeniedHandlerInterface')->getMock();
- $accessDeniedHandler->expects($this->once())->method('handle')->will($this->returnValue(new Response('error')));
+ $accessDeniedHandler->expects($this->once())->method('handle')->willReturn(new Response('error'));
$listener = $this->createExceptionListener(null, $this->createTrustResolver(true), null, null, null, $accessDeniedHandler);
$listener->onKernelException($event);
@@ -148,7 +148,7 @@ public function testAccessDeniedExceptionNotFullFledged(\Exception $exception, \
$event = $this->createEvent($exception);
$tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
- $tokenStorage->expects($this->once())->method('getToken')->will($this->returnValue($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()));
+ $tokenStorage->expects($this->once())->method('getToken')->willReturn($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock());
$listener = $this->createExceptionListener($tokenStorage, $this->createTrustResolver(false), null, $this->createEntryPoint());
$listener->onKernelException($event);
@@ -171,7 +171,7 @@ public function getAccessDeniedExceptionProvider()
private function createEntryPoint(Response $response = null)
{
$entryPoint = $this->getMockBuilder('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')->getMock();
- $entryPoint->expects($this->once())->method('start')->will($this->returnValue($response ?: new Response('OK')));
+ $entryPoint->expects($this->once())->method('start')->willReturn($response ?: new Response('OK'));
return $entryPoint;
}
@@ -179,7 +179,7 @@ private function createEntryPoint(Response $response = null)
private function createTrustResolver($fullFledged)
{
$trustResolver = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolverInterface')->getMock();
- $trustResolver->expects($this->once())->method('isFullFledged')->will($this->returnValue($fullFledged));
+ $trustResolver->expects($this->once())->method('isFullFledged')->willReturn($fullFledged);
return $trustResolver;
}
diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/LogoutListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/LogoutListenerTest.php
index fbcea3d738e70..3796f871562c6 100644
--- a/src/Symfony/Component/Security/Http/Tests/Firewall/LogoutListenerTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/Firewall/LogoutListenerTest.php
@@ -30,7 +30,7 @@ public function testHandleUnmatchedPath()
$httpUtils->expects($this->once())
->method('checkRequestPath')
->with($request, $options['logout_path'])
- ->will($this->returnValue(false));
+ ->willReturn(false);
$listener->handle($event);
}
@@ -49,20 +49,20 @@ public function testHandleMatchedPathWithSuccessHandlerAndCsrfValidation()
$httpUtils->expects($this->once())
->method('checkRequestPath')
->with($request, $options['logout_path'])
- ->will($this->returnValue(true));
+ ->willReturn(true);
$tokenManager->expects($this->once())
->method('isTokenValid')
- ->will($this->returnValue(true));
+ ->willReturn(true);
$successHandler->expects($this->once())
->method('onLogoutSuccess')
->with($request)
- ->will($this->returnValue($response = new Response()));
+ ->willReturn($response = new Response());
$tokenStorage->expects($this->once())
->method('getToken')
- ->will($this->returnValue($token = $this->getToken()));
+ ->willReturn($token = $this->getToken());
$handler = $this->getHandler();
$handler->expects($this->once())
@@ -93,16 +93,16 @@ public function testHandleMatchedPathWithoutSuccessHandlerAndCsrfValidation()
$httpUtils->expects($this->once())
->method('checkRequestPath')
->with($request, $options['logout_path'])
- ->will($this->returnValue(true));
+ ->willReturn(true);
$successHandler->expects($this->once())
->method('onLogoutSuccess')
->with($request)
- ->will($this->returnValue($response = new Response()));
+ ->willReturn($response = new Response());
$tokenStorage->expects($this->once())
->method('getToken')
- ->will($this->returnValue($token = $this->getToken()));
+ ->willReturn($token = $this->getToken());
$handler = $this->getHandler();
$handler->expects($this->once())
@@ -136,12 +136,12 @@ public function testSuccessHandlerReturnsNonResponse()
$httpUtils->expects($this->once())
->method('checkRequestPath')
->with($request, $options['logout_path'])
- ->will($this->returnValue(true));
+ ->willReturn(true);
$successHandler->expects($this->once())
->method('onLogoutSuccess')
->with($request)
- ->will($this->returnValue(null));
+ ->willReturn(null);
$listener->handle($event);
}
@@ -162,11 +162,11 @@ public function testCsrfValidationFails()
$httpUtils->expects($this->once())
->method('checkRequestPath')
->with($request, $options['logout_path'])
- ->will($this->returnValue(true));
+ ->willReturn(true);
$tokenManager->expects($this->once())
->method('isTokenValid')
- ->will($this->returnValue(false));
+ ->willReturn(false);
$listener->handle($event);
}
@@ -189,7 +189,7 @@ private function getGetResponseEvent()
$event->expects($this->any())
->method('getRequest')
- ->will($this->returnValue($request = new Request()));
+ ->willReturn($request = new Request());
return [$event, $request];
}
diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/RememberMeListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/RememberMeListenerTest.php
index 686c7231e6899..57d297103ec80 100644
--- a/src/Symfony/Component/Security/Http/Tests/Firewall/RememberMeListenerTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/Firewall/RememberMeListenerTest.php
@@ -26,7 +26,7 @@ public function testOnCoreSecurityDoesNotTryToPopulateNonEmptyTokenStorage()
$tokenStorage
->expects($this->once())
->method('getToken')
- ->will($this->returnValue($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()))
+ ->willReturn($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock())
;
$tokenStorage
@@ -44,20 +44,20 @@ public function testOnCoreSecurityDoesNothingWhenNoCookieIsSet()
$tokenStorage
->expects($this->once())
->method('getToken')
- ->will($this->returnValue(null))
+ ->willReturn(null)
;
$service
->expects($this->once())
->method('autoLogin')
- ->will($this->returnValue(null))
+ ->willReturn(null)
;
$event = $this->getGetResponseEvent();
$event
->expects($this->once())
->method('getRequest')
- ->will($this->returnValue(new Request()))
+ ->willReturn(new Request())
;
$this->assertNull($listener->handle($event));
@@ -72,13 +72,13 @@ public function testOnCoreSecurityIgnoresAuthenticationExceptionThrownByAuthenti
$tokenStorage
->expects($this->once())
->method('getToken')
- ->will($this->returnValue(null))
+ ->willReturn(null)
;
$service
->expects($this->once())
->method('autoLogin')
- ->will($this->returnValue($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()))
+ ->willReturn($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock())
;
$service
@@ -97,7 +97,7 @@ public function testOnCoreSecurityIgnoresAuthenticationExceptionThrownByAuthenti
$event
->expects($this->once())
->method('getRequest')
- ->will($this->returnValue($request))
+ ->willReturn($request)
;
$listener->handle($event);
@@ -114,13 +114,13 @@ public function testOnCoreSecurityIgnoresAuthenticationOptionallyRethrowsExcepti
$tokenStorage
->expects($this->once())
->method('getToken')
- ->will($this->returnValue(null))
+ ->willReturn(null)
;
$service
->expects($this->once())
->method('autoLogin')
- ->will($this->returnValue($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()))
+ ->willReturn($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock())
;
$service
@@ -139,7 +139,7 @@ public function testOnCoreSecurityIgnoresAuthenticationOptionallyRethrowsExcepti
$event
->expects($this->once())
->method('getRequest')
- ->will($this->returnValue(new Request()))
+ ->willReturn(new Request())
;
$listener->handle($event);
@@ -152,7 +152,7 @@ public function testOnCoreSecurityAuthenticationExceptionDuringAutoLoginTriggers
$tokenStorage
->expects($this->once())
->method('getToken')
- ->will($this->returnValue(null))
+ ->willReturn(null)
;
$exception = new AuthenticationException('Authentication failed.');
@@ -176,7 +176,7 @@ public function testOnCoreSecurityAuthenticationExceptionDuringAutoLoginTriggers
$event
->expects($this->once())
->method('getRequest')
- ->will($this->returnValue(new Request()))
+ ->willReturn(new Request())
;
$listener->handle($event);
@@ -189,14 +189,14 @@ public function testOnCoreSecurity()
$tokenStorage
->expects($this->once())
->method('getToken')
- ->will($this->returnValue(null))
+ ->willReturn(null)
;
$token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
$service
->expects($this->once())
->method('autoLogin')
- ->will($this->returnValue($token))
+ ->willReturn($token)
;
$tokenStorage
@@ -208,14 +208,14 @@ public function testOnCoreSecurity()
$manager
->expects($this->once())
->method('authenticate')
- ->will($this->returnValue($token))
+ ->willReturn($token)
;
$event = $this->getGetResponseEvent();
$event
->expects($this->once())
->method('getRequest')
- ->will($this->returnValue(new Request()))
+ ->willReturn(new Request())
;
$listener->handle($event);
@@ -228,14 +228,14 @@ public function testSessionStrategy()
$tokenStorage
->expects($this->once())
->method('getToken')
- ->will($this->returnValue(null))
+ ->willReturn(null)
;
$token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
$service
->expects($this->once())
->method('autoLogin')
- ->will($this->returnValue($token))
+ ->willReturn($token)
;
$tokenStorage
@@ -247,40 +247,40 @@ public function testSessionStrategy()
$manager
->expects($this->once())
->method('authenticate')
- ->will($this->returnValue($token))
+ ->willReturn($token)
;
$session = $this->getMockBuilder('\Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock();
$session
->expects($this->once())
->method('isStarted')
- ->will($this->returnValue(true))
+ ->willReturn(true)
;
$request = $this->getMockBuilder('\Symfony\Component\HttpFoundation\Request')->getMock();
$request
->expects($this->once())
->method('hasSession')
- ->will($this->returnValue(true))
+ ->willReturn(true)
;
$request
->expects($this->once())
->method('getSession')
- ->will($this->returnValue($session))
+ ->willReturn($session)
;
$event = $this->getGetResponseEvent();
$event
->expects($this->once())
->method('getRequest')
- ->will($this->returnValue($request))
+ ->willReturn($request)
;
$sessionStrategy
->expects($this->once())
->method('onAuthentication')
- ->will($this->returnValue(null))
+ ->willReturn(null)
;
$listener->handle($event);
@@ -293,14 +293,14 @@ public function testSessionIsMigratedByDefault()
$tokenStorage
->expects($this->once())
->method('getToken')
- ->will($this->returnValue(null))
+ ->willReturn(null)
;
$token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
$service
->expects($this->once())
->method('autoLogin')
- ->will($this->returnValue($token))
+ ->willReturn($token)
;
$tokenStorage
@@ -312,14 +312,14 @@ public function testSessionIsMigratedByDefault()
$manager
->expects($this->once())
->method('authenticate')
- ->will($this->returnValue($token))
+ ->willReturn($token)
;
$session = $this->getMockBuilder('\Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock();
$session
->expects($this->once())
->method('isStarted')
- ->will($this->returnValue(true))
+ ->willReturn(true)
;
$session
->expects($this->once())
@@ -330,20 +330,20 @@ public function testSessionIsMigratedByDefault()
$request
->expects($this->any())
->method('hasSession')
- ->will($this->returnValue(true))
+ ->willReturn(true)
;
$request
->expects($this->any())
->method('getSession')
- ->will($this->returnValue($session))
+ ->willReturn($session)
;
$event = $this->getGetResponseEvent();
$event
->expects($this->once())
->method('getRequest')
- ->will($this->returnValue($request))
+ ->willReturn($request)
;
$listener->handle($event);
@@ -356,14 +356,14 @@ public function testOnCoreSecurityInteractiveLoginEventIsDispatchedIfDispatcherI
$tokenStorage
->expects($this->once())
->method('getToken')
- ->will($this->returnValue(null))
+ ->willReturn(null)
;
$token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
$service
->expects($this->once())
->method('autoLogin')
- ->will($this->returnValue($token))
+ ->willReturn($token)
;
$tokenStorage
@@ -375,7 +375,7 @@ public function testOnCoreSecurityInteractiveLoginEventIsDispatchedIfDispatcherI
$manager
->expects($this->once())
->method('authenticate')
- ->will($this->returnValue($token))
+ ->willReturn($token)
;
$event = $this->getGetResponseEvent();
@@ -383,7 +383,7 @@ public function testOnCoreSecurityInteractiveLoginEventIsDispatchedIfDispatcherI
$event
->expects($this->once())
->method('getRequest')
- ->will($this->returnValue($request))
+ ->willReturn($request)
;
$dispatcher
diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/SimplePreAuthenticationListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/SimplePreAuthenticationListenerTest.php
index e35c9e97f2422..9d62858fc936e 100644
--- a/src/Symfony/Component/Security/Http/Tests/Firewall/SimplePreAuthenticationListenerTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/Firewall/SimplePreAuthenticationListenerTest.php
@@ -43,7 +43,7 @@ public function testHandle()
->expects($this->once())
->method('authenticate')
->with($this->equalTo($this->token))
- ->will($this->returnValue($this->token))
+ ->willReturn($this->token)
;
$simpleAuthenticator = $this->getMockBuilder('Symfony\Component\Security\Http\Authentication\SimplePreAuthenticatorInterface')->getMock();
@@ -51,7 +51,7 @@ public function testHandle()
->expects($this->once())
->method('createToken')
->with($this->equalTo($this->request), $this->equalTo('secured_area'))
- ->will($this->returnValue($this->token))
+ ->willReturn($this->token)
;
$loginEvent = new InteractiveLoginEvent($this->request, $this->token);
@@ -88,7 +88,7 @@ public function testHandlecatchAuthenticationException()
->expects($this->once())
->method('createToken')
->with($this->equalTo($this->request), $this->equalTo('secured_area'))
- ->will($this->returnValue($this->token))
+ ->willReturn($this->token)
;
$listener = new SimplePreAuthenticationListener($this->tokenStorage, $this->authenticationManager, 'secured_area', $simpleAuthenticator, $this->logger, $this->dispatcher);
@@ -111,7 +111,7 @@ protected function setUp()
$this->event
->expects($this->any())
->method('getRequest')
- ->will($this->returnValue($this->request))
+ ->willReturn($this->request)
;
$this->logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/SwitchUserListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/SwitchUserListenerTest.php
index f26b72fc148e1..6e3b0e30f81d7 100644
--- a/src/Symfony/Component/Security/Http/Tests/Firewall/SwitchUserListenerTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/Firewall/SwitchUserListenerTest.php
@@ -167,7 +167,7 @@ public function testSwitchUserIsDisallowed()
$this->accessDecisionManager->expects($this->once())
->method('decide')->with($token, ['ROLE_ALLOWED_TO_SWITCH'])
- ->will($this->returnValue(false));
+ ->willReturn(false);
$listener = new SwitchUserListener($this->tokenStorage, $this->userProvider, $this->userChecker, 'provider123', $this->accessDecisionManager);
$listener->handle($this->event);
@@ -183,11 +183,11 @@ public function testSwitchUser()
$this->accessDecisionManager->expects($this->once())
->method('decide')->with($token, ['ROLE_ALLOWED_TO_SWITCH'], $user)
- ->will($this->returnValue(true));
+ ->willReturn(true);
$this->userProvider->expects($this->once())
->method('loadUserByUsername')->with('kuba')
- ->will($this->returnValue($user));
+ ->willReturn($user);
$this->userChecker->expects($this->once())
->method('checkPostAuth')->with($user);
@@ -213,11 +213,11 @@ public function testSwitchUserKeepsOtherQueryStringParameters()
$this->accessDecisionManager->expects($this->once())
->method('decide')->with($token, ['ROLE_ALLOWED_TO_SWITCH'], $user)
- ->will($this->returnValue(true));
+ ->willReturn(true);
$this->userProvider->expects($this->once())
->method('loadUserByUsername')->with('kuba')
- ->will($this->returnValue($user));
+ ->willReturn($user);
$this->userChecker->expects($this->once())
->method('checkPostAuth')->with($user);
@@ -241,11 +241,11 @@ public function testSwitchUserWithReplacedToken()
$this->accessDecisionManager->expects($this->any())
->method('decide')->with($token, ['ROLE_ALLOWED_TO_SWITCH'], $user)
- ->will($this->returnValue(true));
+ ->willReturn(true);
$this->userProvider->expects($this->any())
->method('loadUserByUsername')->with('kuba')
- ->will($this->returnValue($user));
+ ->willReturn($user);
$dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();
$dispatcher
@@ -288,11 +288,11 @@ public function testSwitchUserStateless()
$this->accessDecisionManager->expects($this->once())
->method('decide')->with($token, ['ROLE_ALLOWED_TO_SWITCH'], $user)
- ->will($this->returnValue(true));
+ ->willReturn(true);
$this->userProvider->expects($this->once())
->method('loadUserByUsername')->with('kuba')
- ->will($this->returnValue($user));
+ ->willReturn($user);
$this->userChecker->expects($this->once())
->method('checkPostAuth')->with($user);
diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordFormAuthenticationListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordFormAuthenticationListenerTest.php
index f1536db6d25a6..61455745289df 100644
--- a/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordFormAuthenticationListenerTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordFormAuthenticationListenerTest.php
@@ -38,21 +38,21 @@ public function testHandleWhenUsernameLength($username, $ok)
$httpUtils
->expects($this->any())
->method('checkRequestPath')
- ->will($this->returnValue(true))
+ ->willReturn(true)
;
$failureHandler = $this->getMockBuilder('Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface')->getMock();
$failureHandler
->expects($ok ? $this->never() : $this->once())
->method('onAuthenticationFailure')
- ->will($this->returnValue(new Response()))
+ ->willReturn(new Response())
;
$authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationProviderManager')->disableOriginalConstructor()->getMock();
$authenticationManager
->expects($ok ? $this->once() : $this->never())
->method('authenticate')
- ->will($this->returnValue(new Response()))
+ ->willReturn(new Response())
;
$listener = new UsernamePasswordFormAuthenticationListener(
@@ -70,7 +70,7 @@ public function testHandleWhenUsernameLength($username, $ok)
$event
->expects($this->any())
->method('getRequest')
- ->will($this->returnValue($request))
+ ->willReturn($request)
;
$listener->handle($event);
@@ -154,7 +154,7 @@ public function testHandleNonStringUsernameWith__toString($postOnly)
$usernameClass
->expects($this->atLeastOnce())
->method('__toString')
- ->will($this->returnValue('someUsername'));
+ ->willReturn('someUsername');
$request = Request::create('/login_check', 'POST', ['_username' => $usernameClass]);
$request->setSession($this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock());
diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordJsonAuthenticationListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordJsonAuthenticationListenerTest.php
index ed7acfbe5d7a7..7d2e55906b1d9 100644
--- a/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordJsonAuthenticationListenerTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordJsonAuthenticationListenerTest.php
@@ -43,7 +43,7 @@ private function createListener(array $options = [], $success = true, $matchChec
$httpUtils
->expects($this->any())
->method('checkRequestPath')
- ->will($this->returnValue($matchCheckPath))
+ ->willReturn($matchCheckPath)
;
$authenticationManager = $this->getMockBuilder(AuthenticationManagerInterface::class)->getMock();
diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/X509AuthenticationListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/X509AuthenticationListenerTest.php
index c55eaae0f3157..577ca7c38f1b3 100644
--- a/src/Symfony/Component/Security/Http/Tests/Firewall/X509AuthenticationListenerTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/Firewall/X509AuthenticationListenerTest.php
@@ -56,9 +56,8 @@ public static function dataProviderGetPreAuthenticatedData()
/**
* @dataProvider dataProviderGetPreAuthenticatedDataNoUser
*/
- public function testGetPreAuthenticatedDataNoUser($emailAddress)
+ public function testGetPreAuthenticatedDataNoUser($emailAddress, $credentials)
{
- $credentials = 'CN=Sample certificate DN/emailAddress='.$emailAddress;
$request = new Request([], [], [], [], [], ['SSL_CLIENT_S_DN' => $credentials]);
$tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
@@ -76,10 +75,12 @@ public function testGetPreAuthenticatedDataNoUser($emailAddress)
public static function dataProviderGetPreAuthenticatedDataNoUser()
{
- return [
- 'basicEmailAddress' => ['cert@example.com'],
- 'emailAddressWithPlusSign' => ['cert+something@example.com'],
- ];
+ yield ['cert@example.com', 'CN=Sample certificate DN/emailAddress=cert@example.com'];
+ yield ['cert+something@example.com', 'CN=Sample certificate DN/emailAddress=cert+something@example.com'];
+ yield ['cert@example.com', 'CN=Sample certificate DN,emailAddress=cert@example.com'];
+ yield ['cert+something@example.com', 'CN=Sample certificate DN,emailAddress=cert+something@example.com'];
+ yield ['cert+something@example.com', 'emailAddress=cert+something@example.com,CN=Sample certificate DN'];
+ yield ['cert+something@example.com', 'emailAddress=cert+something@example.com'];
}
/**
diff --git a/src/Symfony/Component/Security/Http/Tests/FirewallMapTest.php b/src/Symfony/Component/Security/Http/Tests/FirewallMapTest.php
index 04fe3b4ea3052..a8eb97192dc70 100644
--- a/src/Symfony/Component/Security/Http/Tests/FirewallMapTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/FirewallMapTest.php
@@ -28,7 +28,7 @@ public function testGetListeners()
->expects($this->once())
->method('matches')
->with($this->equalTo($request))
- ->will($this->returnValue(false))
+ ->willReturn(false)
;
$map->add($notMatchingMatcher, [$this->getMockBuilder('Symfony\Component\Security\Http\Firewall\ListenerInterface')->getMock()]);
@@ -38,7 +38,7 @@ public function testGetListeners()
->expects($this->once())
->method('matches')
->with($this->equalTo($request))
- ->will($this->returnValue(true))
+ ->willReturn(true)
;
$theListener = $this->getMockBuilder('Symfony\Component\Security\Http\Firewall\ListenerInterface')->getMock();
$theException = $this->getMockBuilder('Symfony\Component\Security\Http\Firewall\ExceptionListener')->disableOriginalConstructor()->getMock();
@@ -70,7 +70,7 @@ public function testGetListenersWithAnEntryHavingNoRequestMatcher()
->expects($this->once())
->method('matches')
->with($this->equalTo($request))
- ->will($this->returnValue(false))
+ ->willReturn(false)
;
$map->add($notMatchingMatcher, [$this->getMockBuilder('Symfony\Component\Security\Http\Firewall\ListenerInterface')->getMock()]);
@@ -105,7 +105,7 @@ public function testGetListenersWithNoMatchingEntry()
->expects($this->once())
->method('matches')
->with($this->equalTo($request))
- ->will($this->returnValue(false))
+ ->willReturn(false)
;
$map->add($notMatchingMatcher, [$this->getMockBuilder('Symfony\Component\Security\Http\Firewall\ListenerInterface')->getMock()]);
diff --git a/src/Symfony/Component/Security/Http/Tests/FirewallTest.php b/src/Symfony/Component/Security/Http/Tests/FirewallTest.php
index 7a601f6050e5c..40d597a0c728f 100644
--- a/src/Symfony/Component/Security/Http/Tests/FirewallTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/FirewallTest.php
@@ -41,7 +41,7 @@ public function testOnKernelRequestRegistersExceptionListener()
->expects($this->once())
->method('getListeners')
->with($this->equalTo($request))
- ->will($this->returnValue([[], $listener, null]))
+ ->willReturn([[], $listener, null])
;
$event = new GetResponseEvent($this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(), $request, HttpKernelInterface::MASTER_REQUEST);
@@ -70,7 +70,7 @@ public function testOnKernelRequestStopsWhenThereIsAResponse()
$map
->expects($this->once())
->method('getListeners')
- ->will($this->returnValue([[$first, $second], null, null]))
+ ->willReturn([[$first, $second], null, null])
;
$event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')
@@ -85,7 +85,7 @@ public function testOnKernelRequestStopsWhenThereIsAResponse()
$event
->expects($this->at(0))
->method('hasResponse')
- ->will($this->returnValue(true))
+ ->willReturn(true)
;
$firewall = new Firewall($map, $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock());
diff --git a/src/Symfony/Component/Security/Http/Tests/HttpUtilsTest.php b/src/Symfony/Component/Security/Http/Tests/HttpUtilsTest.php
index 5368f4683c741..a4a76747e5a58 100644
--- a/src/Symfony/Component/Security/Http/Tests/HttpUtilsTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/HttpUtilsTest.php
@@ -92,12 +92,12 @@ public function testCreateRedirectResponseWithRouteName()
->expects($this->any())
->method('generate')
->with('foobar', [], UrlGeneratorInterface::ABSOLUTE_URL)
- ->will($this->returnValue('http://localhost/foo/bar'))
+ ->willReturn('http://localhost/foo/bar')
;
$urlGenerator
->expects($this->any())
->method('getContext')
- ->will($this->returnValue($this->getMockBuilder('Symfony\Component\Routing\RequestContext')->getMock()))
+ ->willReturn($this->getMockBuilder('Symfony\Component\Routing\RequestContext')->getMock())
;
$response = $utils->createRedirectResponse($this->getRequest(), 'foobar');
@@ -125,12 +125,12 @@ public function testCreateRequestWithRouteName()
$urlGenerator
->expects($this->once())
->method('generate')
- ->will($this->returnValue('/foo/bar'))
+ ->willReturn('/foo/bar')
;
$urlGenerator
->expects($this->any())
->method('getContext')
- ->will($this->returnValue($this->getMockBuilder('Symfony\Component\Routing\RequestContext')->getMock()))
+ ->willReturn($this->getMockBuilder('Symfony\Component\Routing\RequestContext')->getMock())
;
$subRequest = $utils->createRequest($this->getRequest(), 'foobar');
@@ -229,7 +229,7 @@ public function testCheckRequestPathWithUrlMatcherAndResourceFoundByUrl()
->expects($this->any())
->method('match')
->with('/foo/bar')
- ->will($this->returnValue(['_route' => 'foobar']))
+ ->willReturn(['_route' => 'foobar'])
;
$utils = new HttpUtils(null, $urlMatcher);
@@ -244,7 +244,7 @@ public function testCheckRequestPathWithUrlMatcherAndResourceFoundByRequest()
->expects($this->any())
->method('matchRequest')
->with($request)
- ->will($this->returnValue(['_route' => 'foobar']))
+ ->willReturn(['_route' => 'foobar'])
;
$utils = new HttpUtils(null, $urlMatcher);
@@ -323,7 +323,7 @@ private function getUrlGenerator($generatedUrl = '/foo/bar')
$urlGenerator
->expects($this->any())
->method('generate')
- ->will($this->returnValue($generatedUrl))
+ ->willReturn($generatedUrl)
;
return $urlGenerator;
diff --git a/src/Symfony/Component/Security/Http/Tests/Logout/DefaultLogoutSuccessHandlerTest.php b/src/Symfony/Component/Security/Http/Tests/Logout/DefaultLogoutSuccessHandlerTest.php
index 9936fc933957b..926f8cc4b23af 100644
--- a/src/Symfony/Component/Security/Http/Tests/Logout/DefaultLogoutSuccessHandlerTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/Logout/DefaultLogoutSuccessHandlerTest.php
@@ -26,7 +26,7 @@ public function testLogout()
$httpUtils->expects($this->once())
->method('createRedirectResponse')
->with($request, '/dashboard')
- ->will($this->returnValue($response));
+ ->willReturn($response);
$handler = new DefaultLogoutSuccessHandler($httpUtils, '/dashboard');
$result = $handler->onLogoutSuccess($request);
diff --git a/src/Symfony/Component/Security/Http/Tests/Logout/SessionLogoutHandlerTest.php b/src/Symfony/Component/Security/Http/Tests/Logout/SessionLogoutHandlerTest.php
index e32d46e3e577e..cf25d1f77c820 100644
--- a/src/Symfony/Component/Security/Http/Tests/Logout/SessionLogoutHandlerTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/Logout/SessionLogoutHandlerTest.php
@@ -28,7 +28,7 @@ public function testLogout()
$request
->expects($this->once())
->method('getSession')
- ->will($this->returnValue($session))
+ ->willReturn($session)
;
$session
diff --git a/src/Symfony/Component/Security/Http/Tests/RememberMe/AbstractRememberMeServicesTest.php b/src/Symfony/Component/Security/Http/Tests/RememberMe/AbstractRememberMeServicesTest.php
index 38b8474ffc38b..ade199c0b9224 100644
--- a/src/Symfony/Component/Security/Http/Tests/RememberMe/AbstractRememberMeServicesTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/RememberMe/AbstractRememberMeServicesTest.php
@@ -51,7 +51,7 @@ public function testAutoLoginThrowsExceptionWhenImplementationDoesNotReturnUserI
$service
->expects($this->once())
->method('processAutoLoginCookie')
- ->will($this->returnValue(null))
+ ->willReturn(null)
;
$service->autoLogin($request);
@@ -67,13 +67,13 @@ public function testAutoLogin()
$user
->expects($this->once())
->method('getRoles')
- ->will($this->returnValue([]))
+ ->willReturn([])
;
$service
->expects($this->once())
->method('processAutoLoginCookie')
- ->will($this->returnValue($user))
+ ->willReturn($user)
;
$returnedToken = $service->autoLogin($request);
@@ -131,7 +131,7 @@ public function testLoginSuccessIsNotProcessedWhenTokenDoesNotContainUserInterfa
$token
->expects($this->once())
->method('getUser')
- ->will($this->returnValue('foo'))
+ ->willReturn('foo')
;
$service
@@ -154,13 +154,13 @@ public function testLoginSuccessIsNotProcessedWhenRememberMeIsNotRequested()
$token
->expects($this->once())
->method('getUser')
- ->will($this->returnValue($account))
+ ->willReturn($account)
;
$service
->expects($this->never())
->method('onLoginSuccess')
- ->will($this->returnValue(null))
+ ->willReturn(null)
;
$this->assertFalse($request->request->has('foo'));
@@ -178,13 +178,13 @@ public function testLoginSuccessWhenRememberMeAlwaysIsTrue()
$token
->expects($this->once())
->method('getUser')
- ->will($this->returnValue($account))
+ ->willReturn($account)
;
$service
->expects($this->once())
->method('onLoginSuccess')
- ->will($this->returnValue(null))
+ ->willReturn(null)
;
$service->loginSuccess($request, $response, $token);
@@ -205,13 +205,13 @@ public function testLoginSuccessWhenRememberMeParameterWithPathIsPositive($value
$token
->expects($this->once())
->method('getUser')
- ->will($this->returnValue($account))
+ ->willReturn($account)
;
$service
->expects($this->once())
->method('onLoginSuccess')
- ->will($this->returnValue(true))
+ ->willReturn(true)
;
$service->loginSuccess($request, $response, $token);
@@ -232,13 +232,13 @@ public function testLoginSuccessWhenRememberMeParameterIsPositive($value)
$token
->expects($this->once())
->method('getUser')
- ->will($this->returnValue($account))
+ ->willReturn($account)
;
$service
->expects($this->once())
->method('onLoginSuccess')
- ->will($this->returnValue(true))
+ ->willReturn(true)
;
$service->loginSuccess($request, $response, $token);
@@ -296,7 +296,7 @@ protected function getProvider()
$provider
->expects($this->any())
->method('supportsClass')
- ->will($this->returnValue(true))
+ ->willReturn(true)
;
return $provider;
diff --git a/src/Symfony/Component/Security/Http/Tests/RememberMe/PersistentTokenBasedRememberMeServicesTest.php b/src/Symfony/Component/Security/Http/Tests/RememberMe/PersistentTokenBasedRememberMeServicesTest.php
index 506cfea61ceab..7afa48edc950c 100644
--- a/src/Symfony/Component/Security/Http/Tests/RememberMe/PersistentTokenBasedRememberMeServicesTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/RememberMe/PersistentTokenBasedRememberMeServicesTest.php
@@ -85,7 +85,7 @@ public function testAutoLoginReturnsNullOnNonExistentUser()
$tokenProvider
->expects($this->once())
->method('loadTokenBySeries')
- ->will($this->returnValue(new PersistentToken('fooclass', 'fooname', 'fooseries', 'foovalue', new \DateTime())))
+ ->willReturn(new PersistentToken('fooclass', 'fooname', 'fooseries', 'foovalue', new \DateTime()))
;
$service->setTokenProvider($tokenProvider);
@@ -112,14 +112,14 @@ public function testAutoLoginThrowsExceptionOnStolenCookieAndRemovesItFromThePer
$tokenProvider
->expects($this->once())
->method('loadTokenBySeries')
- ->will($this->returnValue(new PersistentToken('fooclass', 'foouser', 'fooseries', 'anotherFooValue', new \DateTime())))
+ ->willReturn(new PersistentToken('fooclass', 'foouser', 'fooseries', 'anotherFooValue', new \DateTime()))
;
$tokenProvider
->expects($this->once())
->method('deleteTokenBySeries')
->with($this->equalTo('fooseries'))
- ->will($this->returnValue(null))
+ ->willReturn(null)
;
try {
@@ -142,7 +142,7 @@ public function testAutoLoginDoesNotAcceptAnExpiredCookie()
->expects($this->once())
->method('loadTokenBySeries')
->with($this->equalTo('fooseries'))
- ->will($this->returnValue(new PersistentToken('fooclass', 'username', 'fooseries', 'foovalue', new \DateTime('yesterday'))))
+ ->willReturn(new PersistentToken('fooclass', 'username', 'fooseries', 'foovalue', new \DateTime('yesterday')))
;
$service->setTokenProvider($tokenProvider);
@@ -156,7 +156,7 @@ public function testAutoLogin()
$user
->expects($this->once())
->method('getRoles')
- ->will($this->returnValue(['ROLE_FOO']))
+ ->willReturn(['ROLE_FOO'])
;
$userProvider = $this->getProvider();
@@ -164,7 +164,7 @@ public function testAutoLogin()
->expects($this->once())
->method('loadUserByUsername')
->with($this->equalTo('foouser'))
- ->will($this->returnValue($user))
+ ->willReturn($user)
;
$service = $this->getService($userProvider, ['name' => 'foo', 'path' => null, 'domain' => null, 'secure' => false, 'httponly' => false, 'always_remember_me' => true, 'lifetime' => 3600]);
@@ -176,7 +176,7 @@ public function testAutoLogin()
->expects($this->once())
->method('loadTokenBySeries')
->with($this->equalTo('fooseries'))
- ->will($this->returnValue(new PersistentToken('fooclass', 'foouser', 'fooseries', 'foovalue', new \DateTime())))
+ ->willReturn(new PersistentToken('fooclass', 'foouser', 'fooseries', 'foovalue', new \DateTime()))
;
$service->setTokenProvider($tokenProvider);
@@ -201,7 +201,7 @@ public function testLogout()
->expects($this->once())
->method('deleteTokenBySeries')
->with($this->equalTo('fooseries'))
- ->will($this->returnValue(null))
+ ->willReturn(null)
;
$service->setTokenProvider($tokenProvider);
@@ -277,13 +277,13 @@ public function testLoginSuccessSetsCookieWhenLoggedInWithNonRememberMeTokenInte
$account
->expects($this->once())
->method('getUsername')
- ->will($this->returnValue('foo'))
+ ->willReturn('foo')
;
$token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
$token
->expects($this->any())
->method('getUser')
- ->will($this->returnValue($account))
+ ->willReturn($account)
;
$tokenProvider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface')->getMock();
@@ -333,7 +333,7 @@ protected function getProvider()
$provider
->expects($this->any())
->method('supportsClass')
- ->will($this->returnValue(true))
+ ->willReturn(true)
;
return $provider;
diff --git a/src/Symfony/Component/Security/Http/Tests/RememberMe/ResponseListenerTest.php b/src/Symfony/Component/Security/Http/Tests/RememberMe/ResponseListenerTest.php
index e72bf26313610..0c32fa46e2c20 100644
--- a/src/Symfony/Component/Security/Http/Tests/RememberMe/ResponseListenerTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/RememberMe/ResponseListenerTest.php
@@ -95,9 +95,9 @@ private function getEvent($request, $response, $type = HttpKernelInterface::MAST
->disableOriginalConstructor()
->getMock();
- $event->expects($this->any())->method('getRequest')->will($this->returnValue($request));
- $event->expects($this->any())->method('isMasterRequest')->will($this->returnValue(HttpKernelInterface::MASTER_REQUEST === $type));
- $event->expects($this->any())->method('getResponse')->will($this->returnValue($response));
+ $event->expects($this->any())->method('getRequest')->willReturn($request);
+ $event->expects($this->any())->method('isMasterRequest')->willReturn(HttpKernelInterface::MASTER_REQUEST === $type);
+ $event->expects($this->any())->method('getResponse')->willReturn($response);
return $event;
}
diff --git a/src/Symfony/Component/Security/Http/Tests/RememberMe/TokenBasedRememberMeServicesTest.php b/src/Symfony/Component/Security/Http/Tests/RememberMe/TokenBasedRememberMeServicesTest.php
index e71e650a4d963..4a34d614213f2 100644
--- a/src/Symfony/Component/Security/Http/Tests/RememberMe/TokenBasedRememberMeServicesTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/RememberMe/TokenBasedRememberMeServicesTest.php
@@ -68,14 +68,14 @@ public function testAutoLoginDoesNotAcceptCookieWithInvalidHash()
$user
->expects($this->once())
->method('getPassword')
- ->will($this->returnValue('foopass'))
+ ->willReturn('foopass')
;
$userProvider
->expects($this->once())
->method('loadUserByUsername')
->with($this->equalTo('foouser'))
- ->will($this->returnValue($user))
+ ->willReturn($user)
;
$this->assertNull($service->autoLogin($request));
@@ -93,14 +93,14 @@ public function testAutoLoginDoesNotAcceptAnExpiredCookie()
$user
->expects($this->once())
->method('getPassword')
- ->will($this->returnValue('foopass'))
+ ->willReturn('foopass')
;
$userProvider
->expects($this->once())
->method('loadUserByUsername')
->with($this->equalTo('foouser'))
- ->will($this->returnValue($user))
+ ->willReturn($user)
;
$this->assertNull($service->autoLogin($request));
@@ -118,12 +118,12 @@ public function testAutoLogin($username)
$user
->expects($this->once())
->method('getRoles')
- ->will($this->returnValue(['ROLE_FOO']))
+ ->willReturn(['ROLE_FOO'])
;
$user
->expects($this->once())
->method('getPassword')
- ->will($this->returnValue('foopass'))
+ ->willReturn('foopass')
;
$userProvider = $this->getProvider();
@@ -131,7 +131,7 @@ public function testAutoLogin($username)
->expects($this->once())
->method('loadUserByUsername')
->with($this->equalTo($username))
- ->will($this->returnValue($user))
+ ->willReturn($user)
;
$service = $this->getService($userProvider, ['name' => 'foo', 'always_remember_me' => true, 'lifetime' => 3600]);
@@ -192,7 +192,7 @@ public function testLoginSuccessIgnoresTokensWhichDoNotContainAnUserInterfaceImp
$token
->expects($this->once())
->method('getUser')
- ->will($this->returnValue('foo'))
+ ->willReturn('foo')
;
$cookies = $response->headers->getCookies();
@@ -215,17 +215,17 @@ public function testLoginSuccess()
$user
->expects($this->once())
->method('getPassword')
- ->will($this->returnValue('foopass'))
+ ->willReturn('foopass')
;
$user
->expects($this->once())
->method('getUsername')
- ->will($this->returnValue('foouser'))
+ ->willReturn('foouser')
;
$token
->expects($this->atLeastOnce())
->method('getUser')
- ->will($this->returnValue($user))
+ ->willReturn($user)
;
$cookies = $response->headers->getCookies();
@@ -279,7 +279,7 @@ protected function getProvider()
$provider
->expects($this->any())
->method('supportsClass')
- ->will($this->returnValue(true))
+ ->willReturn(true)
;
return $provider;
diff --git a/src/Symfony/Component/Security/Http/Tests/Session/SessionAuthenticationStrategyTest.php b/src/Symfony/Component/Security/Http/Tests/Session/SessionAuthenticationStrategyTest.php
index 271bc99cc5ba3..6c0df8cb5f2cb 100644
--- a/src/Symfony/Component/Security/Http/Tests/Session/SessionAuthenticationStrategyTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/Session/SessionAuthenticationStrategyTest.php
@@ -61,7 +61,7 @@ private function getRequest($session = null)
$request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
if (null !== $session) {
- $request->expects($this->any())->method('getSession')->will($this->returnValue($session));
+ $request->expects($this->any())->method('getSession')->willReturn($session);
}
return $request;
diff --git a/src/Symfony/Component/Serializer/Encoder/CsvEncoder.php b/src/Symfony/Component/Serializer/Encoder/CsvEncoder.php
index eaaa8dffc3d34..89fb89d5cbdfc 100644
--- a/src/Symfony/Component/Serializer/Encoder/CsvEncoder.php
+++ b/src/Symfony/Component/Serializer/Encoder/CsvEncoder.php
@@ -205,10 +205,11 @@ private function flatten(array $array, array &$result, string $keySeparator, str
if (\is_array($value)) {
$this->flatten($value, $result, $keySeparator, $parentKey.$key.$keySeparator, $escapeFormulas);
} else {
- if ($escapeFormulas && \in_array(substr($value, 0, 1), $this->formulasStartCharacters, true)) {
+ if ($escapeFormulas && \in_array(substr((string) $value, 0, 1), $this->formulasStartCharacters, true)) {
$result[$parentKey.$key] = "\t".$value;
} else {
- $result[$parentKey.$key] = $value;
+ // Ensures an actual value is used when dealing with true and false
+ $result[$parentKey.$key] = false === $value ? 0 : (true === $value ? 1 : $value);
}
}
}
diff --git a/src/Symfony/Component/Serializer/Encoder/JsonDecode.php b/src/Symfony/Component/Serializer/Encoder/JsonDecode.php
index 789e166b50df0..ceedce69eef21 100644
--- a/src/Symfony/Component/Serializer/Encoder/JsonDecode.php
+++ b/src/Symfony/Component/Serializer/Encoder/JsonDecode.php
@@ -92,7 +92,15 @@ public function decode($data, $format, array $context = [])
$recursionDepth = $context[self::RECURSION_DEPTH] ?? $this->defaultContext[self::RECURSION_DEPTH];
$options = $context[self::OPTIONS] ?? $this->defaultContext[self::OPTIONS];
- $decodedData = json_decode($data, $associative, $recursionDepth, $options);
+ try {
+ $decodedData = json_decode($data, $associative, $recursionDepth, $options);
+ } catch (\JsonException $e) {
+ throw new NotEncodableValueException($e->getMessage(), 0, $e);
+ }
+
+ if (\PHP_VERSION_ID >= 70300 && (JSON_THROW_ON_ERROR & $options)) {
+ return $decodedData;
+ }
if (JSON_ERROR_NONE !== json_last_error()) {
throw new NotEncodableValueException(json_last_error_msg());
diff --git a/src/Symfony/Component/Serializer/Encoder/JsonEncode.php b/src/Symfony/Component/Serializer/Encoder/JsonEncode.php
index ca9fc9e5d7790..681e3c4941dc4 100644
--- a/src/Symfony/Component/Serializer/Encoder/JsonEncode.php
+++ b/src/Symfony/Component/Serializer/Encoder/JsonEncode.php
@@ -50,6 +50,10 @@ public function encode($data, $format, array $context = [])
$jsonEncodeOptions = $context[self::OPTIONS] ?? $this->defaultContext[self::OPTIONS];
$encodedJson = json_encode($data, $jsonEncodeOptions);
+ if (\PHP_VERSION_ID >= 70300 && (JSON_THROW_ON_ERROR & $jsonEncodeOptions)) {
+ return $encodedJson;
+ }
+
if (JSON_ERROR_NONE !== json_last_error() && (false === $encodedJson || !($jsonEncodeOptions & JSON_PARTIAL_OUTPUT_ON_ERROR))) {
throw new NotEncodableValueException(json_last_error_msg());
}
diff --git a/src/Symfony/Component/Serializer/Mapping/Factory/ClassMetadataFactory.php b/src/Symfony/Component/Serializer/Mapping/Factory/ClassMetadataFactory.php
index 882091dca8260..b55c070fb8ae2 100644
--- a/src/Symfony/Component/Serializer/Mapping/Factory/ClassMetadataFactory.php
+++ b/src/Symfony/Component/Serializer/Mapping/Factory/ClassMetadataFactory.php
@@ -69,6 +69,6 @@ public function getMetadataFor($value)
*/
public function hasMetadataFor($value)
{
- return \is_object($value) || (\is_string($value) && (\class_exists($value) || \interface_exists($value, false)));
+ return \is_object($value) || (\is_string($value) && (class_exists($value) || interface_exists($value, false)));
}
}
diff --git a/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php
index ad1c4b166715a..620fa8a626abf 100644
--- a/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php
+++ b/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php
@@ -263,7 +263,7 @@ public function setMaxDepthHandler(?callable $handler): void
*/
public function supportsDenormalization($data, $type, $format = null)
{
- return \class_exists($type) || (\interface_exists($type, false) && $this->classDiscriminatorResolver && null !== $this->classDiscriminatorResolver->getMappingForClass($type));
+ return class_exists($type) || (interface_exists($type, false) && $this->classDiscriminatorResolver && null !== $this->classDiscriminatorResolver->getMappingForClass($type));
}
/**
@@ -507,7 +507,7 @@ private function isMaxDepthReached(array $attributesMetadata, string $class, str
protected function createChildContext(array $parentContext, $attribute/*, string $format = null */)
{
if (\func_num_args() >= 3) {
- $format = \func_get_arg(2);
+ $format = func_get_arg(2);
} else {
// will be deprecated in version 4
$format = null;
diff --git a/src/Symfony/Component/Serializer/Normalizer/CustomNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/CustomNormalizer.php
index d5a1990f0b805..dcf2deef806d9 100644
--- a/src/Symfony/Component/Serializer/Normalizer/CustomNormalizer.php
+++ b/src/Symfony/Component/Serializer/Normalizer/CustomNormalizer.php
@@ -65,7 +65,7 @@ public function supportsNormalization($data, $format = null)
*/
public function supportsDenormalization($data, $type, $format = null)
{
- return \is_subclass_of($type, DenormalizableInterface::class);
+ return is_subclass_of($type, DenormalizableInterface::class);
}
/**
diff --git a/src/Symfony/Component/Serializer/Normalizer/DataUriNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/DataUriNormalizer.php
index 9327b7980fc66..2f51e97b21d04 100644
--- a/src/Symfony/Component/Serializer/Normalizer/DataUriNormalizer.php
+++ b/src/Symfony/Component/Serializer/Normalizer/DataUriNormalizer.php
@@ -32,7 +32,7 @@ class DataUriNormalizer implements NormalizerInterface, DenormalizerInterface, C
];
/**
- * @var MimeTypeGuesserInterface
+ * @var MimeTypeGuesserInterface|null
*/
private $mimeTypeGuesser;
diff --git a/src/Symfony/Component/Serializer/Normalizer/ObjectNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/ObjectNormalizer.php
index f766286b2b11a..118e9856f5e9a 100644
--- a/src/Symfony/Component/Serializer/Normalizer/ObjectNormalizer.php
+++ b/src/Symfony/Component/Serializer/Normalizer/ObjectNormalizer.php
@@ -36,7 +36,7 @@ class ObjectNormalizer extends AbstractObjectNormalizer
public function __construct(ClassMetadataFactoryInterface $classMetadataFactory = null, NameConverterInterface $nameConverter = null, PropertyAccessorInterface $propertyAccessor = null, PropertyTypeExtractorInterface $propertyTypeExtractor = null, ClassDiscriminatorResolverInterface $classDiscriminatorResolver = null, callable $objectClassResolver = null, array $defaultContext = [])
{
- if (!\class_exists(PropertyAccess::class)) {
+ if (!class_exists(PropertyAccess::class)) {
throw new LogicException('The ObjectNormalizer class requires the "PropertyAccess" component. Install "symfony/property-access" to use it.');
}
diff --git a/src/Symfony/Component/Serializer/Serializer.php b/src/Symfony/Component/Serializer/Serializer.php
index b950ba58b0a19..c7ccd9fd9fa2b 100644
--- a/src/Symfony/Component/Serializer/Serializer.php
+++ b/src/Symfony/Component/Serializer/Serializer.php
@@ -84,7 +84,7 @@ public function __construct(array $normalizers = [], array $encoders = [])
}
if (!($normalizer instanceof NormalizerInterface || $normalizer instanceof DenormalizerInterface)) {
- @trigger_error(\sprintf('Passing normalizers ("%s") which do not implement either "%s" or "%s" has been deprecated since Symfony 4.2.', \get_class($normalizer), NormalizerInterface::class, DenormalizerInterface::class), E_USER_DEPRECATED);
+ @trigger_error(sprintf('Passing normalizers ("%s") which do not implement either "%s" or "%s" has been deprecated since Symfony 4.2.', \get_class($normalizer), NormalizerInterface::class, DenormalizerInterface::class), E_USER_DEPRECATED);
// throw new \InvalidArgumentException(\sprintf('The class "%s" does not implement "%s" or "%s".', \get_class($normalizer), NormalizerInterface::class, DenormalizerInterface::class));
}
}
@@ -104,7 +104,7 @@ public function __construct(array $normalizers = [], array $encoders = [])
}
if (!($encoder instanceof EncoderInterface || $encoder instanceof DecoderInterface)) {
- @trigger_error(\sprintf('Passing encoders ("%s") which do not implement either "%s" or "%s" has been deprecated since Symfony 4.2.', \get_class($encoder), EncoderInterface::class, DecoderInterface::class), E_USER_DEPRECATED);
+ @trigger_error(sprintf('Passing encoders ("%s") which do not implement either "%s" or "%s" has been deprecated since Symfony 4.2.', \get_class($encoder), EncoderInterface::class, DecoderInterface::class), E_USER_DEPRECATED);
// throw new \InvalidArgumentException(\sprintf('The class "%s" does not implement "%s" or "%s".', \get_class($normalizer), EncoderInterface::class, DecoderInterface::class));
}
}
diff --git a/src/Symfony/Component/Serializer/Tests/Encoder/ChainDecoderTest.php b/src/Symfony/Component/Serializer/Tests/Encoder/ChainDecoderTest.php
index 3a84d99dde286..22b86758a590a 100644
--- a/src/Symfony/Component/Serializer/Tests/Encoder/ChainDecoderTest.php
+++ b/src/Symfony/Component/Serializer/Tests/Encoder/ChainDecoderTest.php
@@ -32,12 +32,12 @@ protected function setUp()
$this->decoder1
->method('supportsDecoding')
- ->will($this->returnValueMap([
+ ->willReturnMap([
[self::FORMAT_1, [], true],
[self::FORMAT_2, [], false],
[self::FORMAT_3, [], false],
[self::FORMAT_3, ['foo' => 'bar'], true],
- ]));
+ ]);
$this->decoder2 = $this
->getMockBuilder('Symfony\Component\Serializer\Encoder\DecoderInterface')
@@ -45,11 +45,11 @@ protected function setUp()
$this->decoder2
->method('supportsDecoding')
- ->will($this->returnValueMap([
+ ->willReturnMap([
[self::FORMAT_1, [], false],
[self::FORMAT_2, [], true],
[self::FORMAT_3, [], false],
- ]));
+ ]);
$this->chainDecoder = new ChainDecoder([$this->decoder1, $this->decoder2]);
}
diff --git a/src/Symfony/Component/Serializer/Tests/Encoder/ChainEncoderTest.php b/src/Symfony/Component/Serializer/Tests/Encoder/ChainEncoderTest.php
index 48ccbdca0aca6..d9b6251ed93c3 100644
--- a/src/Symfony/Component/Serializer/Tests/Encoder/ChainEncoderTest.php
+++ b/src/Symfony/Component/Serializer/Tests/Encoder/ChainEncoderTest.php
@@ -34,12 +34,12 @@ protected function setUp()
$this->encoder1
->method('supportsEncoding')
- ->will($this->returnValueMap([
+ ->willReturnMap([
[self::FORMAT_1, [], true],
[self::FORMAT_2, [], false],
[self::FORMAT_3, [], false],
[self::FORMAT_3, ['foo' => 'bar'], true],
- ]));
+ ]);
$this->encoder2 = $this
->getMockBuilder('Symfony\Component\Serializer\Encoder\EncoderInterface')
@@ -47,11 +47,11 @@ protected function setUp()
$this->encoder2
->method('supportsEncoding')
- ->will($this->returnValueMap([
+ ->willReturnMap([
[self::FORMAT_1, [], false],
[self::FORMAT_2, [], true],
[self::FORMAT_3, [], false],
- ]));
+ ]);
$this->chainEncoder = new ChainEncoder([$this->encoder1, $this->encoder2]);
}
diff --git a/src/Symfony/Component/Serializer/Tests/Encoder/CsvEncoderTest.php b/src/Symfony/Component/Serializer/Tests/Encoder/CsvEncoderTest.php
index 66ffe2d70cd8e..f66080a02d74a 100644
--- a/src/Symfony/Component/Serializer/Tests/Encoder/CsvEncoderTest.php
+++ b/src/Symfony/Component/Serializer/Tests/Encoder/CsvEncoderTest.php
@@ -29,6 +29,24 @@ protected function setUp()
$this->encoder = new CsvEncoder();
}
+ public function testTrueFalseValues()
+ {
+ $data = [
+ 'string' => 'foo',
+ 'int' => 2,
+ 'false' => false,
+ 'true' => true,
+ ];
+
+ // Check that true and false are appropriately handled
+ $this->assertEquals(<<<'CSV'
+string,int,false,true
+foo,2,0,1
+
+CSV
+ , $this->encoder->encode($data, 'csv'));
+ }
+
public function testSupportEncoding()
{
$this->assertTrue($this->encoder->supportsEncoding('csv'));
diff --git a/src/Symfony/Component/Serializer/Tests/Mapping/Factory/CacheMetadataFactoryTest.php b/src/Symfony/Component/Serializer/Tests/Mapping/Factory/CacheMetadataFactoryTest.php
index cac4367ca7995..067f16acf9c36 100644
--- a/src/Symfony/Component/Serializer/Tests/Mapping/Factory/CacheMetadataFactoryTest.php
+++ b/src/Symfony/Component/Serializer/Tests/Mapping/Factory/CacheMetadataFactoryTest.php
@@ -31,7 +31,7 @@ public function testGetMetadataFor()
$decorated
->expects($this->once())
->method('getMetadataFor')
- ->will($this->returnValue($metadata))
+ ->willReturn($metadata)
;
$factory = new CacheClassMetadataFactory($decorated, new ArrayAdapter());
@@ -47,7 +47,7 @@ public function testHasMetadataFor()
$decorated
->expects($this->once())
->method('hasMetadataFor')
- ->will($this->returnValue(true))
+ ->willReturn(true)
;
$factory = new CacheClassMetadataFactory($decorated, new ArrayAdapter());
diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/ArrayDenormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/ArrayDenormalizerTest.php
index fd456cb9dd4d8..132f3c0806350 100644
--- a/src/Symfony/Component/Serializer/Tests/Normalizer/ArrayDenormalizerTest.php
+++ b/src/Symfony/Component/Serializer/Tests/Normalizer/ArrayDenormalizerTest.php
@@ -39,12 +39,12 @@ public function testDenormalize()
$this->serializer->expects($this->at(0))
->method('denormalize')
->with(['foo' => 'one', 'bar' => 'two'])
- ->will($this->returnValue(new ArrayDummy('one', 'two')));
+ ->willReturn(new ArrayDummy('one', 'two'));
$this->serializer->expects($this->at(1))
->method('denormalize')
->with(['foo' => 'three', 'bar' => 'four'])
- ->will($this->returnValue(new ArrayDummy('three', 'four')));
+ ->willReturn(new ArrayDummy('three', 'four'));
$result = $this->denormalizer->denormalize(
[
@@ -68,7 +68,7 @@ public function testSupportsValidArray()
$this->serializer->expects($this->once())
->method('supportsDenormalization')
->with($this->anything(), __NAMESPACE__.'\ArrayDummy', $this->anything())
- ->will($this->returnValue(true));
+ ->willReturn(true);
$this->assertTrue(
$this->denormalizer->supportsDenormalization(
@@ -85,7 +85,7 @@ public function testSupportsInvalidArray()
{
$this->serializer->expects($this->any())
->method('supportsDenormalization')
- ->will($this->returnValue(false));
+ ->willReturn(false);
$this->assertFalse(
$this->denormalizer->supportsDenormalization(
diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php
index 8d9b38312272b..b5cfcae2b09d6 100644
--- a/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php
+++ b/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php
@@ -69,7 +69,7 @@ public function testNormalize()
->expects($this->once())
->method('normalize')
->with($object, 'any')
- ->will($this->returnValue('string_object'))
+ ->willReturn('string_object')
;
$this->assertEquals(
diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/JsonSerializableNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/JsonSerializableNormalizerTest.php
index 5f6731b7ca60b..ba5e03518ce08 100644
--- a/src/Symfony/Component/Serializer/Tests/Normalizer/JsonSerializableNormalizerTest.php
+++ b/src/Symfony/Component/Serializer/Tests/Normalizer/JsonSerializableNormalizerTest.php
@@ -55,11 +55,11 @@ public function testNormalize()
$this->serializer
->expects($this->once())
->method('normalize')
- ->will($this->returnCallback(function ($data) {
+ ->willReturnCallback(function ($data) {
$this->assertArraySubset(['foo' => 'a', 'bar' => 'b', 'baz' => 'c'], $data);
return 'string_object';
- }))
+ })
;
$this->assertEquals('string_object', $this->normalizer->normalize(new JsonSerializableDummy()));
@@ -91,11 +91,11 @@ private function doTestCircularNormalize(bool $legacy = false)
$this->serializer
->expects($this->once())
->method('normalize')
- ->will($this->returnCallback(function ($data, $format, $context) {
+ ->willReturnCallback(function ($data, $format, $context) {
$this->normalizer->normalize($data['qux'], $format, $context);
return 'string_object';
- }))
+ })
;
$this->assertEquals('string_object', $this->normalizer->normalize(new JsonSerializableDummy()));
diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php
index 4c4448dfe4b0e..18de3a39abef7 100644
--- a/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php
+++ b/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php
@@ -74,7 +74,7 @@ public function testNormalize()
->expects($this->once())
->method('normalize')
->with($object, 'any')
- ->will($this->returnValue('string_object'))
+ ->willReturn('string_object')
;
$this->assertEquals(
diff --git a/src/Symfony/Component/Serializer/Tests/SerializerTest.php b/src/Symfony/Component/Serializer/Tests/SerializerTest.php
index ce6be57f3396c..a3b931b5243c5 100644
--- a/src/Symfony/Component/Serializer/Tests/SerializerTest.php
+++ b/src/Symfony/Component/Serializer/Tests/SerializerTest.php
@@ -384,14 +384,14 @@ public function testDeserializeAndSerializeAbstractObjectsWithTheClassMetadataDi
$example = new AbstractDummyFirstChild('foo-value', 'bar-value');
$loaderMock = $this->getMockBuilder(ClassMetadataFactoryInterface::class)->getMock();
- $loaderMock->method('hasMetadataFor')->will($this->returnValueMap([
+ $loaderMock->method('hasMetadataFor')->willReturnMap([
[
AbstractDummy::class,
true,
],
- ]));
+ ]);
- $loaderMock->method('getMetadataFor')->will($this->returnValueMap([
+ $loaderMock->method('getMetadataFor')->willReturnMap([
[
AbstractDummy::class,
new ClassMetadata(
@@ -402,7 +402,7 @@ public function testDeserializeAndSerializeAbstractObjectsWithTheClassMetadataDi
])
),
],
- ]));
+ ]);
$discriminatorResolver = new ClassDiscriminatorFromClassMetadata($loaderMock);
$serializer = new Serializer([new ObjectNormalizer(null, null, null, null, $discriminatorResolver)], ['json' => new JsonEncoder()]);
diff --git a/src/Symfony/Component/Serializer/composer.json b/src/Symfony/Component/Serializer/composer.json
index d03681bfc44ea..f670691982a6b 100644
--- a/src/Symfony/Component/Serializer/composer.json
+++ b/src/Symfony/Component/Serializer/composer.json
@@ -45,7 +45,7 @@
"symfony/yaml": "For using the default YAML mapping loader.",
"symfony/config": "For using the XML mapping loader.",
"symfony/property-access": "For using the ObjectNormalizer.",
- "symfony/http-foundation": "To use the DataUriNormalizer.",
+ "symfony/http-foundation": "For using a MIME type guesser within the DataUriNormalizer.",
"doctrine/annotations": "For using the annotation mapping. You will also need doctrine/cache.",
"doctrine/cache": "For using the default cached annotation reader and metadata cache."
},
diff --git a/src/Symfony/Component/Templating/Tests/DelegatingEngineTest.php b/src/Symfony/Component/Templating/Tests/DelegatingEngineTest.php
index 875672d27fff5..3d61ec2716b59 100644
--- a/src/Symfony/Component/Templating/Tests/DelegatingEngineTest.php
+++ b/src/Symfony/Component/Templating/Tests/DelegatingEngineTest.php
@@ -26,7 +26,7 @@ public function testRenderDelegatesToSupportedEngine()
$secondEngine->expects($this->once())
->method('render')
->with('template.php', ['foo' => 'bar'])
- ->will($this->returnValue(''));
+ ->willReturn('');
$delegatingEngine = new DelegatingEngine([$firstEngine, $secondEngine]);
$result = $delegatingEngine->render('template.php', ['foo' => 'bar']);
@@ -53,7 +53,7 @@ public function testStreamDelegatesToSupportedEngine()
$streamingEngine->expects($this->once())
->method('stream')
->with('template.php', ['foo' => 'bar'])
- ->will($this->returnValue(''));
+ ->willReturn('');
$delegatingEngine = new DelegatingEngine([$streamingEngine]);
$result = $delegatingEngine->stream('template.php', ['foo' => 'bar']);
@@ -77,7 +77,7 @@ public function testExists()
$engine->expects($this->once())
->method('exists')
->with('template.php')
- ->will($this->returnValue(true));
+ ->willReturn(true);
$delegatingEngine = new DelegatingEngine([$engine]);
@@ -132,7 +132,7 @@ private function getEngineMock($template, $supports)
$engine->expects($this->once())
->method('supports')
->with($template)
- ->will($this->returnValue($supports));
+ ->willReturn($supports);
return $engine;
}
@@ -144,7 +144,7 @@ private function getStreamingEngineMock($template, $supports)
$engine->expects($this->once())
->method('supports')
->with($template)
- ->will($this->returnValue($supports));
+ ->willReturn($supports);
return $engine;
}
diff --git a/src/Symfony/Component/Translation/Command/XliffLintCommand.php b/src/Symfony/Component/Translation/Command/XliffLintCommand.php
index 9bea4d9499392..3c2cc9efde6f4 100644
--- a/src/Symfony/Component/Translation/Command/XliffLintCommand.php
+++ b/src/Symfony/Component/Translation/Command/XliffLintCommand.php
@@ -124,7 +124,9 @@ private function validate($content, $file = null)
$normalizedLocale = preg_quote(str_replace('-', '_', $targetLanguage), '/');
// strict file names require translation files to be named '____.locale.xlf'
// otherwise, both '____.locale.xlf' and 'locale.____.xlf' are allowed
- $expectedFilenamePattern = $this->requireStrictFileNames ? sprintf('/^.*\.%s\.xlf/', $normalizedLocale) : sprintf('/^(.*\.%s\.xlf|%s\..*\.xlf)/', $normalizedLocale, $normalizedLocale);
+ // also, the regexp matching must be case-insensitive, as defined for 'target-language' values
+ // http://docs.oasis-open.org/xliff/v1.2/os/xliff-core.html#target-language
+ $expectedFilenamePattern = $this->requireStrictFileNames ? sprintf('/^.*\.(?i:%s)\.xlf/', $normalizedLocale) : sprintf('/^(.*\.(?i:%s)\.xlf|(?i:%s)\..*\.xlf)/', $normalizedLocale, $normalizedLocale);
if (0 === preg_match($expectedFilenamePattern, basename($file))) {
$errors[] = [
diff --git a/src/Symfony/Component/Translation/PluralizationRules.php b/src/Symfony/Component/Translation/PluralizationRules.php
index ee8609fadabfa..77c276073f3f0 100644
--- a/src/Symfony/Component/Translation/PluralizationRules.php
+++ b/src/Symfony/Component/Translation/PluralizationRules.php
@@ -32,7 +32,7 @@ class PluralizationRules
*/
public static function get($number, $locale/*, bool $triggerDeprecation = true*/)
{
- if (3 > \func_num_args() || \func_get_arg(2)) {
+ if (3 > \func_num_args() || func_get_arg(2)) {
@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.2.', __CLASS__), E_USER_DEPRECATED);
}
diff --git a/src/Symfony/Component/Translation/Resources/bin/translation-status.php b/src/Symfony/Component/Translation/Resources/bin/translation-status.php
index 0d37c3e0aa38b..96ccc105741b7 100644
--- a/src/Symfony/Component/Translation/Resources/bin/translation-status.php
+++ b/src/Symfony/Component/Translation/Resources/bin/translation-status.php
@@ -73,7 +73,7 @@
$translationStatus = calculateTranslationStatus($originalFilePath, $translationFilePaths);
$totalMissingTranslations += array_sum(array_map(function ($translation) {
- return \count($translation['missingKeys']);
+ return count($translation['missingKeys']);
}, array_values($translationStatus)));
printTranslationStatus($originalFilePath, $translationStatus, $config['verbose_output']);
@@ -113,8 +113,8 @@ function calculateTranslationStatus($originalFilePath, $translationFilePaths)
$missingKeys = array_diff_key($allTranslationKeys, $translatedKeys);
$translationStatus[$locale] = [
- 'total' => \count($allTranslationKeys),
- 'translated' => \count($translatedKeys),
+ 'total' => count($allTranslationKeys),
+ 'translated' => count($translatedKeys),
'missingKeys' => $missingKeys,
];
}
@@ -176,7 +176,7 @@ function printTable($translations, $verboseOutput)
textColorNormal();
- if (true === $verboseOutput && \count($translation['missingKeys']) > 0) {
+ if (true === $verboseOutput && count($translation['missingKeys']) > 0) {
echo str_repeat('-', 80).PHP_EOL;
echo '| Missing Translations:'.PHP_EOL;
diff --git a/src/Symfony/Component/Translation/Tests/Command/XliffLintCommandTest.php b/src/Symfony/Component/Translation/Tests/Command/XliffLintCommandTest.php
index 516d98af53dba..df2e2f0951dd3 100644
--- a/src/Symfony/Component/Translation/Tests/Command/XliffLintCommandTest.php
+++ b/src/Symfony/Component/Translation/Tests/Command/XliffLintCommandTest.php
@@ -94,6 +94,17 @@ public function testLintIncorrectTargetLanguage()
$this->assertContains('There is a mismatch between the language included in the file name ("messages.en.xlf") and the "es" value used in the "target-language" attribute of the file.', trim($tester->getDisplay()));
}
+ public function testLintTargetLanguageIsCaseInsensitive()
+ {
+ $tester = $this->createCommandTester();
+ $filename = $this->createFile('note', 'zh-cn', 'messages.zh_CN.xlf');
+
+ $tester->execute(['filename' => $filename], ['decorated' => false]);
+
+ $this->assertEquals(0, $tester->getStatusCode());
+ $this->assertContains('[OK] All 1 XLIFF files contain valid syntax.', trim($tester->getDisplay()));
+ }
+
/**
* @expectedException \RuntimeException
*/
diff --git a/src/Symfony/Component/Translation/Tests/DataCollector/TranslationDataCollectorTest.php b/src/Symfony/Component/Translation/Tests/DataCollector/TranslationDataCollectorTest.php
index b4d350ef862e5..bd97a2445c0a5 100644
--- a/src/Symfony/Component/Translation/Tests/DataCollector/TranslationDataCollectorTest.php
+++ b/src/Symfony/Component/Translation/Tests/DataCollector/TranslationDataCollectorTest.php
@@ -27,7 +27,7 @@ protected function setUp()
public function testCollectEmptyMessages()
{
$translator = $this->getTranslator();
- $translator->expects($this->any())->method('getCollectedMessages')->will($this->returnValue([]));
+ $translator->expects($this->any())->method('getCollectedMessages')->willReturn([]);
$dataCollector = new TranslationDataCollector($translator);
$dataCollector->lateCollect();
@@ -125,7 +125,7 @@ public function testCollect()
];
$translator = $this->getTranslator();
- $translator->expects($this->any())->method('getCollectedMessages')->will($this->returnValue($collectedMessages));
+ $translator->expects($this->any())->method('getCollectedMessages')->willReturn($collectedMessages);
$dataCollector = new TranslationDataCollector($translator);
$dataCollector->lateCollect();
diff --git a/src/Symfony/Component/Translation/Tests/MessageCatalogueTest.php b/src/Symfony/Component/Translation/Tests/MessageCatalogueTest.php
index 6fe9368f5c161..cf0dd1a24c2b4 100644
--- a/src/Symfony/Component/Translation/Tests/MessageCatalogueTest.php
+++ b/src/Symfony/Component/Translation/Tests/MessageCatalogueTest.php
@@ -103,10 +103,10 @@ public function testReplace()
public function testAddCatalogue()
{
$r = $this->getMockBuilder('Symfony\Component\Config\Resource\ResourceInterface')->getMock();
- $r->expects($this->any())->method('__toString')->will($this->returnValue('r'));
+ $r->expects($this->any())->method('__toString')->willReturn('r');
$r1 = $this->getMockBuilder('Symfony\Component\Config\Resource\ResourceInterface')->getMock();
- $r1->expects($this->any())->method('__toString')->will($this->returnValue('r1'));
+ $r1->expects($this->any())->method('__toString')->willReturn('r1');
$catalogue = new MessageCatalogue('en', ['domain1' => ['foo' => 'foo']]);
$catalogue->addResource($r);
@@ -127,13 +127,13 @@ public function testAddCatalogue()
public function testAddFallbackCatalogue()
{
$r = $this->getMockBuilder('Symfony\Component\Config\Resource\ResourceInterface')->getMock();
- $r->expects($this->any())->method('__toString')->will($this->returnValue('r'));
+ $r->expects($this->any())->method('__toString')->willReturn('r');
$r1 = $this->getMockBuilder('Symfony\Component\Config\Resource\ResourceInterface')->getMock();
- $r1->expects($this->any())->method('__toString')->will($this->returnValue('r1'));
+ $r1->expects($this->any())->method('__toString')->willReturn('r1');
$r2 = $this->getMockBuilder('Symfony\Component\Config\Resource\ResourceInterface')->getMock();
- $r2->expects($this->any())->method('__toString')->will($this->returnValue('r2'));
+ $r2->expects($this->any())->method('__toString')->willReturn('r2');
$catalogue = new MessageCatalogue('fr_FR', ['domain1' => ['foo' => 'foo'], 'domain2' => ['bar' => 'bar']]);
$catalogue->addResource($r);
@@ -192,11 +192,11 @@ public function testGetAddResource()
{
$catalogue = new MessageCatalogue('en');
$r = $this->getMockBuilder('Symfony\Component\Config\Resource\ResourceInterface')->getMock();
- $r->expects($this->any())->method('__toString')->will($this->returnValue('r'));
+ $r->expects($this->any())->method('__toString')->willReturn('r');
$catalogue->addResource($r);
$catalogue->addResource($r);
$r1 = $this->getMockBuilder('Symfony\Component\Config\Resource\ResourceInterface')->getMock();
- $r1->expects($this->any())->method('__toString')->will($this->returnValue('r1'));
+ $r1->expects($this->any())->method('__toString')->willReturn('r1');
$catalogue->addResource($r1);
$this->assertEquals([$r, $r1], $catalogue->getResources());
diff --git a/src/Symfony/Component/Translation/Tests/TranslatorCacheTest.php b/src/Symfony/Component/Translation/Tests/TranslatorCacheTest.php
index ec909aaa38afc..5d437ff76cff9 100644
--- a/src/Symfony/Component/Translation/Tests/TranslatorCacheTest.php
+++ b/src/Symfony/Component/Translation/Tests/TranslatorCacheTest.php
@@ -104,7 +104,7 @@ public function testCatalogueIsReloadedWhenResourcesAreNoLongerFresh()
$loader
->expects($this->exactly(2))
->method('load')
- ->will($this->returnValue($catalogue))
+ ->willReturn($catalogue)
;
// 1st pass
@@ -249,11 +249,11 @@ public function testRefreshCacheWhenResourcesAreNoLongerFresh()
{
$resource = $this->getMockBuilder('Symfony\Component\Config\Resource\SelfCheckingResourceInterface')->getMock();
$loader = $this->getMockBuilder('Symfony\Component\Translation\Loader\LoaderInterface')->getMock();
- $resource->method('isFresh')->will($this->returnValue(false));
+ $resource->method('isFresh')->willReturn(false);
$loader
->expects($this->exactly(2))
->method('load')
- ->will($this->returnValue($this->getCatalogue('fr', [], [$resource])));
+ ->willReturn($this->getCatalogue('fr', [], [$resource]));
// prime the cache
$translator = new Translator('fr', null, $this->tmpDir, true);
diff --git a/src/Symfony/Component/Translation/Translator.php b/src/Symfony/Component/Translation/Translator.php
index 8a2b2dd9d0c60..ec312ae787301 100644
--- a/src/Symfony/Component/Translation/Translator.php
+++ b/src/Symfony/Component/Translation/Translator.php
@@ -430,7 +430,7 @@ private function loadFallbackCatalogues($locale): void
protected function computeFallbackLocales($locale)
{
if (null === $this->parentLocales) {
- $parentLocales = \json_decode(\file_get_contents(__DIR__.'/Resources/data/parents.json'), true);
+ $parentLocales = json_decode(file_get_contents(__DIR__.'/Resources/data/parents.json'), true);
}
$locales = [];
diff --git a/src/Symfony/Component/Validator/CHANGELOG.md b/src/Symfony/Component/Validator/CHANGELOG.md
index 3863b5717a1fe..2d24f7c69cd3d 100644
--- a/src/Symfony/Component/Validator/CHANGELOG.md
+++ b/src/Symfony/Component/Validator/CHANGELOG.md
@@ -9,7 +9,7 @@ CHANGELOG
* added `DivisibleBy` constraint
* decoupled from `symfony/translation` by using `Symfony\Contracts\Translation\TranslatorInterface`
* deprecated `ValidatorBuilderInterface`
- * made `ValidatorBuilder` final
+ * made `ValidatorBuilder::setTranslator()` final
* marked `format` the default option in `DateTime` constraint
* deprecated validating instances of `\DateTimeInterface` in `DateTimeValidator`, `DateValidator` and `TimeValidator`.
* deprecated using the `Bic`, `Country`, `Currency`, `Language` and `Locale` constraints without `symfony/intl`
diff --git a/src/Symfony/Component/Validator/Constraints/AbstractComparison.php b/src/Symfony/Component/Validator/Constraints/AbstractComparison.php
index 89c2690c081cd..435ced6eb8486 100644
--- a/src/Symfony/Component/Validator/Constraints/AbstractComparison.php
+++ b/src/Symfony/Component/Validator/Constraints/AbstractComparison.php
@@ -14,6 +14,7 @@
use Symfony\Component\PropertyAccess\PropertyAccess;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
+use Symfony\Component\Validator\Exception\LogicException;
/**
* Used for the comparison of values.
@@ -46,7 +47,7 @@ public function __construct($options = null)
}
if (isset($options['propertyPath']) && !class_exists(PropertyAccess::class)) {
- throw new ConstraintDefinitionException(sprintf('The "%s" constraint requires the Symfony PropertyAccess component to use the "propertyPath" option.', \get_class($this)));
+ throw new LogicException(sprintf('The "%s" constraint requires the Symfony PropertyAccess component to use the "propertyPath" option.', \get_class($this)));
}
}
diff --git a/src/Symfony/Component/Validator/Constraints/GroupSequence.php b/src/Symfony/Component/Validator/Constraints/GroupSequence.php
index a39d712bf4be7..fc34ca1a458e2 100644
--- a/src/Symfony/Component/Validator/Constraints/GroupSequence.php
+++ b/src/Symfony/Component/Validator/Constraints/GroupSequence.php
@@ -57,7 +57,7 @@ class GroupSequence
/**
* The groups in the sequence.
*
- * @var string[]|array[]|GroupSequence[]
+ * @var string[]|string[][]|GroupSequence[]
*/
public $groups;
diff --git a/src/Symfony/Component/Validator/Constraints/IssnValidator.php b/src/Symfony/Component/Validator/Constraints/IssnValidator.php
index 90dceba1faa2b..21b6403494c3b 100644
--- a/src/Symfony/Component/Validator/Constraints/IssnValidator.php
+++ b/src/Symfony/Component/Validator/Constraints/IssnValidator.php
@@ -121,7 +121,7 @@ public function validate($value, Constraint $constraint)
for ($i = 0; $i < 7; ++$i) {
// Multiply the first digit by 8, the second by 7, etc.
- $checkSum += (8 - $i) * $canonical[$i];
+ $checkSum += (8 - $i) * (int) $canonical[$i];
}
if (0 !== $checkSum % 11) {
diff --git a/src/Symfony/Component/Validator/Constraints/LuhnValidator.php b/src/Symfony/Component/Validator/Constraints/LuhnValidator.php
index c69057caa6aba..4a515c74cbbd3 100644
--- a/src/Symfony/Component/Validator/Constraints/LuhnValidator.php
+++ b/src/Symfony/Component/Validator/Constraints/LuhnValidator.php
@@ -84,7 +84,7 @@ public function validate($value, Constraint $constraint)
// ^ ^ ^ ^ ^
// = 1+8 + 4 + 6 + 1+6 + 2
for ($i = $length - 2; $i >= 0; $i -= 2) {
- $checkSum += array_sum(str_split($value[$i] * 2));
+ $checkSum += array_sum(str_split((int) $value[$i] * 2));
}
if (0 === $checkSum || 0 !== $checkSum % 10) {
diff --git a/src/Symfony/Component/Validator/GroupSequenceProviderInterface.php b/src/Symfony/Component/Validator/GroupSequenceProviderInterface.php
index 5894397da4deb..1ce504331f7f3 100644
--- a/src/Symfony/Component/Validator/GroupSequenceProviderInterface.php
+++ b/src/Symfony/Component/Validator/GroupSequenceProviderInterface.php
@@ -22,7 +22,7 @@ interface GroupSequenceProviderInterface
* Returns which validation groups should be used for a certain state
* of the object.
*
- * @return string[]|GroupSequence An array of validation groups
+ * @return string[]|string[][]|GroupSequence An array of validation groups
*/
public function getGroupSequence();
}
diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.hr.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.hr.xlf
index 60f02435f5f27..ccc0c0135a36d 100644
--- a/src/Symfony/Component/Validator/Resources/translations/validators.hr.xlf
+++ b/src/Symfony/Component/Validator/Resources/translations/validators.hr.xlf
@@ -334,6 +334,34 @@
This value should be valid JSON.
Ova vrijednost treba biti validan JSON.
+
+ This collection should contain only unique elements.
+ Ova kolekcija treba sadržavati samo unikatne elemente.
+
+
+ This value should be positive.
+ Ova vrijednost treba biti pozitivna.
+
+
+ This value should be either positive or zero.
+ Ova vrijednost treba biti pozitivna ili jednaka nuli.
+
+
+ This value should be negative.
+ Ova vrijednost treba biti negativna.
+
+
+ This value should be either negative or zero.
+ Ova vrijednost treba biti negativna ili jednaka nuli.
+
+
+ This value is not a valid timezone.
+ Ova vrijednost nije validna vremenska zona.
+
+
+ This password has been leaked in a data breach, it must not be used. Please use another password.
+ Ova lozinka je procurila u nekom od sigurnosnih propusta, te je potrebno koristiti drugu lozinku.
+
diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.it.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.it.xlf
index 235d44d1bbee9..f4c188d1dd3aa 100644
--- a/src/Symfony/Component/Validator/Resources/translations/validators.it.xlf
+++ b/src/Symfony/Component/Validator/Resources/translations/validators.it.xlf
@@ -330,6 +330,38 @@
This Business Identifier Code (BIC) is not associated with IBAN {{ iban }}.
Questo codice identificativo bancario (BIC) non è associato all'IBAN {{ iban }}.
+
+ This value should be valid JSON.
+ Questo valore dovrebbe essere un JSON valido.
+
+
+ This collection should contain only unique elements.
+ Questa collezione dovrebbe contenere solo elementi unici.
+
+
+ This value should be positive.
+ Questo valore dovrebbe essere positivo.
+
+
+ This value should be either positive or zero.
+ Questo valore dovrebbe essere positivo oppure zero.
+
+
+ This value should be negative.
+ Questo valore dovrebbe essere negativo.
+
+
+ This value should be either negative or zero.
+ Questo valore dovrebbe essere negativo oppure zero.
+
+
+ This value is not a valid timezone.
+ Questo valore non è un fuso orario valido.
+
+
+ This password has been leaked in a data breach, it must not be used. Please use another password.
+ Questa password è trapelata durante una compromissione di dati, non deve essere usata. Si prega di usare una password diversa.
+
diff --git a/src/Symfony/Component/Validator/Test/ConstraintValidatorTestCase.php b/src/Symfony/Component/Validator/Test/ConstraintValidatorTestCase.php
index e110dbd0bccc8..35e78268d447c 100644
--- a/src/Symfony/Component/Validator/Test/ConstraintValidatorTestCase.php
+++ b/src/Symfony/Component/Validator/Test/ConstraintValidatorTestCase.php
@@ -110,7 +110,7 @@ protected function createContext()
$validator->expects($this->any())
->method('inContext')
->with($context)
- ->will($this->returnValue($contextualValidator));
+ ->willReturn($contextualValidator);
return $context;
}
@@ -175,7 +175,7 @@ protected function expectValidateAt($i, $propertyPath, $value, $group)
$validator->expects($this->at(2 * $i))
->method('atPath')
->with($propertyPath)
- ->will($this->returnValue($validator));
+ ->willReturn($validator);
$validator->expects($this->at(2 * $i + 1))
->method('validate')
->with($value, $this->logicalOr(null, [], $this->isInstanceOf('\Symfony\Component\Validator\Constraints\Valid')), $group);
@@ -187,7 +187,7 @@ protected function expectValidateValueAt($i, $propertyPath, $value, $constraints
$contextualValidator->expects($this->at(2 * $i))
->method('atPath')
->with($propertyPath)
- ->will($this->returnValue($contextualValidator));
+ ->willReturn($contextualValidator);
$contextualValidator->expects($this->at(2 * $i + 1))
->method('validate')
->with($value, $constraints, $group);
diff --git a/src/Symfony/Component/Validator/Tests/Constraints/ExpressionValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/ExpressionValidatorTest.php
index a61d6d675eef0..7e1b460a807a0 100644
--- a/src/Symfony/Component/Validator/Tests/Constraints/ExpressionValidatorTest.php
+++ b/src/Symfony/Component/Validator/Tests/Constraints/ExpressionValidatorTest.php
@@ -258,11 +258,11 @@ public function testExpressionLanguageUsage()
$used = false;
$expressionLanguage->method('evaluate')
- ->will($this->returnCallback(function () use (&$used) {
+ ->willReturnCallback(function () use (&$used) {
$used = true;
return true;
- }));
+ });
$validator = new ExpressionValidator(null, $expressionLanguage);
$validator->initialize($this->createContext());
diff --git a/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php
index 7915178e60223..c5105c20cf583 100644
--- a/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php
+++ b/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php
@@ -294,11 +294,11 @@ public function testValidMimeType()
$file
->expects($this->once())
->method('getPathname')
- ->will($this->returnValue($this->path));
+ ->willReturn($this->path);
$file
->expects($this->once())
->method('getMimeType')
- ->will($this->returnValue('image/jpg'));
+ ->willReturn('image/jpg');
$constraint = new File([
'mimeTypes' => ['image/png', 'image/jpg'],
@@ -318,11 +318,11 @@ public function testValidWildcardMimeType()
$file
->expects($this->once())
->method('getPathname')
- ->will($this->returnValue($this->path));
+ ->willReturn($this->path);
$file
->expects($this->once())
->method('getMimeType')
- ->will($this->returnValue('image/jpg'));
+ ->willReturn('image/jpg');
$constraint = new File([
'mimeTypes' => ['image/*'],
@@ -342,11 +342,11 @@ public function testInvalidMimeType()
$file
->expects($this->once())
->method('getPathname')
- ->will($this->returnValue($this->path));
+ ->willReturn($this->path);
$file
->expects($this->once())
->method('getMimeType')
- ->will($this->returnValue('application/pdf'));
+ ->willReturn('application/pdf');
$constraint = new File([
'mimeTypes' => ['image/png', 'image/jpg'],
@@ -373,11 +373,11 @@ public function testInvalidWildcardMimeType()
$file
->expects($this->once())
->method('getPathname')
- ->will($this->returnValue($this->path));
+ ->willReturn($this->path);
$file
->expects($this->once())
->method('getMimeType')
- ->will($this->returnValue('application/pdf'));
+ ->willReturn('application/pdf');
$constraint = new File([
'mimeTypes' => ['image/*', 'image/jpg'],
diff --git a/src/Symfony/Component/Validator/Tests/ContainerConstraintValidatorFactoryTest.php b/src/Symfony/Component/Validator/Tests/ContainerConstraintValidatorFactoryTest.php
index 3782fba46c3b1..5178bc3b3060d 100644
--- a/src/Symfony/Component/Validator/Tests/ContainerConstraintValidatorFactoryTest.php
+++ b/src/Symfony/Component/Validator/Tests/ContainerConstraintValidatorFactoryTest.php
@@ -54,7 +54,7 @@ public function testGetInstanceInvalidValidatorClass()
$constraint
->expects($this->once())
->method('validatedBy')
- ->will($this->returnValue('Fully\\Qualified\\ConstraintValidator\\Class\\Name'));
+ ->willReturn('Fully\\Qualified\\ConstraintValidator\\Class\\Name');
$factory = new ContainerConstraintValidatorFactory(new Container());
$factory->getInstance($constraint);
diff --git a/src/Symfony/Component/Validator/Tests/Mapping/Cache/AbstractCacheTest.php b/src/Symfony/Component/Validator/Tests/Mapping/Cache/AbstractCacheTest.php
index 4d0363fd717b4..bd088e0f093d7 100644
--- a/src/Symfony/Component/Validator/Tests/Mapping/Cache/AbstractCacheTest.php
+++ b/src/Symfony/Component/Validator/Tests/Mapping/Cache/AbstractCacheTest.php
@@ -31,7 +31,7 @@ public function testWrite()
$meta->expects($this->once())
->method('getClassName')
- ->will($this->returnValue('Foo\\Bar'));
+ ->willReturn('Foo\\Bar');
$this->cache->write($meta);
@@ -51,7 +51,7 @@ public function testHas()
$meta->expects($this->once())
->method('getClassName')
- ->will($this->returnValue('Foo\\Bar'));
+ ->willReturn('Foo\\Bar');
$this->assertFalse($this->cache->has('Foo\\Bar'), 'has() returns false when there is no entry');
@@ -68,7 +68,7 @@ public function testRead()
$meta->expects($this->once())
->method('getClassName')
- ->will($this->returnValue('Foo\\Bar'));
+ ->willReturn('Foo\\Bar');
$this->assertFalse($this->cache->read('Foo\\Bar'), 'read() returns false when there is no entry');
diff --git a/src/Symfony/Component/Validator/Tests/Mapping/Factory/LazyLoadingMetadataFactoryTest.php b/src/Symfony/Component/Validator/Tests/Mapping/Factory/LazyLoadingMetadataFactoryTest.php
index a7876d7f9168f..9ad85e3f904fe 100644
--- a/src/Symfony/Component/Validator/Tests/Mapping/Factory/LazyLoadingMetadataFactoryTest.php
+++ b/src/Symfony/Component/Validator/Tests/Mapping/Factory/LazyLoadingMetadataFactoryTest.php
@@ -97,7 +97,7 @@ public function testWriteMetadataToCache()
[$this->equalTo(self::PARENT_CLASS)],
[$this->equalTo(self::INTERFACE_A_CLASS)]
)
- ->will($this->returnValue(false));
+ ->willReturn(false);
$cache->expects($this->exactly(2))
->method('write')
->withConsecutive(
@@ -172,12 +172,12 @@ public function testMetadataCacheWithRuntimeConstraint()
$cache
->expects($this->any())
->method('write')
- ->will($this->returnCallback(function ($metadata) { serialize($metadata); }))
+ ->willReturnCallback(function ($metadata) { serialize($metadata); })
;
$cache->expects($this->any())
->method('read')
- ->will($this->returnValue(false));
+ ->willReturn(false);
$metadata = $factory->getMetadataFor(self::PARENT_CLASS);
$metadata->addConstraint(new Callback(function () {}));
diff --git a/src/Symfony/Component/Validator/Tests/Mapping/Loader/LoaderChainTest.php b/src/Symfony/Component/Validator/Tests/Mapping/Loader/LoaderChainTest.php
index f9905386c9601..45b8576f0e16a 100644
--- a/src/Symfony/Component/Validator/Tests/Mapping/Loader/LoaderChainTest.php
+++ b/src/Symfony/Component/Validator/Tests/Mapping/Loader/LoaderChainTest.php
@@ -46,12 +46,12 @@ public function testReturnsTrueIfAnyLoaderReturnedTrue()
$loader1 = $this->getMockBuilder('Symfony\Component\Validator\Mapping\Loader\LoaderInterface')->getMock();
$loader1->expects($this->any())
->method('loadClassMetadata')
- ->will($this->returnValue(true));
+ ->willReturn(true);
$loader2 = $this->getMockBuilder('Symfony\Component\Validator\Mapping\Loader\LoaderInterface')->getMock();
$loader2->expects($this->any())
->method('loadClassMetadata')
- ->will($this->returnValue(false));
+ ->willReturn(false);
$chain = new LoaderChain([
$loader1,
@@ -68,12 +68,12 @@ public function testReturnsFalseIfNoLoaderReturnedTrue()
$loader1 = $this->getMockBuilder('Symfony\Component\Validator\Mapping\Loader\LoaderInterface')->getMock();
$loader1->expects($this->any())
->method('loadClassMetadata')
- ->will($this->returnValue(false));
+ ->willReturn(false);
$loader2 = $this->getMockBuilder('Symfony\Component\Validator\Mapping\Loader\LoaderInterface')->getMock();
$loader2->expects($this->any())
->method('loadClassMetadata')
- ->will($this->returnValue(false));
+ ->willReturn(false);
$chain = new LoaderChain([
$loader1,
diff --git a/src/Symfony/Component/Validator/Tests/Validator/AbstractTest.php b/src/Symfony/Component/Validator/Tests/Validator/AbstractTest.php
index 1df64de4d99c6..2bc3d11ef6d49 100644
--- a/src/Symfony/Component/Validator/Tests/Validator/AbstractTest.php
+++ b/src/Symfony/Component/Validator/Tests/Validator/AbstractTest.php
@@ -610,9 +610,9 @@ public function testInitializeObjectsOnFirstValidation()
$initializer1->expects($this->once())
->method('initialize')
->with($entity)
- ->will($this->returnCallback(function ($object) {
+ ->willReturnCallback(function ($object) {
$object->initialized = true;
- }));
+ });
$initializer2->expects($this->once())
->method('initialize')
diff --git a/src/Symfony/Component/Validator/ValidatorBuilder.php b/src/Symfony/Component/Validator/ValidatorBuilder.php
index 0766a2e9f399a..a65cca4c3d921 100644
--- a/src/Symfony/Component/Validator/ValidatorBuilder.php
+++ b/src/Symfony/Component/Validator/ValidatorBuilder.php
@@ -38,8 +38,6 @@
* The default implementation of {@link ValidatorBuilderInterface}.
*
* @author Bernhard Schussek
- *
- * @final since Symfony 4.2
*/
class ValidatorBuilder implements ValidatorBuilderInterface
{
@@ -255,6 +253,8 @@ public function setConstraintValidatorFactory(ConstraintValidatorFactoryInterfac
/**
* {@inheritdoc}
+ *
+ * @final since Symfony 4.2
*/
public function setTranslator(LegacyTranslatorInterface $translator)
{
diff --git a/src/Symfony/Component/VarDumper/Caster/Caster.php b/src/Symfony/Component/VarDumper/Caster/Caster.php
index 292bd67eb4bd4..bf9e3cf356759 100644
--- a/src/Symfony/Component/VarDumper/Caster/Caster.php
+++ b/src/Symfony/Component/VarDumper/Caster/Caster.php
@@ -48,13 +48,8 @@ class Caster
*/
public static function castObject($obj, $class, $hasDebugInfo = false)
{
- if ($hasDebugInfo) {
- $a = $obj->__debugInfo();
- } elseif ($obj instanceof \Closure) {
- $a = [];
- } else {
- $a = (array) $obj;
- }
+ $a = $obj instanceof \Closure ? [] : (array) $obj;
+
if ($obj instanceof \__PHP_Incomplete_Class) {
return $a;
}
@@ -88,6 +83,17 @@ public static function castObject($obj, $class, $hasDebugInfo = false)
}
}
+ if ($hasDebugInfo && \is_array($debugInfo = $obj->__debugInfo())) {
+ foreach ($debugInfo as $k => $v) {
+ if (!isset($k[0]) || "\0" !== $k[0]) {
+ $k = self::PREFIX_VIRTUAL.$k;
+ }
+
+ unset($a[$k]);
+ $a[$k] = $v;
+ }
+ }
+
return $a;
}
diff --git a/src/Symfony/Component/VarDumper/Caster/ClassStub.php b/src/Symfony/Component/VarDumper/Caster/ClassStub.php
index b655ae960e16f..0b9329dbe903f 100644
--- a/src/Symfony/Component/VarDumper/Caster/ClassStub.php
+++ b/src/Symfony/Component/VarDumper/Caster/ClassStub.php
@@ -57,7 +57,7 @@ public function __construct(string $identifier, $callable = null)
if (false !== strpos($identifier, "class@anonymous\0")) {
$this->value = $identifier = preg_replace_callback('/class@anonymous\x00.*?\.php0x?[0-9a-fA-F]++/', function ($m) {
- return \class_exists($m[0], false) ? get_parent_class($m[0]).'@anonymous' : $m[0];
+ return class_exists($m[0], false) ? get_parent_class($m[0]).'@anonymous' : $m[0];
}, $identifier);
}
diff --git a/src/Symfony/Component/VarDumper/Caster/DateCaster.php b/src/Symfony/Component/VarDumper/Caster/DateCaster.php
index 29c123d6ee5e3..f4c3c26c41210 100644
--- a/src/Symfony/Component/VarDumper/Caster/DateCaster.php
+++ b/src/Symfony/Component/VarDumper/Caster/DateCaster.php
@@ -88,7 +88,7 @@ public static function castPeriod(\DatePeriod $p, array $a, Stub $stub, $isNeste
if (self::PERIOD_LIMIT === $i) {
$now = new \DateTimeImmutable();
$dates[] = sprintf('%s more', ($end = $p->getEndDate())
- ? ceil(($end->format('U.u') - $d->format('U.u')) / ($now->add($p->getDateInterval())->format('U.u') - $now->format('U.u')))
+ ? ceil(($end->format('U.u') - $d->format('U.u')) / ((int) $now->add($p->getDateInterval())->format('U.u') - (int) $now->format('U.u')))
: $p->recurrences - $i
);
break;
diff --git a/src/Symfony/Component/VarDumper/Caster/ExceptionCaster.php b/src/Symfony/Component/VarDumper/Caster/ExceptionCaster.php
index 06cd11e63dd50..83296bbc1a74b 100644
--- a/src/Symfony/Component/VarDumper/Caster/ExceptionCaster.php
+++ b/src/Symfony/Component/VarDumper/Caster/ExceptionCaster.php
@@ -283,7 +283,7 @@ private static function filterExceptionArray($xClass, array $a, $xPrefix, $filte
if (isset($a[Caster::PREFIX_PROTECTED.'message']) && false !== strpos($a[Caster::PREFIX_PROTECTED.'message'], "class@anonymous\0")) {
$a[Caster::PREFIX_PROTECTED.'message'] = preg_replace_callback('/class@anonymous\x00.*?\.php0x?[0-9a-fA-F]++/', function ($m) {
- return \class_exists($m[0], false) ? get_parent_class($m[0]).'@anonymous' : $m[0];
+ return class_exists($m[0], false) ? get_parent_class($m[0]).'@anonymous' : $m[0];
}, $a[Caster::PREFIX_PROTECTED.'message']);
}
diff --git a/src/Symfony/Component/VarDumper/Caster/ProxyManagerCaster.php b/src/Symfony/Component/VarDumper/Caster/ProxyManagerCaster.php
index da037b6b3e8b3..d8afd704006a8 100644
--- a/src/Symfony/Component/VarDumper/Caster/ProxyManagerCaster.php
+++ b/src/Symfony/Component/VarDumper/Caster/ProxyManagerCaster.php
@@ -21,7 +21,7 @@ class ProxyManagerCaster
{
public static function castProxy(ProxyInterface $c, array $a, Stub $stub, $isNested)
{
- if ($parent = \get_parent_class($c)) {
+ if ($parent = get_parent_class($c)) {
$stub->class .= ' - '.$parent;
}
$stub->class .= '@proxy';
diff --git a/src/Symfony/Component/VarDumper/Cloner/VarCloner.php b/src/Symfony/Component/VarDumper/Cloner/VarCloner.php
index b8318c514ffbf..58c2117737f99 100644
--- a/src/Symfony/Component/VarDumper/Cloner/VarCloner.php
+++ b/src/Symfony/Component/VarDumper/Cloner/VarCloner.php
@@ -73,7 +73,7 @@ protected function doClone($var)
}
if ($gk !== $k) {
$fromObjCast = true;
- $refs = $vals = \array_values($queue[$i]);
+ $refs = $vals = array_values($queue[$i]);
break;
}
}
@@ -84,7 +84,7 @@ protected function doClone($var)
if ($zvalIsRef = $vals[$k] === $cookie) {
$vals[$k] = &$stub; // Break hard references to make $queue completely
unset($stub); // independent from the original structure
- if ($v instanceof Stub && isset($hardRefs[\spl_object_id($v)])) {
+ if ($v instanceof Stub && isset($hardRefs[spl_object_id($v)])) {
$vals[$k] = $refs[$k] = $v;
if ($v->value instanceof Stub && (Stub::TYPE_OBJECT === $v->value->type || Stub::TYPE_RESOURCE === $v->value->type)) {
++$v->value->refCount;
@@ -94,7 +94,7 @@ protected function doClone($var)
}
$refs[$k] = $vals[$k] = new Stub();
$refs[$k]->value = $v;
- $h = \spl_object_id($refs[$k]);
+ $h = spl_object_id($refs[$k]);
$hardRefs[$h] = &$refs[$k];
$values[$h] = $v;
$vals[$k]->handle = ++$refsCounter;
@@ -112,22 +112,22 @@ protected function doClone($var)
if ('' === $v) {
continue 2;
}
- if (!\preg_match('//u', $v)) {
+ if (!preg_match('//u', $v)) {
$stub = new Stub();
$stub->type = Stub::TYPE_STRING;
$stub->class = Stub::STRING_BINARY;
if (0 <= $maxString && 0 < $cut = \strlen($v) - $maxString) {
$stub->cut = $cut;
- $stub->value = \substr($v, 0, -$cut);
+ $stub->value = substr($v, 0, -$cut);
} else {
$stub->value = $v;
}
- } elseif (0 <= $maxString && isset($v[1 + ($maxString >> 2)]) && 0 < $cut = \mb_strlen($v, 'UTF-8') - $maxString) {
+ } elseif (0 <= $maxString && isset($v[1 + ($maxString >> 2)]) && 0 < $cut = mb_strlen($v, 'UTF-8') - $maxString) {
$stub = new Stub();
$stub->type = Stub::TYPE_STRING;
$stub->class = Stub::STRING_UTF8;
$stub->cut = $cut;
- $stub->value = \mb_substr($v, 0, $maxString, 'UTF-8');
+ $stub->value = mb_substr($v, 0, $maxString, 'UTF-8');
} else {
continue 2;
}
@@ -173,7 +173,7 @@ protected function doClone($var)
case \is_object($v):
case $v instanceof \__PHP_Incomplete_Class:
- if (empty($objRefs[$h = \spl_object_id($v)])) {
+ if (empty($objRefs[$h = spl_object_id($v)])) {
$stub = new Stub();
$stub->type = Stub::TYPE_OBJECT;
$stub->class = \get_class($v);
@@ -184,7 +184,7 @@ protected function doClone($var)
if (Stub::TYPE_OBJECT !== $stub->type || null === $stub->value) {
break;
}
- $stub->handle = $h = \spl_object_id($stub->value);
+ $stub->handle = $h = spl_object_id($stub->value);
}
$stub->value = null;
if (0 <= $maxItems && $maxItems <= $pos && $minimumDepthReached) {
@@ -206,7 +206,7 @@ protected function doClone($var)
if (empty($resRefs[$h = (int) $v])) {
$stub = new Stub();
$stub->type = Stub::TYPE_RESOURCE;
- if ('Unknown' === $stub->class = @\get_resource_type($v)) {
+ if ('Unknown' === $stub->class = @get_resource_type($v)) {
$stub->class = 'Closed';
}
$stub->value = $v;
diff --git a/src/Symfony/Component/VarDumper/Tests/Caster/IntlCasterTest.php b/src/Symfony/Component/VarDumper/Tests/Caster/IntlCasterTest.php
index c93b9df83d55a..0bff5bf496385 100644
--- a/src/Symfony/Component/VarDumper/Tests/Caster/IntlCasterTest.php
+++ b/src/Symfony/Component/VarDumper/Tests/Caster/IntlCasterTest.php
@@ -240,6 +240,12 @@ public function testCastDateFormatter()
$expectedTimeType = $var->getTimeType();
$expectedDateType = $var->getDateType();
+ $expectedTimeZone = $var->getTimeZone();
+ $expectedTimeZoneDisplayName = $expectedTimeZone->getDisplayName();
+ $expectedTimeZoneID = $expectedTimeZone->getID();
+ $expectedTimeZoneRawOffset = $expectedTimeZone->getRawOffset();
+ $expectedTimeZoneDSTSavings = $expectedTimeZone->useDaylightTime() ? "\n dst_savings: ".$expectedTimeZone->getDSTSavings() : '';
+
$expectedCalendarObject = $var->getCalendarObject();
$expectedCalendarObjectType = $expectedCalendarObject->getType();
$expectedCalendarObjectFirstDayOfWeek = $expectedCalendarObject->getFirstDayOfWeek();
@@ -254,13 +260,7 @@ public function testCastDateFormatter()
$expectedCalendarObjectTimeZoneDisplayName = $expectedCalendarObjectTimeZone->getDisplayName();
$expectedCalendarObjectTimeZoneID = $expectedCalendarObjectTimeZone->getID();
$expectedCalendarObjectTimeZoneRawOffset = $expectedCalendarObjectTimeZone->getRawOffset();
- $expectedCalendarObjectTimeZoneDSTSavings = $expectedCalendarObjectTimeZone->getDSTSavings();
-
- $expectedTimeZone = $var->getTimeZone();
- $expectedTimeZoneDisplayName = $expectedTimeZone->getDisplayName();
- $expectedTimeZoneID = $expectedTimeZone->getID();
- $expectedTimeZoneRawOffset = $expectedTimeZone->getRawOffset();
- $expectedTimeZoneDSTSavings = $expectedTimeZone->getDSTSavings();
+ $expectedCalendarObjectTimeZoneDSTSavings = $expectedTimeZone->useDaylightTime() ? "\n dst_savings: ".$expectedCalendarObjectTimeZone->getDSTSavings() : '';
$expected = << $value) {
if (\is_resource($value)) {
- throw new NotInstantiableTypeException(\get_resource_type($value).' resource');
+ throw new NotInstantiableTypeException(get_resource_type($value).' resource');
}
$refs[$k] = $objectsPool;
@@ -115,14 +115,14 @@ public static function prepare($values, $objectsPool, &$refsPool, &$objectsCount
goto handle_value;
}
- if (\method_exists($class, '__sleep')) {
+ if (method_exists($class, '__sleep')) {
if (!\is_array($sleep = $value->__sleep())) {
trigger_error('serialize(): __sleep should return an array only containing the names of instance-variables to serialize', E_USER_NOTICE);
$value = null;
goto handle_value;
}
foreach ($sleep as $name) {
- if (\property_exists($value, $name) && !$reflector->hasProperty($name)) {
+ if (property_exists($value, $name) && !$reflector->hasProperty($name)) {
$arrayValue[$name] = $value->$name;
}
}
@@ -171,7 +171,7 @@ public static function prepare($values, $objectsPool, &$refsPool, &$objectsCount
$objectsPool[$value] = [$id = \count($objectsPool)];
$properties = self::prepare($properties, $objectsPool, $refsPool, $objectsCount, $valueIsStatic);
++$objectsCount;
- $objectsPool[$value] = [$id, $class, $properties, \method_exists($class, '__unserialize') ? -$objectsCount : (\method_exists($class, '__wakeup') ? $objectsCount : 0)];
+ $objectsPool[$value] = [$id, $class, $properties, method_exists($class, '__unserialize') ? -$objectsCount : (method_exists($class, '__wakeup') ? $objectsCount : 0)];
$value = new Reference($id);
diff --git a/src/Symfony/Component/VarExporter/Internal/Hydrator.php b/src/Symfony/Component/VarExporter/Internal/Hydrator.php
index 5f64adf96fb53..364d292d916e7 100644
--- a/src/Symfony/Component/VarExporter/Internal/Hydrator.php
+++ b/src/Symfony/Component/VarExporter/Internal/Hydrator.php
@@ -65,7 +65,7 @@ public static function getHydrator($class)
};
}
- if (!\class_exists($class) && !\interface_exists($class, false) && !\trait_exists($class, false)) {
+ if (!class_exists($class) && !interface_exists($class, false) && !trait_exists($class, false)) {
throw new ClassNotFoundException($class);
}
$classReflector = new \ReflectionClass($class);
diff --git a/src/Symfony/Component/VarExporter/Internal/Registry.php b/src/Symfony/Component/VarExporter/Internal/Registry.php
index b5069dd16aa84..dd2792133e425 100644
--- a/src/Symfony/Component/VarExporter/Internal/Registry.php
+++ b/src/Symfony/Component/VarExporter/Internal/Registry.php
@@ -65,7 +65,7 @@ public static function f($class)
public static function getClassReflector($class, $instantiableWithoutConstructor = false, $cloneable = null)
{
- if (!($isClass = \class_exists($class)) && !\interface_exists($class, false) && !\trait_exists($class, false)) {
+ if (!($isClass = class_exists($class)) && !interface_exists($class, false) && !trait_exists($class, false)) {
throw new ClassNotFoundException($class);
}
$reflector = new \ReflectionClass($class);
@@ -86,14 +86,14 @@ public static function getClassReflector($class, $instantiableWithoutConstructor
$proto = $reflector->newInstanceWithoutConstructor();
$instantiableWithoutConstructor = true;
} catch (\ReflectionException $e) {
- $proto = $reflector->implementsInterface('Serializable') && (\PHP_VERSION_ID < 70400 || !\method_exists($class, '__unserialize')) ? 'C:' : 'O:';
+ $proto = $reflector->implementsInterface('Serializable') && (\PHP_VERSION_ID < 70400 || !method_exists($class, '__unserialize')) ? 'C:' : 'O:';
if ('C:' === $proto && !$reflector->getMethod('unserialize')->isInternal()) {
$proto = null;
} elseif (false === $proto = @unserialize($proto.\strlen($class).':"'.$class.'":0:{}')) {
throw new NotInstantiableTypeException($class);
}
}
- if (null !== $proto && !$proto instanceof \Throwable && !$proto instanceof \Serializable && !\method_exists($class, '__sleep') && (\PHP_VERSION_ID < 70400 || !\method_exists($class, '__serialize'))) {
+ if (null !== $proto && !$proto instanceof \Throwable && !$proto instanceof \Serializable && !method_exists($class, '__sleep') && (\PHP_VERSION_ID < 70400 || !method_exists($class, '__serialize'))) {
try {
serialize($proto);
} catch (\Exception $e) {
@@ -103,7 +103,7 @@ public static function getClassReflector($class, $instantiableWithoutConstructor
}
if (null === $cloneable) {
- if (($proto instanceof \Reflector || $proto instanceof \ReflectionGenerator || $proto instanceof \ReflectionType || $proto instanceof \IteratorIterator || $proto instanceof \RecursiveIteratorIterator) && (!$proto instanceof \Serializable && !\method_exists($proto, '__wakeup') && (\PHP_VERSION_ID < 70400 || !\method_exists($class, '__unserialize')))) {
+ if (($proto instanceof \Reflector || $proto instanceof \ReflectionGenerator || $proto instanceof \ReflectionType || $proto instanceof \IteratorIterator || $proto instanceof \RecursiveIteratorIterator) && (!$proto instanceof \Serializable && !method_exists($proto, '__wakeup') && (\PHP_VERSION_ID < 70400 || !method_exists($class, '__unserialize')))) {
throw new NotInstantiableTypeException($class);
}
diff --git a/src/Symfony/Component/VarExporter/README.md b/src/Symfony/Component/VarExporter/README.md
index 180554ed1a036..bb13960e0d929 100644
--- a/src/Symfony/Component/VarExporter/README.md
+++ b/src/Symfony/Component/VarExporter/README.md
@@ -31,7 +31,7 @@ It also provides a few improvements over `var_export()`/`serialize()`:
Resources
---------
- * [Documentation](https://symfony.com/doc/current/components/var_exporter/introduction.html)
+ * [Documentation](https://symfony.com/doc/current/components/var_exporter.html)
* [Contributing](https://symfony.com/doc/current/contributing/index.html)
* [Report issues](https://github.com/symfony/symfony/issues) and
[send Pull Requests](https://github.com/symfony/symfony/pulls)
diff --git a/src/Symfony/Component/Workflow/Dumper/GraphvizDumper.php b/src/Symfony/Component/Workflow/Dumper/GraphvizDumper.php
index 5a1654ae5503e..c0247014e7fcd 100644
--- a/src/Symfony/Component/Workflow/Dumper/GraphvizDumper.php
+++ b/src/Symfony/Component/Workflow/Dumper/GraphvizDumper.php
@@ -213,7 +213,7 @@ protected function dotize($id)
*/
protected function escape($value): string
{
- return \is_bool($value) ? ($value ? '1' : '0') : \addslashes($value);
+ return \is_bool($value) ? ($value ? '1' : '0') : addslashes($value);
}
private function addAttributes(array $attributes): string
diff --git a/src/Symfony/Component/Workflow/Tests/RegistryTest.php b/src/Symfony/Component/Workflow/Tests/RegistryTest.php
index 867046f7c5db3..d96c6fe645106 100644
--- a/src/Symfony/Component/Workflow/Tests/RegistryTest.php
+++ b/src/Symfony/Component/Workflow/Tests/RegistryTest.php
@@ -115,9 +115,9 @@ private function createSupportStrategy($supportedClassName)
{
$strategy = $this->getMockBuilder(SupportStrategyInterface::class)->getMock();
$strategy->expects($this->any())->method('supports')
- ->will($this->returnCallback(function ($workflow, $subject) use ($supportedClassName) {
+ ->willReturnCallback(function ($workflow, $subject) use ($supportedClassName) {
return $subject instanceof $supportedClassName;
- }));
+ });
return $strategy;
}
@@ -129,9 +129,9 @@ private function createWorkflowSupportStrategy($supportedClassName)
{
$strategy = $this->getMockBuilder(WorkflowSupportStrategyInterface::class)->getMock();
$strategy->expects($this->any())->method('supports')
- ->will($this->returnCallback(function ($workflow, $subject) use ($supportedClassName) {
+ ->willReturnCallback(function ($workflow, $subject) use ($supportedClassName) {
return $subject instanceof $supportedClassName;
- }));
+ });
return $strategy;
}
diff --git a/src/Symfony/Component/Workflow/Tests/StateMachineTest.php b/src/Symfony/Component/Workflow/Tests/StateMachineTest.php
index 7f76c4a70b1ea..8354229a35af1 100644
--- a/src/Symfony/Component/Workflow/Tests/StateMachineTest.php
+++ b/src/Symfony/Component/Workflow/Tests/StateMachineTest.php
@@ -78,7 +78,7 @@ public function testBuildTransitionBlockerListReturnsExpectedReasonOnBranchMerge
$net = new StateMachine($definition, null, $dispatcher);
$dispatcher->addListener('workflow.guard', function (GuardEvent $event) {
- $event->addTransitionBlocker(new TransitionBlocker(\sprintf('Transition blocker of place %s', $event->getTransition()->getFroms()[0]), 'blocker'));
+ $event->addTransitionBlocker(new TransitionBlocker(sprintf('Transition blocker of place %s', $event->getTransition()->getFroms()[0]), 'blocker'));
});
$subject = new \stdClass();
diff --git a/src/Symfony/Contracts/Translation/TranslatorTrait.php b/src/Symfony/Contracts/Translation/TranslatorTrait.php
index c1021923c835a..488b4f4f23974 100644
--- a/src/Symfony/Contracts/Translation/TranslatorTrait.php
+++ b/src/Symfony/Contracts/Translation/TranslatorTrait.php
@@ -91,7 +91,7 @@ public function trans($id, array $parameters = [], $domain = null, $locale = nul
}
} else {
$leftNumber = '-Inf' === $matches['left'] ? -INF : (float) $matches['left'];
- $rightNumber = \is_numeric($matches['right']) ? (float) $matches['right'] : INF;
+ $rightNumber = is_numeric($matches['right']) ? (float) $matches['right'] : INF;
if (('[' === $matches['left_delimiter'] ? $number >= $leftNumber : $number > $leftNumber)
&& (']' === $matches['right_delimiter'] ? $number <= $rightNumber : $number < $rightNumber)
@@ -117,7 +117,7 @@ public function trans($id, array $parameters = [], $domain = null, $locale = nul
$message = sprintf('Unable to choose a translation for "%s" with locale "%s" for value "%d". Double check that this translation has the correct plural options (e.g. "There is one apple|There are %%count%% apples").', $id, $locale, $number);
- if (\class_exists(InvalidArgumentException::class)) {
+ if (class_exists(InvalidArgumentException::class)) {
throw new InvalidArgumentException($message);
}