Exercise / HTMLPurifierBundle

HTML Purifier is a standards-compliant HTML filter library written in PHP.
http://htmlpurifier.org/
Other
275 stars 56 forks source link

Implement static function getExtendedTypes(): iterable in place of getExtendedType #61

Closed mpiot closed 5 years ago

mpiot commented 5 years ago

This PR fix this deprecation since Symfony 4.2

Not implementing the static getExtendedTypes() method in Exercise\HTMLPurifierBundle\Form\TypeExtension\HTMLPurifierTextTypeExtension when implementing the Symfony\Component\Form\FormTypeExtensionInterface is deprecated since Symfony 4.2. The method will be added to the interface in 5.0.

<?php
namespace Symfony\Component\Form;

use Symfony\Component\OptionsResolver\OptionsResolver;

/**
 * @author Bernhard Schussek <bschussek@gmail.com>
 *
 * @method static iterable getExtendedTypes() Gets the extended types - not implementing it is deprecated since Symfony 4.2
 */
interface FormTypeExtensionInterface
{
    //...

       /**
     * Returns the name of the type being extended.
     *
     * @return string The name of the type being extended
     *
     * @deprecated since Symfony 4.2, use getExtendedTypes() instead.
     */
    public function getExtendedType();
}
stof commented 5 years ago

public function getExtendedType() must still be implemented. Otherwise the bundle becomes incompatible with older Symfony versions.

stof commented 5 years ago

and this is also incompatible with PHP 5.5.9. Merging that would require bumping the min PHP version.

althaus commented 5 years ago

Wouldn't adding a simple:

    public static function getExtendedTypes()
    {
        return [TextType::class];
    }

fix the issue?

stof commented 5 years ago

yeah, I think that adding that method without removing the other ones might be enough. (to be ready for Symfony 5, we would need the return type, but dropping PHP 5 support before adding support for Symfony 5 is probably fine)

mpiot commented 5 years ago

I've test, the deprecation is removed when we add the new one, the old is only called if the new don't exist.

Then, I add the public static getExtendedTypes() methods, keep the previous public function getExtendedType(), and update the composer php version to ^7.1.3 (needed for the return type: http://php.net/manual/en/language.types.iterable.php ).

mikemix commented 5 years ago

Is this going to get merged?

althaus commented 5 years ago

Is bumping the PHP version necessary? Couldn't the iterable be added "later"?

mpiot commented 5 years ago

I'll look if the return type is defined in the interface, if yes, we're forced to specify it. Else we can remove the iterable.

spolischook commented 5 years ago

If this commit is really needed, so it should be merged in separate branch and major version should be updated.

althaus commented 5 years ago

@mpiot As the method is currently only annotated in the interface it should work without iterable and bumping the PHP version.

mpiot commented 5 years ago

@althaus Yes, I'm so sorry, I've see it a week ago, but not take time to fix...

I've removed it :-)

spolischook commented 5 years ago

New release was created https://github.com/Exercise/HTMLPurifierBundle/releases/tag/V2.0.4