2019-10-13 05:59:52 +00:00
|
|
|
<?php
|
|
|
|
|
2021-05-09 20:15:43 +00:00
|
|
|
declare (strict_types=1);
|
2022-06-06 17:12:56 +00:00
|
|
|
namespace Rector\NodeNestingScope;
|
2019-04-06 00:16:58 +00:00
|
|
|
|
2022-06-06 17:12:56 +00:00
|
|
|
use PhpParser\Node;
|
2023-06-18 06:01:13 +00:00
|
|
|
use Rector\NodeTypeResolver\Node\AttributeKey;
|
2019-04-06 00:16:58 +00:00
|
|
|
final class ContextAnalyzer
|
|
|
|
{
|
|
|
|
/**
|
2023-06-22 11:51:54 +00:00
|
|
|
* @api
|
2023-06-08 22:00:17 +00:00
|
|
|
*/
|
2022-06-07 08:22:29 +00:00
|
|
|
public function isInLoop(Node $node) : bool
|
2019-04-06 00:16:58 +00:00
|
|
|
{
|
2023-06-18 06:01:13 +00:00
|
|
|
return $node->getAttribute(AttributeKey::IS_IN_LOOP) === \true;
|
2019-04-06 00:16:58 +00:00
|
|
|
}
|
2022-07-17 01:16:52 +00:00
|
|
|
/**
|
|
|
|
* @api
|
|
|
|
*/
|
2022-06-07 08:22:29 +00:00
|
|
|
public function isInIf(Node $node) : bool
|
2019-04-06 00:16:58 +00:00
|
|
|
{
|
2023-06-22 11:51:54 +00:00
|
|
|
return $node->getAttribute(AttributeKey::IS_IN_IF) === \true;
|
2019-04-06 00:16:58 +00:00
|
|
|
}
|
|
|
|
}
|