Skip to content

Instantly share code, notes, and snippets.

@mikeschinkel
Last active August 29, 2015 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikeschinkel/9f04abd203b82a6952d5 to your computer and use it in GitHub Desktop.
Save mikeschinkel/9f04abd203b82a6952d5 to your computer and use it in GitHub Desktop.
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