|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* PHP: Nelson Martell Library file |
|
5
|
|
|
* |
|
6
|
|
|
* Copyright © 2021 Nelson Martell (http://nelson6e65.github.io) |
|
7
|
|
|
* |
|
8
|
|
|
* Licensed under The MIT License (MIT) |
|
9
|
|
|
* For full copyright and license information, please see the LICENSE |
|
10
|
|
|
* Redistributions of files must retain the above copyright notice. |
|
11
|
|
|
* |
|
12
|
|
|
* @copyright 2021 Nelson Martell |
|
13
|
|
|
* @link http://nelson6e65.github.io/php_nml/ |
|
14
|
|
|
* @since v1.0.0 |
|
15
|
|
|
* @license http://www.opensource.org/licenses/mit-license.php The MIT License (MIT) |
|
16
|
|
|
* */ |
|
17
|
|
|
|
|
18
|
|
|
declare(strict_types=1); |
|
19
|
|
|
|
|
20
|
|
|
namespace NelsonMartell\Test\DataProviders\ExampleClass; |
|
21
|
|
|
|
|
22
|
|
|
use NelsonMartell\StrictObject; |
|
23
|
|
|
use NelsonMartell\PropertiesHandler; |
|
24
|
|
|
use NelsonMartell\IMagicPropertiesContainer; |
|
25
|
|
|
use NelsonMartell\IStrictPropertiesContainer; |
|
26
|
|
|
use stdClass as VeryLongClassName; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @internal |
|
30
|
|
|
* |
|
31
|
|
|
* @property string $UpperCaseProperty |
|
32
|
|
|
* @property-read string $UpperCaseWithDifferentSetterProperty |
|
33
|
|
|
* @property-write string|int $UpperCaseWithDifferentSetterProperty |
|
34
|
|
|
* @property-read VeryLongClassName|null $propertyWithLongClass Officia deserunt mollit anim id est laborum. |
|
35
|
|
|
* @property-write VeryLongClassName|int|null $propertyWithLongClass Lorem ipsum dolor sit amet. |
|
36
|
|
|
* @property-read VeryLongClassName|null $anotherPropertyAfterPropertyWithLongClass |
|
37
|
|
|
* @property-write VeryLongClassName|int|string|null $anotherPropertyAfterPropertyWithLongClass |
|
38
|
|
|
*/ |
|
39
|
|
|
class WithManyMagicPropertiesClass implements IStrictPropertiesContainer, IMagicPropertiesContainer |
|
40
|
|
|
{ |
|
41
|
|
|
use PropertiesHandler; |
|
42
|
|
|
|
|
43
|
|
|
private array $data = []; |
|
44
|
|
|
|
|
45
|
|
|
public function __construct() |
|
46
|
|
|
{ |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* |
|
52
|
|
|
* |
|
53
|
|
|
* @return string |
|
54
|
|
|
*/ |
|
55
|
|
|
protected function getUpperCaseProperty(): string |
|
56
|
|
|
{ |
|
57
|
|
|
return $this->data['UpperCaseProperty'] ?? ''; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* |
|
62
|
|
|
* @param string|int $value |
|
63
|
|
|
*/ |
|
64
|
|
|
protected function setUpperCaseProperty($value) |
|
65
|
|
|
{ |
|
66
|
|
|
$this->data['UpperCaseProperty'] = ${value}; |
|
|
|
|
|
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* |
|
71
|
|
|
* |
|
72
|
|
|
* @return string |
|
73
|
|
|
*/ |
|
74
|
|
|
protected function getUpperCaseWithDifferentSetterProperty(): string |
|
75
|
|
|
{ |
|
76
|
|
|
return $this->data['UpperCaseWithDifferentSetterProperty'] ?? ''; |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* |
|
81
|
|
|
* @param string|int $value |
|
82
|
|
|
*/ |
|
83
|
|
|
protected function setUpperCaseWithDifferentSetterProperty($value) |
|
84
|
|
|
{ |
|
85
|
|
|
$this->data['UpperCaseWithDifferentSetterProperty'] = "${value}"; |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
/** |
|
89
|
|
|
* @return VeryLongClassName|null |
|
90
|
|
|
*/ |
|
91
|
|
|
protected function getPropertyWithLongClass() |
|
92
|
|
|
{ |
|
93
|
|
|
return $this->data['propertyWithLongClass'] ?? null; |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
/** |
|
97
|
|
|
* @param VeryLongClassName|int|null $value |
|
98
|
|
|
*/ |
|
99
|
|
|
protected function setPropertyWithLongClass($value) |
|
100
|
|
|
{ |
|
101
|
|
|
if ($value !== null && !($value instanceof VeryLongClassName)) { |
|
102
|
|
|
$original = $value; |
|
103
|
|
|
$value = new VeryLongClassName(); |
|
104
|
|
|
$value->original = $original; |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
$this->data['propertyWithLongClass'] = $value; |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
|
|
111
|
|
|
/** |
|
112
|
|
|
* @return VeryLongClassName|null |
|
113
|
|
|
*/ |
|
114
|
|
|
protected function getAnotherPropertyAfterPropertyWithLongClass() |
|
115
|
|
|
{ |
|
116
|
|
|
return $this->data['anotherPropertyAfterPropertyWithLongClass'] ?? null; |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
/** |
|
120
|
|
|
* @param VeryLongClassName|int|string|null $value |
|
121
|
|
|
*/ |
|
122
|
|
|
protected function setAnotherPropertyAfterPropertyWithLongClass($value) |
|
123
|
|
|
{ |
|
124
|
|
|
if ($value !== null && !($value instanceof VeryLongClassName)) { |
|
125
|
|
|
$original = $value; |
|
126
|
|
|
$value = new VeryLongClassName(); |
|
127
|
|
|
$value->original = $original; |
|
128
|
|
|
} |
|
129
|
|
|
|
|
130
|
|
|
$this->data['anotherPropertyAfterPropertyWithLongClass'] = $value; |
|
131
|
|
|
} |
|
132
|
|
|
} |
|
133
|
|
|
|