This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | /* * |
||
4 | *@author nicolaas[at] sunnysideup.co.nz |
||
5 | * |
||
6 | **/ |
||
7 | |||
8 | class Advertisement extends DataObject |
||
0 ignored issues
–
show
|
|||
9 | { |
||
10 | /** |
||
11 | * |
||
12 | * @var int |
||
13 | */ |
||
14 | private static $thumbnail_size = 140; |
||
0 ignored issues
–
show
|
|||
15 | |||
16 | /** |
||
17 | * |
||
18 | * @var int |
||
19 | */ |
||
20 | private static $width = 0; |
||
0 ignored issues
–
show
|
|||
21 | |||
22 | /** |
||
23 | * |
||
24 | * @var int |
||
25 | */ |
||
26 | private static $height = 0; |
||
0 ignored issues
–
show
|
|||
27 | |||
28 | /** |
||
29 | * |
||
30 | * @var bool |
||
31 | */ |
||
32 | private static $show_title = false; |
||
0 ignored issues
–
show
|
|||
33 | |||
34 | /** |
||
35 | * |
||
36 | * @var bool |
||
37 | */ |
||
38 | private static $show_description = false; |
||
0 ignored issues
–
show
|
|||
39 | |||
40 | /** |
||
41 | * must be a string as booleans dont work well on configs |
||
42 | * @varchar yes / no |
||
43 | */ |
||
44 | private static $resize_images = "yes"; |
||
0 ignored issues
–
show
|
|||
45 | |||
46 | /** |
||
47 | * |
||
48 | * @return string |
||
49 | */ |
||
50 | public static function recommended_image_size_statement() |
||
51 | { |
||
52 | $array = array(); |
||
53 | if (Config::inst()->get("Advertisement", "width")) { |
||
54 | $array[] = "width = ".Config::inst()->get("Advertisement", "width")."px"; |
||
55 | } |
||
56 | if (Config::inst()->get("Advertisement", "height")) { |
||
57 | $array[] = "height = ".Config::inst()->get("Advertisement", "height")."px"; |
||
58 | } |
||
59 | $count = count($array); |
||
60 | if ($count == 0) { |
||
61 | return _t("Advertisement.NO_RECOMMENDED_SIZE_HAS_BEEN_SET", "No recommeded image size has been set."); |
||
62 | } else { |
||
63 | return _t("Advertisement.RECOMMENDED_SIZE", "Recommended Size").": ".implode(" "._t("Advertisement.AND", "and")." ", $array)."."; |
||
64 | } |
||
65 | } |
||
66 | |||
67 | |||
68 | private static $db = array( |
||
0 ignored issues
–
show
|
|||
69 | "Title" => "Varchar(255)", |
||
70 | "ExternalLink" => "Varchar(150)", |
||
71 | "Description" => "Text", |
||
72 | "Sort" => "Int" |
||
73 | ); |
||
74 | |||
75 | private static $has_one = array( |
||
0 ignored issues
–
show
|
|||
76 | "AdvertisementImage" => "Image", |
||
77 | "LinkedPage" => "SiteTree", |
||
78 | "AdditionalImage" => "Image" |
||
79 | ); |
||
80 | |||
81 | private static $belongs_many_many = array( |
||
0 ignored issues
–
show
|
|||
82 | "Parents" => "SiteTree", |
||
83 | ); |
||
84 | |||
85 | private static $casting = array( |
||
0 ignored issues
–
show
|
|||
86 | "FullTitle" => "HTMLText", |
||
87 | "Link" => "Varchar", |
||
88 | "GroupID" => "Int" |
||
89 | ); |
||
90 | |||
91 | private static $defaults = array( |
||
0 ignored issues
–
show
|
|||
92 | "Sort" => 1000 |
||
93 | ); |
||
94 | |||
95 | private static $default_sort = "\"Sort\" ASC, \"Title\" ASC"; |
||
0 ignored issues
–
show
|
|||
96 | |||
97 | private static $searchable_fields = array( |
||
0 ignored issues
–
show
|
|||
98 | "Title" => "PartialMatchFilter" |
||
99 | ); |
||
100 | |||
101 | private static $singular_name = "Advertisement"; |
||
0 ignored issues
–
show
|
|||
102 | |||
103 | private static $plural_name = "Advertisements"; |
||
0 ignored issues
–
show
|
|||
104 | |||
105 | private static $summary_fields = array( |
||
0 ignored issues
–
show
|
|||
106 | "FullTitle" => "Image", |
||
107 | "Link" => "Link" |
||
108 | ); |
||
109 | |||
110 | |||
111 | /** |
||
112 | * @alias getLink |
||
113 | * @return string |
||
114 | */ |
||
115 | public function Link() |
||
116 | { |
||
117 | return $this->getLink(); |
||
118 | } |
||
119 | |||
120 | |||
121 | /** |
||
122 | * |
||
123 | * @return string |
||
124 | */ |
||
125 | public function getLink() |
||
126 | { |
||
127 | $link = ''; |
||
128 | if ($this->ExternalLink) { |
||
0 ignored issues
–
show
The property
ExternalLink does not exist on object<Advertisement> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read 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. ![]() |
|||
129 | $link = $this->ExternalLink; |
||
0 ignored issues
–
show
The property
ExternalLink does not exist on object<Advertisement> . Since you implemented __set , maybe consider adding a @property annotation.
Since your code implements the magic setter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
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. ![]() |
|||
130 | } elseif ($this->LinkedPageID) { |
||
0 ignored issues
–
show
The property
LinkedPageID does not exist on object<Advertisement> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read 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. ![]() |
|||
131 | if ($this->LinkedPage()) { |
||
0 ignored issues
–
show
The method
LinkedPage does not exist on object<Advertisement> ? Since you implemented __call , maybe consider adding a @method annotation.
If you implement This is often the case, when class ParentClass {
private $data = array();
public function __call($method, array $args) {
if (0 === strpos($method, 'get')) {
return $this->data[strtolower(substr($method, 3))];
}
throw new \LogicException(sprintf('Unsupported method: %s', $method));
}
}
/**
* If this class knows which fields exist, you can specify the methods here:
*
* @method string getName()
*/
class SomeClass extends ParentClass { }
![]() |
|||
132 | $link = $this->LinkedPage()->Link(); |
||
0 ignored issues
–
show
The method
LinkedPage does not exist on object<Advertisement> ? Since you implemented __call , maybe consider adding a @method annotation.
If you implement This is often the case, when class ParentClass {
private $data = array();
public function __call($method, array $args) {
if (0 === strpos($method, 'get')) {
return $this->data[strtolower(substr($method, 3))];
}
throw new \LogicException(sprintf('Unsupported method: %s', $method));
}
}
/**
* If this class knows which fields exist, you can specify the methods here:
*
* @method string getName()
*/
class SomeClass extends ParentClass { }
![]() |
|||
133 | } |
||
134 | } |
||
135 | return $link; |
||
136 | } |
||
137 | |||
138 | |||
139 | /** |
||
140 | * |
||
141 | * @return HTMLText |
||
142 | */ |
||
143 | public function getFullTitle($additionalStyle = '') |
||
144 | { |
||
145 | $s = $this->Title; |
||
0 ignored issues
–
show
The property
Title does not exist on object<Advertisement> . Since you implemented __set , maybe consider adding a @property annotation.
Since your code implements the magic setter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
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. ![]() |
|||
146 | if ($this->AdvertisementImageID) { |
||
0 ignored issues
–
show
The property
AdvertisementImageID does not exist on object<Advertisement> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read 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. ![]() |
|||
147 | $image = $this->AdvertisementImage(); |
||
0 ignored issues
–
show
The method
AdvertisementImage() does not exist on Advertisement . Did you maybe mean ResizedAdvertisementImage() ?
This check marks calls to methods that do not seem to exist on an object. This is most likely the result of a method being renamed without all references to it being renamed likewise. ![]() |
|||
148 | if ($image && $image->exists()) { |
||
149 | $thumb = $image->setSize(Config::inst()->get("Advertisement", "thumbnail_size"), Config::inst()->get("Advertisement", "thumbnail_size")); |
||
150 | if ($thumb) { |
||
151 | $s = ' |
||
152 | <img src="'.$thumb->Link().'" title="'.$thumb->Link().'"/ style="vertical-align: top; display: block; float: left; padding-right: 10px; '.$additionalStyle.' "><div style="width: 100%;">'.$s.'</div><div style="clear: left;"></div>'; |
||
153 | } |
||
154 | } |
||
155 | } |
||
156 | return DBField::create_field("HTMLText", $s); |
||
157 | } |
||
158 | |||
159 | /** |
||
160 | * |
||
161 | * @return HTMLText |
||
162 | */ |
||
163 | public function FullTitle() |
||
164 | { |
||
165 | return $this->getFullTitle(); |
||
166 | } |
||
167 | |||
168 | /** |
||
169 | * |
||
170 | * @return int | null |
||
171 | */ |
||
172 | public function getGroupID() |
||
173 | { |
||
174 | if ($this->AdvertisementImageID) { |
||
0 ignored issues
–
show
The property
AdvertisementImageID does not exist on object<Advertisement> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read 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. ![]() |
|||
175 | $image = Image::get()->byID($this->AdvertisementImageID); |
||
0 ignored issues
–
show
The property
AdvertisementImageID does not exist on object<Advertisement> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read 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. ![]() |
|||
176 | if ($image) { |
||
177 | return $image->ParentID; |
||
178 | } |
||
179 | } |
||
180 | } |
||
181 | |||
182 | /** |
||
183 | * |
||
184 | * @return int | null |
||
185 | */ |
||
186 | public function GroupID() |
||
187 | { |
||
188 | return $this->getGroupID(); |
||
189 | } |
||
190 | |||
191 | public function getCMSFields() |
||
192 | { |
||
193 | $fields = parent::getCMSFields(); |
||
194 | $fields->removeFieldFromTab("Root", "Sort"); |
||
195 | $fields->removeFieldFromTab("Root.Main", "AdvertisementImage"); |
||
196 | $fields->removeFieldFromTab("Root.Main", "AdvertisementImageID"); |
||
197 | $fields->removeFieldFromTab("Root.Main", "LinkedPageID"); |
||
198 | $fields->removeFieldFromTab("Root.Main", "ExternalLink"); |
||
199 | $fields->removeFieldFromTab("Root.Parents", "Parents"); |
||
200 | $fields->removeFieldFromTab("Root", "Parents"); |
||
201 | |||
202 | if (! $this->ShowTitle()) { |
||
203 | $fields->removeFieldFromTab("Root", "Title"); |
||
204 | } |
||
205 | |||
206 | if (! $this->ShowDescription()) { |
||
207 | $fields->removeFieldFromTab("Root", "Description"); |
||
208 | } |
||
209 | |||
210 | $fields->addFieldToTab("Root.Main", ReadonlyField::create("Link", 'Calculated Link')); |
||
211 | $fields->addFieldToTab("Root.Main", $mainImageField = new UploadField($name = "AdvertisementImage", $title = $this->i18n_singular_name())); |
||
212 | $mainImageField->setRightTitle(self::recommended_image_size_statement()); |
||
213 | $fields->addFieldToTab( |
||
214 | "Root.Main", |
||
215 | $additionalImageField = UploadField::create( |
||
216 | $name = "AdditionalImage", |
||
217 | $title = $this->i18n_singular_name()." "._t("Advertisement.ADDITIONAL_IMAGE", "additional image") |
||
218 | ) |
||
219 | ); |
||
220 | $additionalImageField->setRightTitle(self::recommended_image_size_statement()); |
||
221 | if ($this->ID) { |
||
222 | $treeField = TreeMultiselectField::create( |
||
223 | "Parents", |
||
224 | _t("Advertisement.GETCMSFIELDSPARENTID", "only show on ... (leave blank to show on all " |
||
225 | .$this->i18n_singular_name() |
||
226 | ." pages)"), |
||
227 | "SiteTree" |
||
228 | ); |
||
229 | /*$callback = $this->callbackFilterFunctionForMultiSelect(); |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
65% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
230 | if($callback) { |
||
231 | $treeField->setFilterFunction ($callback); |
||
232 | }*/ |
||
233 | $fields->addFieldToTab("Root.ShownOn", $treeField); |
||
234 | } |
||
235 | $fields->addFieldToTab( |
||
236 | "Root.OptionalLink", |
||
237 | $externalLinkField = new TextField($name = "ExternalLink", $title = _t("Advertisement.GETCMSFIELDSEXTERNALLINK", "link to external site")) |
||
238 | ); |
||
239 | $externalLinkField->setRightTitle(_t("Advertisement.GETCMSFIELDSEXTERNALLINK_EXPLANATION", "(e.g. http://www.wikipedia.org) - this will override an internal link")); |
||
240 | $fields->addFieldToTab("Root.OptionalLink", TreeDropdownField::create($name = "LinkedPageID", $title = _t("Advertisement.GETCMSFIELDSEXTERNALLINKID", "link to a page on this website"), $sourceObject = "SiteTree")); |
||
241 | if (class_exists("DataObjectSorterController")) { |
||
0 ignored issues
–
show
This
if statement is empty and can be removed.
This check looks for the bodies of These if (rand(1, 6) > 3) {
//print "Check failed";
} else {
print "Check succeeded";
}
could be turned into if (rand(1, 6) <= 3) {
print "Check succeeded";
}
This is much more concise to read. ![]() |
|||
242 | //sorted on parent page... |
||
243 | } else { |
||
244 | $fields->addFieldToTab( |
||
245 | "Root.Position", |
||
246 | $sortField = NumericField::create( |
||
247 | "Sort", |
||
248 | _t("Advertisement.SORT", "Sort index number") |
||
249 | ) |
||
250 | ); |
||
251 | $sortField->setRightTitle(_t("Advertisement.SORT_EXPLANATION", "the lower the number, the earlier it shows")); |
||
252 | } |
||
253 | $fields->removeFieldFromTab("Root.Main", "AlternativeSortNumber"); |
||
254 | |||
255 | return $fields; |
||
256 | } |
||
257 | |||
258 | public function onBeforeWrite() |
||
259 | { |
||
260 | parent::onBeforeWrite(); |
||
261 | if (! $this->Sort) { |
||
0 ignored issues
–
show
The property
Sort does not exist on object<Advertisement> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read 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. ![]() |
|||
262 | $defaults = $this->Config()->get("defaults"); |
||
263 | $this->Sort = isset($defaults["Sort"]) ? $defaults["Sort"] : 0; |
||
0 ignored issues
–
show
The property
Sort does not exist on object<Advertisement> . Since you implemented __set , maybe consider adding a @property annotation.
Since your code implements the magic setter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
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. ![]() |
|||
264 | } |
||
265 | } |
||
266 | |||
267 | |||
268 | public function requireDefaultRecords() |
||
269 | { |
||
270 | parent::requireDefaultRecords(); |
||
271 | DB::query("UPDATE \"Advertisement\" SET \"Title\" = \"ID\" WHERE \"Title\" = '' OR \"Title\" IS NULL;"); |
||
272 | } |
||
273 | |||
274 | |||
275 | /** |
||
276 | * |
||
277 | * @return bool |
||
0 ignored issues
–
show
|
|||
278 | */ |
||
279 | protected function callbackFilterFunctionForMultiSelect() |
||
280 | { |
||
281 | $inc = Config::inst()->get("AdvertisementDecorator", "page_classes_with_advertisements"); |
||
282 | $exc = Config::inst()->get("AdvertisementDecorator", "page_classes_without_advertisements"); |
||
283 | if (is_array($inc) && count($inc)) { |
||
284 | $string = 'return in_array($obj->class, array(\''.implode("','", $inc).'\'));'; |
||
285 | } elseif (is_array($exc) && count($exc)) { |
||
286 | $string = 'return !in_array($obj->class, array(\''.implode("','", $exc).'\'));'; |
||
287 | } |
||
288 | if (isset($string)) { |
||
289 | return create_function('$obj', $string); |
||
0 ignored issues
–
show
The use of
create_function is highly discouraged, better use a closure.
// Instead of
$function = create_function('$a, $b', 'return $a + $b');
// Better use
$function = function($a, $b) { return $a + $b; }
![]() |
|||
290 | } else { |
||
291 | return false; |
||
292 | } |
||
293 | } |
||
294 | |||
295 | public function Image() |
||
296 | { |
||
297 | //will be depreciated in the future. |
||
298 | return $this->ResizedAdvertisementImage(); |
||
299 | } |
||
300 | |||
301 | /** |
||
302 | * |
||
303 | * @return Image | null |
||
304 | */ |
||
305 | public function ResizedAdvertisementImage() |
||
306 | { |
||
307 | $resizedImage = null; |
||
308 | $imageID = intval($this->AdvertisementImageID+ 0); |
||
0 ignored issues
–
show
The property
AdvertisementImageID does not exist on object<Advertisement> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read 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. ![]() |
|||
309 | if ($imageID) { |
||
310 | if ($this->Config()->get("resize_images") == 'yes') { |
||
311 | $imageObject = Image::get()->byID($imageID); |
||
312 | $resizedImage = $imageObject; |
||
313 | if ($imageObject) { |
||
314 | if ($imageObject->ID) { |
||
315 | $imageObject->Title = Convert::raw2att($this->Title); |
||
0 ignored issues
–
show
The property
Title does not exist on object<Advertisement> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read 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. ![]() |
|||
316 | $w = Config::inst()->get("Advertisement", "width"); |
||
317 | $h = Config::inst()->get("Advertisement", "height"); |
||
318 | if ($h && $w) { |
||
319 | $resizedImage = $imageObject->SetSize($w, $h); |
||
320 | } elseif ($h) { |
||
321 | $resizedImage = $imageObject->SetHeight($h); |
||
322 | } elseif ($w) { |
||
323 | $resizedImage = $imageObject->SetWidth($w); |
||
324 | } else { |
||
325 | $resizedImage = $imageObject; |
||
326 | } |
||
327 | } else { |
||
0 ignored issues
–
show
This
else statement is empty and can be removed.
This check looks for the These if (rand(1, 6) > 3) {
print "Check failed";
} else {
//print "Check succeeded";
}
could be turned into if (rand(1, 6) > 3) {
print "Check failed";
}
This is much more concise to read. ![]() |
|||
328 | //debug::show("no image"); |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
72% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
329 | } |
||
330 | } else { |
||
0 ignored issues
–
show
This
else statement is empty and can be removed.
This check looks for the These if (rand(1, 6) > 3) {
print "Check failed";
} else {
//print "Check succeeded";
}
could be turned into if (rand(1, 6) > 3) {
print "Check failed";
}
This is much more concise to read. ![]() |
|||
331 | //debug::show("could not find image"); |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
72% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
332 | } |
||
333 | } else { |
||
334 | return $this->AdvertisementImage(); |
||
0 ignored issues
–
show
The method
AdvertisementImage() does not exist on Advertisement . Did you maybe mean ResizedAdvertisementImage() ?
This check marks calls to methods that do not seem to exist on an object. This is most likely the result of a method being renamed without all references to it being renamed likewise. ![]() |
|||
335 | } |
||
336 | } else { |
||
0 ignored issues
–
show
This
else statement is empty and can be removed.
This check looks for the These if (rand(1, 6) > 3) {
print "Check failed";
} else {
//print "Check succeeded";
}
could be turned into if (rand(1, 6) > 3) {
print "Check failed";
}
This is much more concise to read. ![]() |
|||
337 | //debug::show("no imageID ($imageID) "); |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
72% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
338 | } |
||
339 | |||
340 | return $resizedImage; |
||
341 | } |
||
342 | |||
343 | public function ThinyThumb() |
||
344 | { |
||
345 | return "This function has not been implemented"; |
||
346 | } |
||
347 | |||
348 | /** |
||
349 | * |
||
350 | * @return bool |
||
351 | */ |
||
352 | public function ShowTitle() |
||
353 | { |
||
354 | return $this->Config()->get('show_title'); |
||
355 | } |
||
356 | |||
357 | /** |
||
358 | * |
||
359 | * @return bool |
||
360 | */ |
||
361 | public function ShowDescription() |
||
362 | { |
||
363 | return $this->Config()->get('show_description'); |
||
364 | } |
||
365 | } |
||
366 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.