Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
PhpStorm Inspection Claim Variable is Unused when it is Used
<?php
function get_foo( $state, $method ) {
$value = null;
if ( method_exists( $this, $method ) ) {
/**
* PhpStorm INCORRECTLY identifies $value as NOT being used later.
*/
$value = $state->data[ $method ] = call_user_func( array( $state, $property_name ) );
}
return $value;
}
/**
* @param object $state
* @param string $method
*
* @return mixed|null
*/
function get_bar( $state, $method ) {
$value = null;
if ( method_exists( $this, $method ) ) {
/**
* PhpStorm correctly identifies $value as being used later.
*/
$value = $state->data = call_user_func( array( $state, $property_name ) );
}
return $value;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.