getAttribute(AttributeKey::SCOPE); if (!$currentScope instanceof Scope) { $errorMessage = \sprintf('Scope not available on "%s" node, but is required by a refactorWithScope() method of "%s" rule. Fix scope refresh on changed nodes first', \get_class($node), static::class); throw new ShouldNotHappenException($errorMessage); } return $this->refactorWithScope($node, $currentScope); } }