2021-10-05 15:59:39 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare (strict_types=1);
|
2022-06-06 16:43:29 +00:00
|
|
|
namespace RectorPrefix20220606\Rector\Strict\Rector;
|
2021-10-05 15:59:39 +00:00
|
|
|
|
2022-06-06 16:43:29 +00:00
|
|
|
use RectorPrefix20220606\Rector\Core\Contract\Rector\ConfigurableRectorInterface;
|
|
|
|
use RectorPrefix20220606\Rector\Core\Rector\AbstractRector;
|
2022-06-06 06:00:07 +00:00
|
|
|
use RectorPrefix20220606\Webmozart\Assert\Assert;
|
2021-10-05 15:59:39 +00:00
|
|
|
/**
|
|
|
|
* @see \Rector\Tests\Strict\Rector\BooleanNot\BooleanInBooleanNotRuleFixerRector\BooleanInBooleanNotRuleFixerRectorTest
|
|
|
|
*/
|
2022-06-06 16:43:29 +00:00
|
|
|
abstract class AbstractFalsyScalarRuleFixerRector extends AbstractRector implements ConfigurableRectorInterface
|
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-06 16:43:29 +00:00
|
|
|
Assert::boolean($treatAsNonEmpty);
|
2021-10-05 15:59:39 +00:00
|
|
|
$this->treatAsNonEmpty = $treatAsNonEmpty;
|
|
|
|
}
|
|
|
|
}
|