rector/rules/Strict/Rector/AbstractFalsyScalarRuleFixerRector.php

32 lines
1015 B
PHP
Raw Normal View History

<?php
declare (strict_types=1);
2022-06-06 16:43:29 +00:00
namespace RectorPrefix20220606\Rector\Strict\Rector;
2022-06-06 16:43:29 +00:00
use RectorPrefix20220606\Rector\Core\Contract\Rector\ConfigurableRectorInterface;
use RectorPrefix20220606\Rector\Core\Rector\AbstractRector;
use RectorPrefix20220606\Webmozart\Assert\Assert;
/**
* @see \Rector\Tests\Strict\Rector\BooleanNot\BooleanInBooleanNotRuleFixerRector\BooleanInBooleanNotRuleFixerRectorTest
*/
2022-06-06 16:43:29 +00:00
abstract class AbstractFalsyScalarRuleFixerRector extends AbstractRector implements ConfigurableRectorInterface
{
/**
* @var string
*/
public const TREAT_AS_NON_EMPTY = 'treat_as_non_empty';
/**
* @var bool
*/
protected $treatAsNonEmpty = \false;
/**
* @param mixed[] $configuration
*/
public function configure(array $configuration) : void
{
$treatAsNonEmpty = $configuration[self::TREAT_AS_NON_EMPTY] ?? (bool) \current($configuration);
2022-06-06 16:43:29 +00:00
Assert::boolean($treatAsNonEmpty);
$this->treatAsNonEmpty = $treatAsNonEmpty;
}
}