Skip to content

Commit fb00ce4

Browse files
committed
[Form] fixed deprecation triggers, removed usage of deprecated features
1 parent 1535738 commit fb00ce4

File tree

6 files changed

+23
-9
lines changed

6 files changed

+23
-9
lines changed

Exception/AlreadyBoundException.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
namespace Symfony\Component\Form\Exception;
1313

14-
trigger_error('The '.__NAMESPACE__.'\AlreadyBoundException class is deprecated since version 2.3 and will be removed in 3.0. Use the Symfony\Component\Form\Exception\AlreadySubmittedException class instead.', E_USER_DEPRECATED);
15-
1614
/**
1715
* Alias of {@link AlreadySubmittedException}.
1816
*
@@ -21,4 +19,12 @@
2119
*/
2220
class AlreadyBoundException extends LogicException
2321
{
22+
public function __construct($message = '', $code = 0, \Exception $previous = null)
23+
{
24+
if (__CLASS__ === get_class($this)) {
25+
trigger_error('The '.__CLASS__.' class is deprecated since version 2.3 and will be removed in 3.0. Use the Symfony\Component\Form\Exception\AlreadySubmittedException class instead.', E_USER_DEPRECATED);
26+
}
27+
28+
parent::__construct($message, $code, $previous);
29+
}
2430
}

Extension/Validator/ViolationMapper/ViolationMapper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ public function mapViolation(ConstraintViolation $violation, FormInterface $form
127127
$scope->addError(new FormError(
128128
$violation->getMessage(),
129129
$violation->getMessageTemplate(),
130-
$violation->getMessageParameters(),
131-
$violation->getMessagePluralization(),
130+
$violation->getParameters(),
131+
$violation->getPlural(),
132132
$violation
133133
));
134134
}

Tests/CompoundFormTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -791,8 +791,10 @@ public function testSubmitGetRequestWithEmptyRootFormName()
791791
$this->assertEquals(array('extra' => 'data'), $form->getExtraData());
792792
}
793793

794-
public function testGetErrorsAsStringDeep()
794+
public function testLegacyGetErrorsAsStringDeep()
795795
{
796+
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
797+
796798
$parent = $this->getBuilder()
797799
->setCompound(true)
798800
->setDataMapper($this->getDataMapper())
@@ -810,8 +812,10 @@ public function testGetErrorsAsStringDeep()
810812
);
811813
}
812814

813-
public function testGetErrorsAsStringDeepWithIndentation()
815+
public function testLegacyGetErrorsAsStringDeepWithIndentation()
814816
{
817+
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
818+
815819
$parent = $this->getBuilder()
816820
->setCompound(true)
817821
->setDataMapper($this->getDataMapper())

Tests/Extension/Core/Type/FormTypeTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,8 +637,10 @@ public function testPassZeroLabelToView()
637637
$this->assertSame('0', $view->vars['label']);
638638
}
639639

640-
public function testCanGetErrorsWhenButtonInForm()
640+
public function testLegacyCanGetErrorsWhenButtonInForm()
641641
{
642+
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
643+
642644
$builder = $this->factory->createBuilder('form', null, array(
643645
'data_class' => 'Symfony\Component\Form\Tests\Fixtures\Author',
644646
'required' => false,

Tests/Extension/Validator/Constraints/FormValidatorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ public function testNoViolationIfAllowExtraData()
575575
->add($this->getBuilder('child'))
576576
->getForm();
577577

578-
$form->bind(array('foo' => 'bar'));
578+
$form->submit(array('foo' => 'bar'));
579579

580580
$context->expects($this->never())
581581
->method('addViolation');

Tests/SimpleFormTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -733,8 +733,10 @@ public function testCreateViewWithExplicitParent()
733733
$this->assertSame($view, $form->createView($parentView));
734734
}
735735

736-
public function testGetErrorsAsString()
736+
public function testLegacyGetErrorsAsString()
737737
{
738+
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
739+
738740
$this->form->addError(new FormError('Error!'));
739741

740742
$this->assertEquals("ERROR: Error!\n", $this->form->getErrorsAsString());

0 commit comments

Comments
 (0)