diff --git a/lib/runner.php b/lib/runner.php index 70e77d92..cedebcb1 100644 --- a/lib/runner.php +++ b/lib/runner.php @@ -1292,7 +1292,7 @@ function export_uses( array $uses ) { default: case 'functions': - $out[ $type ][] = array( + $used = array( 'name' => $name, 'line' => $element->getLineNumber(), 'end_line' => $element->getNode()->getAttribute( 'endLine' ), @@ -1310,9 +1310,11 @@ function export_uses( array $uses ) { $version = (string) $arguments[1]->value->value; } - $out[ $type ][0]['deprecation_version'] = $version; + $used['deprecation_version'] = $version; } + $out[ $type ][] = $used; + break; } } diff --git a/tests/phpunit/tests/export/uses/deprecated.inc b/tests/phpunit/tests/export/uses/deprecated.inc new file mode 100644 index 00000000..44e6a819 --- /dev/null +++ b/tests/phpunit/tests/export/uses/deprecated.inc @@ -0,0 +1,6 @@ +assertFunctionUsesFunction( + 'old_thing' + , array( + 'name' => '_deprecated_function', + 'line' => 5, + 'end_line' => 5, + 'deprecation_version' => '6.1.0', + ) + ); + } + + /** + * Test that the version isn't exported for a call preceding the deprecation. + */ + public function test_preceding_call_has_no_version() { + + $this->assertFunctionUsesFunction( + 'old_thing' + , array( + 'name' => 'do_something_first', + 'line' => 4, + 'end_line' => 4, + ) + ); + } +}