2021-10-05 15:59:39 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare (strict_types=1);
|
2022-06-06 17:12:56 +00:00
|
|
|
namespace Rector\Strict\Rector;
|
2021-10-05 15:59:39 +00:00
|
|
|
|
2024-01-02 02:40:38 +00:00
|
|
|
use Rector\Contract\Rector\ConfigurableRectorInterface;
|
|
|
|
use Rector\Rector\AbstractScopeAwareRector;
|
2024-03-01 20:02:28 +00:00
|
|
|
use RectorPrefix202403\Webmozart\Assert\Assert;
|
2021-10-05 15:59:39 +00:00
|
|
|
/**
|
|
|
|
* @see \Rector\Tests\Strict\Rector\BooleanNot\BooleanInBooleanNotRuleFixerRector\BooleanInBooleanNotRuleFixerRectorTest
|
2023-05-11 08:30:47 +00:00
|
|
|
*
|
2023-05-11 11:52:57 +00:00
|
|
|
* @internal
|
2021-10-05 15:59:39 +00:00
|
|
|
*/
|
2023-07-19 11:08:33 +00:00
|
|
|
abstract class AbstractFalsyScalarRuleFixerRector extends AbstractScopeAwareRector implements ConfigurableRectorInterface
|
2021-10-05 15:59:39 +00:00
|
|
|
{
|
|
|
|
/**
|
2022-06-30 13:57:27 +00:00
|
|
|
* @api
|
2021-10-05 15:59:39 +00:00
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
public const TREAT_AS_NON_EMPTY = 'treat_as_non_empty';
|
|
|
|
/**
|
|
|
|
* @var bool
|
|
|
|
*/
|
|
|
|
protected $treatAsNonEmpty = \false;
|
|
|
|
/**
|
2021-11-28 17:01:20 +00:00
|
|
|
* @param mixed[] $configuration
|
2021-10-05 15:59:39 +00:00
|
|
|
*/
|
2021-12-10 10:22:23 +00:00
|
|
|
public function configure(array $configuration) : void
|
2021-10-05 15:59:39 +00:00
|
|
|
{
|
2022-02-02 21:17:05 +00:00
|
|
|
$treatAsNonEmpty = $configuration[self::TREAT_AS_NON_EMPTY] ?? (bool) \current($configuration);
|
2022-06-07 08:22:29 +00:00
|
|
|
Assert::boolean($treatAsNonEmpty);
|
2021-10-05 15:59:39 +00:00
|
|
|
$this->treatAsNonEmpty = $treatAsNonEmpty;
|
|
|
|
}
|
|
|
|
}
|