1 | <?php |
||
18 | class ExternalArticle implements Arrayable |
||
19 | { |
||
20 | /** |
||
21 | * @var string |
||
22 | */ |
||
23 | private $title; |
||
24 | |||
25 | /** |
||
26 | * @var string |
||
27 | */ |
||
28 | private $body; |
||
29 | |||
30 | /** |
||
31 | * @var string |
||
32 | */ |
||
33 | private $preview = ''; |
||
34 | |||
35 | /** |
||
36 | * @var string |
||
37 | */ |
||
38 | private $url; |
||
39 | |||
40 | /** |
||
41 | * @var \DateTime |
||
42 | */ |
||
43 | private $createdAt; |
||
44 | |||
45 | /** |
||
46 | * @var array|string[] |
||
47 | */ |
||
48 | private $images = []; |
||
49 | |||
50 | /** |
||
51 | * ExternalArticle constructor. |
||
52 | * @param string $title |
||
53 | * @param string $body |
||
54 | * @param string $url |
||
55 | */ |
||
56 | public function __construct(string $title, string $body, string $url) |
||
64 | |||
65 | /** |
||
66 | * @return string |
||
67 | */ |
||
68 | public function getPreview(): string |
||
72 | |||
73 | /** |
||
74 | * @param string $preview |
||
75 | * @return $this|ExternalArticle |
||
76 | */ |
||
77 | public function setPreview(string $preview): ExternalArticle |
||
83 | |||
84 | /** |
||
85 | * @param string $image |
||
86 | * @return $this |
||
87 | */ |
||
88 | public function addImageUrl(string $image) |
||
94 | |||
95 | /** |
||
96 | * @return array |
||
97 | */ |
||
98 | public function getImages(): array |
||
102 | |||
103 | /** |
||
104 | * @return string |
||
105 | */ |
||
106 | public function getTitle(): string |
||
110 | |||
111 | /** |
||
112 | * @return string |
||
113 | */ |
||
114 | public function getBody(): string |
||
118 | |||
119 | /** |
||
120 | * @return string |
||
121 | */ |
||
122 | public function getUrl(): string |
||
126 | |||
127 | /** |
||
128 | * @return \DateTime |
||
129 | */ |
||
130 | public function getCreatedAt(): \DateTime |
||
134 | |||
135 | /** |
||
136 | * @param \DateTime $createdAt |
||
137 | * @return $this|ExternalArticle |
||
138 | */ |
||
139 | public function setCreatedAt(\DateTime $createdAt) |
||
145 | |||
146 | /** |
||
147 | * @return array |
||
148 | */ |
||
149 | public function toArray(): array |
||
159 | |||
160 | /** |
||
161 | * @param Article $article |
||
162 | * @return Article |
||
163 | */ |
||
164 | public function fill(Article $article): Article |
||
182 | } |
||
183 |
Since your code implements the magic setter
_set
, this function will be called for any write access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.Since the property has write access only, you can use the @property-write annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.