diff --git a/UPGRADE-4.2.md b/UPGRADE-4.2.md index 67481540bd..d2db3db090 100644 --- a/UPGRADE-4.2.md +++ b/UPGRADE-4.2.md @@ -1,6 +1,11 @@ UPGRADE FROM 4.1 to 4.2 ======================= +BrowserKit +---------- + + * The `Client::submit()` method will have a new `$serverParameters` argument in version 5.0, not defining it is deprecated. + Cache ----- @@ -37,6 +42,16 @@ DoctrineBridge * The `lazy` attribute on `doctrine.event_listener` tags was removed. Listeners are now lazy by default. So any `lazy` attributes can safely be removed from those tags. +DomCrawler +---------- + + * The `Crawler::children()` method will have a new `$selector` argument in version 5.0, not defining it is deprecated. + +Finder +------ + + * The `Finder::sortByName()` method will have a new `$useNaturalSort` argument in version 5.0, not defining it is deprecated. + Form ---- @@ -145,6 +160,11 @@ Messenger Each interface method have been merged untouched into the `Serializer` interface, so you can simply merge your two implementations together and implement the new interface. +Monolog +------- + + * The methods `DebugProcessor::getLogs()`, `DebugProcessor::countErrors()`, `Logger::getLogs()` and `Logger::countErrors()` will have a new `$request` argument in version 5.0, not defining it is deprecated. + Security -------- @@ -171,8 +191,9 @@ SecurityBundle Serializer ---------- - * Relying on the default value (false) of the "as_collection" option is deprecated since 4.2. + * Relying on the default value (false) of the "as_collection" option is deprecated. You should set it to false explicitly instead as true will be the default value in 5.0. + * The `AbstractNormalizer::handleCircularReference()` method will have two new `$format` and `$context` arguments in version 5.0, not defining them is deprecated. Translation ----------- diff --git a/UPGRADE-5.0.md b/UPGRADE-5.0.md index caea8ca9c1..49ec7e39a8 100644 --- a/UPGRADE-5.0.md +++ b/UPGRADE-5.0.md @@ -1,6 +1,11 @@ UPGRADE FROM 4.x to 5.0 ======================= +BrowserKit +---------- + + * The `Client::submit()` method has a new `$serverParameters` argument. + Cache ----- @@ -49,11 +54,21 @@ DoctrineBridge * Deprecated injecting `ClassMetadataFactory` in `DoctrineExtractor`, an instance of `EntityManagerInterface` should be injected instead +DomCrawler +---------- + + * The `Crawler::children()` method has a new `$selector` argument. + EventDispatcher --------------- * The `TraceableEventDispatcherInterface` has been removed. +Finder +------ + + * The `Finder::sortByName()` method has a new `$useNaturalSort` argument. + FrameworkBundle --------------- @@ -103,6 +118,11 @@ HttpFoundation * The `getClientSize()` method of the `UploadedFile` class has been removed. * The `getSession()` method of the `Request` class throws an exception when session is null. +Monolog +------- + + * The methods `DebugProcessor::getLogs()`, `DebugProcessor::countErrors()`, `Logger::getLogs()` and `Logger::countErrors()` have a new `$request` argument. + Process ------- @@ -144,6 +164,11 @@ SecurityBundle * The `security.authentication.trust_resolver.anonymous_class` parameter has been removed. * The `security.authentication.trust_resolver.rememberme_class` parameter has been removed. +Serializer +---------- + + * The `AbstractNormalizer::handleCircularReference()` method has two new `$format` and `$context` arguments. + Translation ----------- diff --git a/src/Symfony/Bridge/Monolog/CHANGELOG.md b/src/Symfony/Bridge/Monolog/CHANGELOG.md index 6d984c218a..cf5c9d3db8 100644 --- a/src/Symfony/Bridge/Monolog/CHANGELOG.md +++ b/src/Symfony/Bridge/Monolog/CHANGELOG.md @@ -5,6 +5,9 @@ CHANGELOG ----- * added `ProcessorInterface`: an optional interface to allow autoconfiguration of Monolog processors + * The methods `DebugProcessor::getLogs()`, `DebugProcessor::countErrors()`, `Logger::getLogs()` + and `Logger::countErrors()` will have a new `$request` argument in version 5.0, not defining + it is deprecated since Symfony 4.2. 4.1.0 ----- diff --git a/src/Symfony/Bridge/Monolog/Logger.php b/src/Symfony/Bridge/Monolog/Logger.php index d884cd9792..531ec8875b 100644 --- a/src/Symfony/Bridge/Monolog/Logger.php +++ b/src/Symfony/Bridge/Monolog/Logger.php @@ -26,6 +26,10 @@ class Logger extends BaseLogger implements DebugLoggerInterface, ResetInterface */ public function getLogs(/* Request $request = null */) { + if (\func_num_args() < 1 && __CLASS__ !== \get_class($this) && __CLASS__ !== (new \ReflectionMethod($this, __FUNCTION__))->getDeclaringClass()->getName() && !$this instanceof \PHPUnit\Framework\MockObject\MockObject && !$this instanceof \Prophecy\Prophecy\ProphecySubjectInterface) { + @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 ($logger = $this->getDebugLogger()) { return $logger->getLogs(...\func_get_args()); } @@ -38,6 +42,10 @@ class Logger extends BaseLogger implements DebugLoggerInterface, ResetInterface */ public function countErrors(/* Request $request = null */) { + if (\func_num_args() < 1 && __CLASS__ !== \get_class($this) && __CLASS__ !== (new \ReflectionMethod($this, __FUNCTION__))->getDeclaringClass()->getName() && !$this instanceof \PHPUnit\Framework\MockObject\MockObject && !$this instanceof \Prophecy\Prophecy\ProphecySubjectInterface) { + @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 ($logger = $this->getDebugLogger()) { return $logger->countErrors(...\func_get_args()); } diff --git a/src/Symfony/Bridge/Monolog/Processor/DebugProcessor.php b/src/Symfony/Bridge/Monolog/Processor/DebugProcessor.php index 13f8a2de3e..1a8c7edd85 100644 --- a/src/Symfony/Bridge/Monolog/Processor/DebugProcessor.php +++ b/src/Symfony/Bridge/Monolog/Processor/DebugProcessor.php @@ -61,6 +61,10 @@ class DebugProcessor implements DebugLoggerInterface, ResetInterface */ public function getLogs(/* Request $request = null */) { + if (\func_num_args() < 1 && __CLASS__ !== \get_class($this) && __CLASS__ !== (new \ReflectionMethod($this, __FUNCTION__))->getDeclaringClass()->getName() && !$this instanceof \PHPUnit\Framework\MockObject\MockObject && !$this instanceof \Prophecy\Prophecy\ProphecySubjectInterface) { + @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)) && isset($this->records[$hash = spl_object_hash($request)])) { return $this->records[$hash]; } @@ -77,6 +81,10 @@ class DebugProcessor implements DebugLoggerInterface, ResetInterface */ public function countErrors(/* Request $request = null */) { + if (\func_num_args() < 1 && __CLASS__ !== \get_class($this) && __CLASS__ !== (new \ReflectionMethod($this, __FUNCTION__))->getDeclaringClass()->getName() && !$this instanceof \PHPUnit\Framework\MockObject\MockObject && !$this instanceof \Prophecy\Prophecy\ProphecySubjectInterface) { + @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)) && isset($this->errorCount[$hash = spl_object_hash($request)])) { return $this->errorCount[$hash]; } diff --git a/src/Symfony/Bridge/Monolog/Tests/LoggerTest.php b/src/Symfony/Bridge/Monolog/Tests/LoggerTest.php index 46156adbd8..6ffade8073 100644 --- a/src/Symfony/Bridge/Monolog/Tests/LoggerTest.php +++ b/src/Symfony/Bridge/Monolog/Tests/LoggerTest.php @@ -107,4 +107,37 @@ class LoggerTest extends TestCase $this->assertEmpty($logger->getLogs()); $this->assertSame(0, $logger->countErrors()); } + + /** + * @group legacy + * @expectedDeprecation The "Symfony\Bridge\Monolog\Logger::getLogs()" method will have a new "Request $request = null" argument in version 5.0, not defining it is deprecated since Symfony 4.2. + */ + public function testInheritedClassCallGetLogsWithoutArgument() + { + $loggerChild = new ClassThatInheritLogger('test'); + $loggerChild->getLogs(); + } + + /** + * @group legacy + * @expectedDeprecation The "Symfony\Bridge\Monolog\Logger::countErrors()" method will have a new "Request $request = null" argument in version 5.0, not defining it is deprecated since Symfony 4.2. + */ + public function testInheritedClassCallCountErrorsWithoutArgument() + { + $loggerChild = new ClassThatInheritLogger('test'); + $loggerChild->countErrors(); + } +} + +class ClassThatInheritLogger extends Logger +{ + public function getLogs() + { + parent::getLogs(); + } + + public function countErrors() + { + parent::countErrors(); + } } diff --git a/src/Symfony/Bridge/Monolog/Tests/Processor/DebugProcessorTest.php b/src/Symfony/Bridge/Monolog/Tests/Processor/DebugProcessorTest.php index 9acaf6074e..d7a83dca7c 100644 --- a/src/Symfony/Bridge/Monolog/Tests/Processor/DebugProcessorTest.php +++ b/src/Symfony/Bridge/Monolog/Tests/Processor/DebugProcessorTest.php @@ -60,6 +60,26 @@ class DebugProcessorTest extends TestCase $this->assertSame(1, $processor->countErrors($request)); } + /** + * @group legacy + * @expectedDeprecation The "Symfony\Bridge\Monolog\Processor\DebugProcessor::getLogs()" method will have a new "Request $request = null" argument in version 5.0, not defining it is deprecated since Symfony 4.2. + */ + public function testInheritedClassCallGetLogsWithoutArgument() + { + $debugProcessorChild = new ClassThatInheritDebugProcessor(); + $debugProcessorChild->getLogs(); + } + + /** + * @group legacy + * @expectedDeprecation The "Symfony\Bridge\Monolog\Processor\DebugProcessor::countErrors()" method will have a new "Request $request = null" argument in version 5.0, not defining it is deprecated since Symfony 4.2. + */ + public function testInheritedClassCallCountErrorsWithoutArgument() + { + $debugProcessorChild = new ClassThatInheritDebugProcessor(); + $debugProcessorChild->countErrors(); + } + private function getRecord($level = Logger::WARNING, $message = 'test') { return array( @@ -73,3 +93,16 @@ class DebugProcessorTest extends TestCase ); } } + +class ClassThatInheritDebugProcessor extends DebugProcessor +{ + public function getLogs() + { + parent::getLogs(); + } + + public function countErrors() + { + parent::countErrors(); + } +} diff --git a/src/Symfony/Component/BrowserKit/CHANGELOG.md b/src/Symfony/Component/BrowserKit/CHANGELOG.md index ceb1af7c2a..55ff9e2803 100644 --- a/src/Symfony/Component/BrowserKit/CHANGELOG.md +++ b/src/Symfony/Component/BrowserKit/CHANGELOG.md @@ -1,6 +1,12 @@ CHANGELOG ========= +4.2.0 +----- + + * The method `Client::submit()` will have a new `$serverParameters` argument + in version 5.0, not defining it is deprecated since version 4.2 + 3.4.0 ----- diff --git a/src/Symfony/Component/BrowserKit/Client.php b/src/Symfony/Component/BrowserKit/Client.php index f2a4a7d1dd..e3056a3120 100644 --- a/src/Symfony/Component/BrowserKit/Client.php +++ b/src/Symfony/Component/BrowserKit/Client.php @@ -311,6 +311,10 @@ abstract class Client */ public function submit(Form $form, array $values = array()/*, array $serverParameters = array()*/) { + if (\func_num_args() < 3 && __CLASS__ !== \get_class($this) && __CLASS__ !== (new \ReflectionMethod($this, __FUNCTION__))->getDeclaringClass()->getName() && !$this instanceof \PHPUnit\Framework\MockObject\MockObject && !$this instanceof \Prophecy\Prophecy\ProphecySubjectInterface) { + @trigger_error(sprintf('The "%s()" method will have a new "array $serverParameters = array()" argument in version 5.0, not defining it is deprecated since Symfony 4.2.', __METHOD__), E_USER_DEPRECATED); + } + $form->setValues($values); $serverParameters = 2 < \func_num_args() ? func_get_arg(2) : array(); diff --git a/src/Symfony/Component/BrowserKit/Tests/ClientTest.php b/src/Symfony/Component/BrowserKit/Tests/ClientTest.php index 28005d2588..36de64c32d 100644 --- a/src/Symfony/Component/BrowserKit/Tests/ClientTest.php +++ b/src/Symfony/Component/BrowserKit/Tests/ClientTest.php @@ -16,6 +16,7 @@ use Symfony\Component\BrowserKit\Client; use Symfony\Component\BrowserKit\CookieJar; use Symfony\Component\BrowserKit\History; use Symfony\Component\BrowserKit\Response; +use Symfony\Component\DomCrawler\Form as DomCrawlerForm; class SpecialResponse extends Response { @@ -877,4 +878,42 @@ class ClientTest extends TestCase $client = new TestClient(); $this->assertNull($client->getInternalRequest()); } + + /** + * @group legacy + * @expectedDeprecation The "Symfony\Component\BrowserKit\Client::submit()" method will have a new "array $serverParameters = array()" argument in version 5.0, not defining it is deprecated since Symfony 4.2. + */ + public function testInheritedClassCallSubmitWithTwoArguments() + { + $clientChild = new ClassThatInheritClient(); + $clientChild->setNextResponse(new Response('
')); + $clientChild->submit($clientChild->request('GET', 'http://www.example.com/foo/foobar')->filter('input')->form()); + } +} + +class ClassThatInheritClient extends Client +{ + protected $nextResponse = null; + + public function setNextResponse(Response $response) + { + $this->nextResponse = $response; + } + + protected function doRequest($request) + { + if (null === $this->nextResponse) { + return new Response(); + } + + $response = $this->nextResponse; + $this->nextResponse = null; + + return $response; + } + + public function submit(DomCrawlerForm $form, array $values = array()) + { + return parent::submit($form, $values); + } } diff --git a/src/Symfony/Component/DomCrawler/CHANGELOG.md b/src/Symfony/Component/DomCrawler/CHANGELOG.md index c2065c5911..c8c6c82325 100644 --- a/src/Symfony/Component/DomCrawler/CHANGELOG.md +++ b/src/Symfony/Component/DomCrawler/CHANGELOG.md @@ -6,6 +6,8 @@ CHANGELOG * The `$currentUri` constructor argument of the `AbstractUriElement`, `Link` and `Image` classes is now optional. +* The `Crawler::children()` method will have a new `$selector` argument in version 5.0, + not defining it is deprecated since version 4.2. 3.1.0 ----- diff --git a/src/Symfony/Component/DomCrawler/Crawler.php b/src/Symfony/Component/DomCrawler/Crawler.php index 373c5edb63..360ddbe26b 100644 --- a/src/Symfony/Component/DomCrawler/Crawler.php +++ b/src/Symfony/Component/DomCrawler/Crawler.php @@ -510,6 +510,9 @@ class Crawler implements \Countable, \IteratorAggregate */ public function children(/* string $selector = null */) { + if (\func_num_args() < 1 && __CLASS__ !== \get_class($this) && __CLASS__ !== (new \ReflectionMethod($this, __FUNCTION__))->getDeclaringClass()->getName() && !$this instanceof \PHPUnit\Framework\MockObject\MockObject && !$this instanceof \Prophecy\Prophecy\ProphecySubjectInterface) { + @trigger_error(sprintf('The "%s()" method will have a new "string $selector = null" argument in version 5.0, not defining it is deprecated since Symfony 4.2.', __METHOD__), E_USER_DEPRECATED); + } $selector = 0 < \func_num_args() ? func_get_arg(0) : null; if (!$this->nodes) { diff --git a/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php b/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php index 294c2f6bf8..9e73eaae1d 100644 --- a/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php +++ b/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php @@ -1148,6 +1148,62 @@ HTML; (new Crawler())->evaluate('//form/input[1]'); } + /** + * @group legacy + * @expectedDeprecation The "Symfony\Component\DomCrawler\Crawler::children()" method will have a new "string $selector = null" argument in version 5.0, not defining it is deprecated since Symfony 4.2. + */ + public function testInheritedClassCallChildrenWithoutArgument() + { + $dom = new \DOMDocument(); + $dom->loadHTML(' + + + Foo + Fabien\'s Foo + Fabien"s Foo + \' Fabien"s Foo + + Bar +    Fabien\'s Bar   + Fabien"s Bar + \' Fabien"s Bar + + GetLink + + Klausi|Claudiu + +
+ + + +