Make Node abstract

This commit is contained in:
Fabien Potencier
2024-09-27 08:03:01 +02:00
parent 3b15ba5a4c
commit f4a596e5b0
+1 -5
View File
@@ -24,7 +24,7 @@ use Twig\Source;
* @implements \IteratorAggregate<int|string, Node>
*/
#[YieldReady]
class Node implements \Countable, \IteratorAggregate
abstract class Node implements \Countable, \IteratorAggregate
{
/**
* @var array<string|int, Node>
@@ -48,10 +48,6 @@ class Node implements \Countable, \IteratorAggregate
*/
public function __construct(array $nodes = [], array $attributes = [], int $lineno = 0)
{
if (self::class === static::class) {
trigger_deprecation('twig/twig', '3.15', \sprintf('Instantiating "%s" directly is deprecated; the class will become abstract in 4.0.', self::class));
}
foreach ($nodes as $name => $node) {
if (!$node instanceof self) {
throw new \InvalidArgumentException(\sprintf('Using "%s" for the value of node "%s" of "%s" is not supported. You must pass a \Twig\Node\Node instance.', \is_object($node) ? $node::class : (null === $node ? 'null' : \gettype($node)), $name, static::class));