The expression $this->images of type Bobbyshaw\WatsonVisualRecognition\Image[] is implicitly converted to a boolean; are you sure this is intended? If so, consider using empty($expr) instead to make it clear that you intend to check for an array without elements.
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an
empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using empty(..) or !empty(...) instead.
Loading history...
29
$images = [];
30
foreach ($this->data->images as $image) {
31
$classifiers = [];
32
if (isset($image->scores)) {
33
foreach ($image->scores as $classifier) {
34
$classifiers[] = new Classifier(
35
$classifier->classifier_id,
36
$classifier->name,
37
$classifier->score
38
);
39
}
40
}
41
$images[] = new Image($image->image, $classifiers);
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)
or! empty(...)
instead.