Skip to content

Commit

Permalink
Improve triggering of the deprecation error
Browse files Browse the repository at this point in the history
  • Loading branch information
wouterj committed Mar 24, 2015
1 parent 39b0e96 commit a8b3b9b
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions ResolvedFormType.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,19 +206,25 @@ public function getOptionsResolver()
$this->innerType->setDefaultOptions($this->optionsResolver);

$reflector = new \ReflectionMethod($this->innerType, 'setDefaultOptions');
$isOverwritten = ($reflector->getDeclaringClass()->getName() !== 'Symfony\Component\Form\AbstractType');
$isOldOverwritten = $reflector->getDeclaringClass()->getName() !== 'Symfony\Component\Form\AbstractType';

if (true === $isOverwritten) {
$reflector = new \ReflectionMethod($this->innerType, 'configureOptions');
$isNewOverwritten = $reflector->getDeclaringClass()->getName() !== 'Symfony\Component\Form\AbstractType';

if ($isOldOverwritten && !$isNewOverwritten) {
trigger_error('The FormTypeInterface::setDefaultOptions() method is deprecated since version 2.7 and will be removed in 3.0. Use configureOptions() instead. This method will be added to the FormTypeInterface with Symfony 3.0.', E_USER_DEPRECATED);
}

foreach ($this->typeExtensions as $extension) {
$extension->setDefaultOptions($this->optionsResolver);

$reflector = new \ReflectionMethod($extension, 'setDefaultOptions');
$isOverwritten = ($reflector->getDeclaringClass()->getName() !== 'Symfony\Component\Form\AbstractTypeExtension');
$isOldOverwritten = $reflector->getDeclaringClass()->getName() !== 'Symfony\Component\Form\AbstractTypeExtension';

$reflector = new \ReflectionMethod($extension, 'configureOptions');
$isNewOverwritten = $reflector->getDeclaringClass()->getName() !== 'Symfony\Component\Form\AbstractTypeExtension';

if (true === $isOverwritten) {
if ($isOldOverwritten && !$isNewOverwritten) {
trigger_error('The FormTypeExtensionInterface::setDefaultOptions() method is deprecated since version 2.7 and will be removed in 3.0. Use configureOptions() instead. This method will be added to the FormTypeExtensionInterface with Symfony 3.0.', E_USER_DEPRECATED);
}
}
Expand Down

0 comments on commit a8b3b9b

Please sign in to comment.