-
Notifications
You must be signed in to change notification settings - Fork 426
/
bug-3892.php
72 lines (55 loc) · 1.19 KB
/
bug-3892.php
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
namespace Bug3892;
class OrderEntity
{
public function isLoaded(): bool
{
return rand(0,1) === 0;
}
}
abstract class OrderSaved
{
public const TYP = [PickingOrder::class => '200', ReceiptOrder::class => '300'];
/** @var Order[] */
private array $dtos;
public function __construct(OrderEntity $order)
{
$this->dtos = \array_filter([ReceiptOrder::fromOrder($order), PickingOrder::fromOrder($order)]);
}
/**
* @return Order[]
*/
public function getDTOs(): array
{
return $this->dtos;
}
}
abstract class Order
{
public const TYP = [PickingOrder::class => '200', ReceiptOrder::class => '300'];
}
class PickingOrder extends Order
{
public static function fromOrder(OrderEntity $order): ?self
{
return $order->isLoaded() ? new self() : null;
}
}
class ReceiptOrder extends Order
{
public static function fromOrder(OrderEntity $order): ?self
{
return $order->isLoaded() ? new self() : null;
}
}
class Foo
{
public function doFoo(OrderSaved $event)
{
$DTOs = $event->getDTOs();
$DTOClasses = \array_map('\get_class', $DTOs);
$missingClasses = \array_diff(\array_keys(Order::TYP), $DTOClasses);
if (\in_array(ReceiptOrder::class, $missingClasses, true)) {
}
}
}