Last active
August 29, 2015 14:23
-
-
Save mikeschinkel/9f04abd203b82a6952d5 to your computer and use it in GitHub Desktop.
PhpStorm Inspection Claim Variable is Unused when it is Used
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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