Skip to content

Commit

Permalink
Merge pull request #141 from Ocramius/hotfix/hhvm-compat
Browse files Browse the repository at this point in the history
Applying workarounds for HHVM compatibility
  • Loading branch information
Ocramius committed Feb 6, 2014
2 parents a8e3e5b + e95b8c6 commit 40a89a7
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function __construct(
$localizedProperties = array();

foreach ($originalClass->getProperties() as $originalProperty) {
if (PHP_VERSION_ID < 50400 && $originalProperty->isPrivate()) {
if ((PHP_VERSION_ID < 50400 || (defined('HHVM_VERSION'))) && $originalProperty->isPrivate()) {
// @codeCoverageIgnoreStart
throw UnsupportedProxiedClassException::unsupportedLocalizedReflectionProperty($originalProperty);
// @codeCoverageIgnoreEnd
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ private static function getOperation($operationType, $nameParameter, $valueParam
*/
private static function getScopeReBind()
{
if (PHP_VERSION_ID < 50400) {
if (PHP_VERSION_ID < 50400 || defined('HHVM_VERSION')) {
// @codeCoverageIgnoreStart
return '';
// @codeCoverageIgnoreEnd
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class AccessInterceptorScopeLocalizerFunctionalTest extends PHPUnit_Framework_Te
*/
public static function setUpBeforeClass()
{
if (PHP_VERSION_ID < 50400) {
if (PHP_VERSION_ID < 50400 || defined('HHVM_VERSION')) {
throw new PHPUnit_Framework_SkippedTestError(
'PHP 5.3 doesn\'t support scope localization of private properties'
);
Expand Down
3 changes: 2 additions & 1 deletion tests/ProxyManagerTest/Functional/BasePerformanceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,9 @@ protected function endCapturing($messageTemplate)
*/
protected function compareProfile(array $baseProfile, array $proxyProfile)
{
$baseMemory = max(1, $baseProfile['memory']);
$timeOverhead = (($proxyProfile['time'] / $baseProfile['time']) - 1) * 100;
$memoryOverhead = (($proxyProfile['memory'] / $baseProfile['memory']) - 1) * 100;
$memoryOverhead = (($proxyProfile['memory'] / $baseMemory) - 1) * 100;

echo sprintf('Comparison time / memory: %.2f%% / %.2f%%', $timeOverhead, $memoryOverhead) . "\n\n";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ public function testCanGenerateMultipleDifferentProxiesForSameClass($className)

$reflectionClass = new ReflectionClass($className);

if (PHP_VERSION_ID < 50400 && $reflectionClass->getProperties(ReflectionProperty::IS_PRIVATE)) {
if ((defined('HHVM_VERSION') || PHP_VERSION_ID < 50400)
&& $reflectionClass->getProperties(ReflectionProperty::IS_PRIVATE)
) {
$skipScopeLocalizerTests = true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public function testBodyStructureWithProtectedProperties()
*/
public function testBodyStructureWithPrivateProperties()
{
if (PHP_VERSION_ID < 50400) {
if (PHP_VERSION_ID < 50400 || defined('HHVM_VERSION')) {
$this->setExpectedException('ProxyManager\Exception\UnsupportedProxiedClassException');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ public function testGeneratesValidCode($className)
return parent::testGeneratesValidCode($className);
}

if (PHP_VERSION_ID < 50400 && $reflectionClass->getProperties(ReflectionProperty::IS_PRIVATE)) {
if ((PHP_VERSION_ID < 50400 || defined('HHVM_VERSION'))
&& $reflectionClass->getProperties(ReflectionProperty::IS_PRIVATE)
) {
$this->setExpectedException('ProxyManager\Exception\UnsupportedProxiedClassException');
}

Expand Down

0 comments on commit 40a89a7

Please sign in to comment.