It seems like $image defined by parameter $image on line 21 can also be of type resource; however, IBM\Watson\VisualRecogni...Classify::classifyUrl() does only seem to accept string, maybe add an additional type check?
This check looks at variables that have been passed in as parameters and are passed out again
to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
The variable $response does not seem to be defined for all execution paths leading up to this point.
If you define a variable conditionally, it can happen that it is not defined
for all execution paths.
Let’s take a look at an example:
functionmyFunction($a){switch($a){case'foo':$x=1;break;case'bar':$x=2;break;}// $x is potentially undefined here.echo$x;}
In the above example, the variable $x is defined if you pass “foo” or “bar”
as argument for $a. However, since the switch statement has no default
case statement, if you pass any other value, the variable $x would be undefined.
Available Fixes
Check for existence of the variable explicitly:
functionmyFunction($a){switch($a){case'foo':$x=1;break;case'bar':$x=2;break;}if(isset($x)){// Make sure it's always set.echo$x;}}
Define a default value for the variable:
functionmyFunction($a){$x='';// Set a default which gets overridden for certain paths.switch($a){case'foo':$x=1;break;case'bar':$x=2;break;}echo$x;}
Add a value for the missing path:
functionmyFunction($a){switch($a){case'foo':$x=1;break;case'bar':$x=2;break;// We add support for the missing case.default:$x='';break;}echo$x;}