Skip to content

Instantly share code, notes, and snippets.

@fabre-thibaud
Last active August 29, 2015 14:05
Show Gist options
  • Save fabre-thibaud/5a83eaed823067075c23 to your computer and use it in GitHub Desktop.
Save fabre-thibaud/5a83eaed823067075c23 to your computer and use it in GitHub Desktop.
HHVM \ReflectionFunction::getStaticVariables() incompatibility with PHP 5.4 -> 5.6
<?php
//See https://travis-ci.org/aztech-digital/closure-scope-merger/builds/33884775 for output containing test case
class ReflectionTest extends \PHPUnit_Framework_TestCase
{
public function testReflectionFunctionRefVars()
{
$refVariable = false;
$refName = 'refVariable';
$callback = function() use (& $refVariable)
{
// Stub callback to get a "by-ref" variable in reflection function static vars
};
$function = new \ReflectionFunction($callback);
$staticVariables = $function->getStaticVariables();
$this->assertTrue(array_key_exists($refName, $staticVariables));
$this->assertTrue($refVariable === false);
$staticVariables[$refName] = true;
$this->assertTrue($refVariable === true, 'Static variables from reflection should be bound to current scope.');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment