aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Structure/Types/ResultType.php
blob: 623ca3ed37ee18b7187c6c228a9f871d8a0ed204 (plain)
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
<?php

declare(strict_types=1);

namespace Nsfisis\Waddiwasi\Structure\Types;

use function count;

final readonly class ResultType
{
    /**
     * @param list<ValType> $types
     */
    public function __construct(
        public array $types,
    ) {
    }

    public function equals(ResultType $other): bool
    {
        if (count($this->types) !== count($other->types)) {
            return false;
        }
        foreach ($this->types as $i => $type) {
            if (!$type->equals($other->types[$i])) {
                return false;
            }
        }
        return true;
    }
}