1: <?php declare(strict_types=1);
2:
3: namespace Salient\Core;
4:
5: use Salient\Contract\Core\Entity\Readable;
6: use Salient\Contract\Core\Provider\ProviderContextInterface;
7: use Salient\Contract\Core\Provider\ProviderInterface;
8: use Salient\Core\Concern\ReadsProtectedProperties;
9: use Closure;
10:
11: /**
12: * How to create or update an instance from an array
13: *
14: * @property-read array<string,int> $Parameters Key => constructor parameter index
15: * @property-read array<string,true> $PassByRefParameters Key => `true`
16: * @property-read array<string,true> $NotNullableParameters Key => `true`
17: * @property-read array<Closure(mixed[], ?string, TClass, ?TProvider, ?TContext): void> $Callbacks Arbitrary callbacks
18: * @property-read array<string,string> $Methods Key => "magic" property method
19: * @property-read array<string,string> $Properties Key => declared property name
20: * @property-read string[] $MetaProperties Arbitrary keys
21: * @property-read string[] $DateProperties Date keys
22: * @property-read array<TIntrospector::*_KEY,string> $CustomKeys Identifier => key
23: * @property-read int $LastParameterIndex Index of the last constructor parameter to which array values are mapped
24: *
25: * @see Introspector
26: *
27: * @template TIntrospector of Introspector
28: * @template TClass of object
29: * @template TProvider of ProviderInterface
30: * @template TContext of ProviderContextInterface
31: */
32: final class IntrospectorKeyTargets implements Readable
33: {
34: use ReadsProtectedProperties;
35:
36: /**
37: * Key => constructor parameter index
38: *
39: * @var array<string,int>
40: */
41: protected $Parameters;
42:
43: /**
44: * Key => `true`
45: *
46: * @var array<string,true>
47: */
48: protected $PassByRefParameters;
49:
50: /**
51: * Key => `true`
52: *
53: * @var array<string,true>
54: */
55: protected $NotNullableParameters;
56:
57: /**
58: * Arbitrary callbacks
59: *
60: * @var array<Closure(mixed[], ?string, TClass, ?TProvider, ?TContext): void>
61: */
62: protected $Callbacks;
63:
64: /**
65: * Key => "magic" property method
66: *
67: * @var array<string,string>
68: */
69: protected $Methods;
70:
71: /**
72: * Key => declared property name
73: *
74: * @var array<string,string>
75: */
76: protected $Properties;
77:
78: /**
79: * Arbitrary keys
80: *
81: * @var string[]
82: */
83: protected $MetaProperties;
84:
85: /**
86: * Date keys
87: *
88: * @var string[]
89: */
90: protected $DateProperties;
91:
92: /**
93: * Identifier => key
94: *
95: * @var array<TIntrospector::*_KEY,string>
96: */
97: protected $CustomKeys;
98:
99: /**
100: * Index of the last constructor parameter to which array values are mapped
101: *
102: * @var int
103: */
104: protected $LastParameterIndex = -1;
105:
106: /**
107: * @param array<string,int> $parameters
108: * @param array<string,true> $passByRefParameters
109: * @param array<string,true> $notNullableParameters
110: * @param array<Closure(mixed[], ?string, TClass, ?TProvider, ?TContext): void> $callbacks
111: * @param array<string,string> $methods
112: * @param array<string,string> $properties
113: * @param string[] $metaProperties
114: * @param string[] $dateProperties
115: * @param array<TIntrospector::*_KEY,string> $customKeys
116: */
117: public function __construct(
118: array $parameters,
119: array $passByRefParameters,
120: array $notNullableParameters,
121: array $callbacks,
122: array $methods,
123: array $properties,
124: array $metaProperties,
125: array $dateProperties,
126: array $customKeys
127: ) {
128: $this->Parameters = $parameters;
129: $this->PassByRefParameters = $passByRefParameters;
130: $this->NotNullableParameters = $notNullableParameters;
131: $this->Callbacks = $callbacks;
132: $this->Methods = $methods;
133: $this->Properties = $properties;
134: $this->MetaProperties = $metaProperties;
135: $this->DateProperties = $dateProperties;
136: $this->CustomKeys = $customKeys;
137:
138: if ($this->Parameters) {
139: $this->LastParameterIndex = max(array_values($parameters));
140: }
141: }
142: }
143: