Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Issue Make Laminas Filters callable, and compatible with laminas-filters >=3.5.0 #38610

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/code/Magento/Catalog/Model/Product/Filter/DateTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@

namespace Magento\Catalog\Model\Product\Filter;

use Laminas\Filter\AbstractFilter;
use Laminas\Filter\FilterInterface;
use Magento\Framework\Stdlib\DateTime as StdlibDateTime;
use Magento\Framework\Stdlib\DateTime\Filter\DateTime as StdlibDateTimeFilter;

/**
* Product datetime fields values filter
*/
class DateTime implements FilterInterface
class DateTime extends AbstractFilter implements FilterInterface
{
/**
* @var StdlibDateTimeFilter
Expand Down
3 changes: 2 additions & 1 deletion app/code/Magento/Directory/Model/Currency/Filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
*/
namespace Magento\Directory\Model\Currency;

use Laminas\Filter\AbstractFilter;
use Laminas\Filter\FilterInterface;
use Magento\Framework\Pricing\PriceCurrencyInterface;

class Filter implements FilterInterface
class Filter extends AbstractFilter implements FilterInterface
{
/**
* Rate value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
*/
namespace Magento\GoogleAdwords\Model\Filter;

use Laminas\Filter\AbstractFilter;
use Laminas\Filter\FilterInterface;

/**
* @api
* @since 100.0.2
*/
class UppercaseTitle implements FilterInterface
class UppercaseTitle extends AbstractFilter implements FilterInterface
{
/**
* Convert title to uppercase
Expand Down
3 changes: 2 additions & 1 deletion lib/internal/Magento/Framework/Filter/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
*/
namespace Magento\Framework\Filter;

use Laminas\Filter\AbstractFilter;
use Laminas\Filter\FilterInterface;

class Email implements FilterInterface
class Email extends AbstractFilter implements FilterInterface
{
/**
* Returns the result of filtering $value.
Expand Down
3 changes: 2 additions & 1 deletion lib/internal/Magento/Framework/Filter/Input.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
namespace Magento\Framework\Filter;

use Exception;
use Laminas\Filter\AbstractFilter;
use Laminas\Filter\FilterInterface;
use Magento\Framework\App\Helper\AbstractHelper;
use Magento\Framework\ObjectManagerInterface;

/**
* Filter data collector
*/
class Input implements FilterInterface
class Input extends AbstractFilter implements FilterInterface
{
private const CHAIN_APPEND = 'append';
private const CHAIN_PREPEND = 'prepend';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@

namespace Magento\Framework\Filter\Input;

use Laminas\Filter\AbstractFilter;
use Laminas\Filter\FilterInterface;
use Magento\Framework\App\ObjectManager;

class MaliciousCode implements FilterInterface
class MaliciousCode extends AbstractFilter implements FilterInterface
{
/**
* @var PurifierInterface|null $purifier
Expand Down
15 changes: 3 additions & 12 deletions lib/internal/Magento/Framework/Filter/LocalizedToNormalized.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@

use Exception;
use IntlDateFormatter;
use Laminas\Filter\AbstractFilter;
use Laminas\Filter\FilterInterface;
use Laminas\I18n\Filter\NumberParse;
use NumberFormatter;

class LocalizedToNormalized implements FilterInterface
class LocalizedToNormalized extends AbstractFilter implements FilterInterface
{
/**
* @var array
Expand All @@ -22,16 +23,6 @@ class LocalizedToNormalized implements FilterInterface
'precision' => null
];

/**
* @param array|null $options
*/
public function __construct($options = null)
{
if (null !== $options) {
$this->setOptions($options);
}
}

/**
* Returns the set options
*
Expand All @@ -48,7 +39,7 @@ public function getOptions()
* @param array|null $options
* @return LocalizedToNormalized
*/
public function setOptions(array $options = null)
public function setOptions($options)
{
$this->_options = $options + $this->_options;

Expand Down
3 changes: 2 additions & 1 deletion lib/internal/Magento/Framework/Filter/Money.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
*/
namespace Magento\Framework\Filter;

use Laminas\Filter\AbstractFilter;
use Laminas\Filter\FilterInterface;

/**
* @deprecated As money_format() was removed in PHP 8.0
* @see https://www.php.net/manual/en/function.money-format.php
*/
class Money implements FilterInterface
class Money extends AbstractFilter implements FilterInterface
{
/**
* @var string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@

use Exception;
use IntlDateFormatter;
use Laminas\Filter\AbstractFilter;
use Laminas\Filter\FilterInterface;
use Laminas\I18n\Filter\NumberParse;
use NumberFormatter;

class NormalizedToLocalized implements FilterInterface
class NormalizedToLocalized extends AbstractFilter implements FilterInterface
{
/**
* @var array
Expand Down Expand Up @@ -50,7 +51,7 @@ public function getOptions()
* @param array|null $options
* @return self
*/
public function setOptions(array $options = null)
public function setOptions($options)
{
$this->_options = array_merge($this->_options, $options);
return $this;
Expand Down
3 changes: 2 additions & 1 deletion lib/internal/Magento/Framework/Filter/RemoveAccents.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
*/
namespace Magento\Framework\Filter;

use Laminas\Filter\AbstractFilter;
use Laminas\Filter\FilterInterface;

/**
* Remove accents from string
*/
class RemoveAccents implements FilterInterface
class RemoveAccents extends AbstractFilter implements FilterInterface
{
/**
* @var bool
Expand Down
3 changes: 2 additions & 1 deletion lib/internal/Magento/Framework/Filter/RemoveTags.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
*/
namespace Magento\Framework\Filter;

use Laminas\Filter\AbstractFilter;
use Laminas\Filter\FilterInterface;

/**
* Remove tags from string
*/
class RemoveTags implements FilterInterface
class RemoveTags extends AbstractFilter implements FilterInterface
{
/**
* Convert html entities
Expand Down
3 changes: 2 additions & 1 deletion lib/internal/Magento/Framework/Filter/SplitWords.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
*/
namespace Magento\Framework\Filter;

use Laminas\Filter\AbstractFilter;
use Laminas\Filter\FilterInterface;

class SplitWords implements FilterInterface
class SplitWords extends AbstractFilter implements FilterInterface
{
/**
* @var bool
Expand Down
3 changes: 2 additions & 1 deletion lib/internal/Magento/Framework/Filter/Sprintf.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
*/
namespace Magento\Framework\Filter;

use Laminas\Filter\AbstractFilter;
use Laminas\Filter\FilterInterface;

class Sprintf implements FilterInterface
class Sprintf extends AbstractFilter implements FilterInterface
{
/**
* @var string
Expand Down
3 changes: 2 additions & 1 deletion lib/internal/Magento/Framework/Filter/StripTags.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
namespace Magento\Framework\Filter;

use Laminas\Filter\FilterInterface;
use Magento\Catalog\Model\Layer\Filter\AbstractFilter;

/**
* Filter for standard strip_tags() function with extra functionality for html entities
*/
class StripTags implements FilterInterface
class StripTags extends AbstractFilter implements FilterInterface
{
/**
* @var \Magento\Framework\Escaper
Expand Down
3 changes: 2 additions & 1 deletion lib/internal/Magento/Framework/Filter/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
namespace Magento\Framework\Filter;

use InvalidArgumentException;
use Laminas\Filter\AbstractFilter;
use Laminas\Filter\FilterInterface;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\Filter\DirectiveProcessor\DependDirective;
Expand All @@ -26,7 +27,7 @@
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @since 100.0.2
*/
class Template implements FilterInterface
class Template extends AbstractFilter implements FilterInterface
{
/**
* Construction regular expression
Expand Down
13 changes: 13 additions & 0 deletions lib/internal/Magento/Framework/Filter/Template/Simple.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,17 @@ public function filter($value)
$expression = '#' . preg_quote($this->_startTag, '#') . '(.*?)' . preg_quote($this->_endTag, '#') . '#';
return preg_replace_callback($expression, $callback, $value);
}

/**
* Invoke filter as a command
*
* Proxies to {@link filter()}
*
* @throws \Laminas\Filter\Exception\ExceptionInterface If filtering $value is impossible.
* @return mixed
*/
public function __invoke(mixed $value)
{
return $this->filter($value);
}
}
3 changes: 2 additions & 1 deletion lib/internal/Magento/Framework/Filter/Translit.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
*/
namespace Magento\Framework\Filter;

use Laminas\Filter\AbstractFilter;
use Laminas\Filter\FilterInterface;

/**
* Translit filter
*
* Process string based on convertation table
*/
class Translit implements FilterInterface
class Translit extends AbstractFilter implements FilterInterface
{
/**
* Symbol convert table
Expand Down
3 changes: 2 additions & 1 deletion lib/internal/Magento/Framework/Filter/Truncate.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/
namespace Magento\Framework\Filter;

use Laminas\Filter\AbstractFilter;
use Laminas\Filter\FilterInterface;
use Magento\Framework\Stdlib\StringUtils;

Expand All @@ -17,7 +18,7 @@
* @deprecated 101.0.7
* @see \Magento\Framework\Filter\TruncateFilter
*/
class Truncate implements FilterInterface
class Truncate extends AbstractFilter implements FilterInterface
{
/**
* @var int
Expand Down
3 changes: 2 additions & 1 deletion lib/internal/Magento/Framework/Filter/TruncateFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace Magento\Framework\Filter;

use Laminas\Filter\AbstractFilter;
use Laminas\Filter\FilterInterface;
use Magento\Framework\Filter\TruncateFilter\Result;
use Magento\Framework\Filter\TruncateFilter\ResultFactory;
Expand All @@ -17,7 +18,7 @@
* Truncate a string to a certain length if necessary, appending the $etc string.
* $remainder will contain the string that has been replaced with $etc.
*/
class TruncateFilter implements FilterInterface
class TruncateFilter extends AbstractFilter implements FilterInterface
{
/**
* @var int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
namespace Magento\Framework\Stdlib\DateTime\Filter;

use Exception;
use Laminas\Filter\AbstractFilter;
use Laminas\Filter\FilterInterface;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Filter\LocalizedToNormalized;
Expand All @@ -18,7 +19,7 @@
* @api
* @since 100.0.2
*/
class Date implements FilterInterface
class Date extends AbstractFilter implements FilterInterface
{
/**
* Filter that converts localized input into normalized format
Expand Down