1 | <?php |
||
28 | class Article extends BaseArticle implements ArticleInterface, GeoIpPlaceInterface |
||
29 | { |
||
30 | use TenantAwareTrait; |
||
31 | use OrganizationAwareTrait; |
||
32 | use PaywallSecuredTrait; |
||
33 | use ContentListsAwareTrait; |
||
34 | |||
35 | /** |
||
36 | * @var PackageInterface |
||
37 | */ |
||
38 | protected $package; |
||
39 | |||
40 | /** |
||
41 | * @var bool |
||
42 | */ |
||
43 | protected $isPublishedFBIA = false; |
||
44 | |||
45 | /** |
||
46 | * @var ArticleStatisticsInterface |
||
47 | */ |
||
48 | protected $articleStatistics; |
||
49 | |||
50 | /** |
||
51 | * @var ExternalArticleInterface |
||
52 | */ |
||
53 | protected $externalArticle; |
||
54 | |||
55 | /** |
||
56 | * @var int |
||
57 | */ |
||
58 | protected $commentsCount = 0; |
||
59 | |||
60 | /** @var Place */ |
||
61 | protected $geoIpPlace; |
||
62 | |||
63 | /** @var bool */ |
||
64 | protected $isPublishedToAppleNews = false; |
||
65 | |||
66 | /** @var AppleNewsArticleInterface|null */ |
||
67 | protected $appleNewsArticle; |
||
68 | |||
69 | /** |
||
70 | * {@inheritdoc} |
||
71 | */ |
||
72 | public function setId($id) |
||
76 | |||
77 | /** |
||
78 | * {@inheritdoc} |
||
79 | */ |
||
80 | public function getPackage(): ?PackageInterface |
||
84 | |||
85 | /** |
||
86 | * {@inheritdoc} |
||
87 | */ |
||
88 | public function setPackage(?PackageInterface $package) |
||
92 | |||
93 | /** |
||
94 | * {@inheritdoc} |
||
95 | */ |
||
96 | public function isPublishedFBIA(): bool |
||
100 | |||
101 | /** |
||
102 | * {@inheritdoc} |
||
103 | */ |
||
104 | public function setPublishedFBIA(bool $isPublished) |
||
108 | |||
109 | /** |
||
110 | * {@inheritdoc} |
||
111 | */ |
||
112 | public function getArticleStatistics(): ?ArticleStatisticsInterface |
||
116 | |||
117 | /** |
||
118 | * {@inheritdoc} |
||
119 | */ |
||
120 | public function setArticleStatistics(ArticleStatisticsInterface $articleStatistics): void |
||
125 | |||
126 | /** |
||
127 | * {@inheritdoc} |
||
128 | */ |
||
129 | public function getExternalArticle(): ?ExternalArticleInterface |
||
133 | |||
134 | /** |
||
135 | * {@inheritdoc} |
||
136 | */ |
||
137 | public function setExternalArticle(ExternalArticleInterface $externalArticle): void |
||
141 | |||
142 | public function getPackageExternalData() |
||
155 | |||
156 | public function getCommentsCount(): int |
||
164 | |||
165 | public function setCommentsCount(int $commentsCount): void |
||
169 | |||
170 | public function getGeoIpPlaces(): array |
||
181 | |||
182 | public function isPublishedToAppleNews(): bool |
||
186 | |||
187 | public function setPublishedToAppleNews(bool $isPublished): void |
||
191 | |||
192 | public function getAppleNewsArticle(): ?AppleNewsArticleInterface |
||
196 | |||
197 | public function setAppleNewsArticle(?AppleNewsArticleInterface $appleNewsArticle): void |
||
201 | |||
202 | public function setPackageUpdatedAt(LifecycleEventArgs $event): void |
||
214 | } |
||
215 |
This error can happen if you refactor code and forget to move the variable initialization.
Let’s take a look at a simple example:
The above code is perfectly fine. Now imagine that we re-order the statements:
In that case,
$x
would be read before it is initialized. This was a very basic example, however the principle is the same for the found issue.