2021-08-09 13:33:35 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare (strict_types=1);
|
2024-01-02 02:40:38 +00:00
|
|
|
namespace Rector\NodeAnalyzer;
|
2021-08-09 13:33:35 +00:00
|
|
|
|
2022-06-06 17:12:56 +00:00
|
|
|
use PhpParser\Node\Expr\Variable;
|
|
|
|
use Rector\NodeTypeResolver\Node\AttributeKey;
|
2021-08-09 13:33:35 +00:00
|
|
|
final class VariableAnalyzer
|
|
|
|
{
|
2022-06-07 08:22:29 +00:00
|
|
|
public function isStaticOrGlobal(Variable $variable) : bool
|
2021-08-09 13:33:35 +00:00
|
|
|
{
|
2023-05-13 10:12:10 +00:00
|
|
|
if ($variable->getAttribute(AttributeKey::IS_GLOBAL_VAR) === \true) {
|
|
|
|
return \true;
|
|
|
|
}
|
2023-05-13 10:37:59 +00:00
|
|
|
return $variable->getAttribute(AttributeKey::IS_STATIC_VAR) === \true;
|
2021-08-09 13:33:35 +00:00
|
|
|
}
|
2022-06-07 08:22:29 +00:00
|
|
|
public function isUsedByReference(Variable $variable) : bool
|
2022-02-25 08:28:29 +00:00
|
|
|
{
|
2023-05-13 17:37:31 +00:00
|
|
|
return $variable->getAttribute(AttributeKey::IS_BYREF_VAR) === \true;
|
2022-07-02 22:36:41 +00:00
|
|
|
}
|
2021-08-09 13:33:35 +00:00
|
|
|
}
|