The expression $pid of type integer|null is loosely compared to true; this is ambiguous if the integer can be zero. You might want to explicitly use !== null instead.
In PHP, under loose comparison (like ==, or !=, or switch conditions),
values of different types might be equal.
For integer values, zero is a special case, in particular the following
results might be unexpected:
0==false// true0==null// true123==false// false123==null// false// It is often better to use strict comparison0===false// false0===null// false
Loading history...
19
20
$this->ID = $pid;
21
22
} else {
23
24
$this->ID = 0;
25
26
}
27
}
28
29
/**
30
* Returns default image url
31
* @return string
32
*/
33
public static function get_default_image() {
34
35
// You can put here any url
36
return THEME_DIR . '/assets/noimage.png';
37
38
}
39
40
/**
41
* Returns image url. In case image ID is 0 or not set returns default image
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.