-
-
Notifications
You must be signed in to change notification settings - Fork 440
Expand file tree
/
Copy pathAbstractFalsyScalarRuleFixerRector.php
More file actions
36 lines (29 loc) · 941 Bytes
/
AbstractFalsyScalarRuleFixerRector.php
File metadata and controls
36 lines (29 loc) · 941 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
declare(strict_types=1);
namespace Rector\Strict\Rector;
use Rector\Contract\Rector\ConfigurableRectorInterface;
use Rector\Rector\AbstractRector;
use Webmozart\Assert\Assert;
/**
* @see \Rector\Tests\Strict\Rector\BooleanNot\BooleanInBooleanNotRuleFixerRector\BooleanInBooleanNotRuleFixerRectorTest
*
* @internal
*/
abstract class AbstractFalsyScalarRuleFixerRector extends AbstractRector implements ConfigurableRectorInterface
{
/**
* @api
* @var string
*/
final public const TREAT_AS_NON_EMPTY = 'treat_as_non_empty';
protected bool $treatAsNonEmpty = false;
/**
* @param array<string, mixed> $configuration
*/
public function configure(array $configuration): void
{
$treatAsNonEmpty = $configuration[self::TREAT_AS_NON_EMPTY] ?? (bool) current($configuration);
Assert::boolean($treatAsNonEmpty);
$this->treatAsNonEmpty = $treatAsNonEmpty;
}
}