diff --git a/Patchwork.php b/Patchwork.php index 7d1a0e0..f0bc81e 100644 --- a/Patchwork.php +++ b/Patchwork.php @@ -107,13 +107,6 @@ function always($value) Utils\markMissedCallables(); -if (Utils\runningOnHHVM()) { - # no preprocessor needed on HHVM; - # just let Patchwork become a wrapper for fb_intercept() - spl_autoload_register('Patchwork\CallRerouting\deployQueue'); - return; -} - CodeManipulation\Stream::discoverOtherWrapper(); CodeManipulation\Stream::wrap(); diff --git a/src/CallRerouting.php b/src/CallRerouting.php index 0a926a4..c0619ed 100644 --- a/src/CallRerouting.php +++ b/src/CallRerouting.php @@ -96,9 +96,6 @@ function connect($source, callable $target, Handle $handle = null, $partOfWildca } } else { $handle = queueConnection($source, $target, $handle); - if (Utils\runningOnHHVM()) { - connectOnHHVM("$class::$method", $handle); - } } } attachExistenceAssertion($handle, $source); @@ -166,12 +163,6 @@ function validate($function, $partOfWildcard = false) if ($reflection->isInternal() && !in_array($name, Config\getRedefinableInternals())) { throw new Exceptions\NotUserDefined($function); } - if (Utils\runningOnHHVM()) { - if ($reflection->isInternal()) { - throw new Exceptions\InternalsNotSupportedOnHHVM($function); - } - return; - } if (!$reflection->isInternal() && !inPreprocessedFile($function) && !$partOfWildcard) { throw new Exceptions\DefinedTooEarly($function); } @@ -179,9 +170,6 @@ function validate($function, $partOfWildcard = false) function inPreprocessedFile($callable) { - if (Utils\runningOnHHVM()) { - return true; - } if (Utils\isOwnName(Utils\callableToString($callable))) { return false; } @@ -196,9 +184,6 @@ function connectFunction($function, callable $target, Handle $handle = null) $routes = &State::$routes[null][$function]; $offset = Utils\append($routes, [$target, $handle]); $handle->addReference($routes[$offset]); - if (Utils\runningOnHHVM()) { - connectOnHHVM($function, $handle); - } return $handle; } @@ -236,18 +221,13 @@ function connectMethod($function, callable $target, Handle $handle = null) $reflection = Utils\reflectCallable($function); $declaringClass = $reflection->getDeclaringClass(); $class = $declaringClass->getName(); - if (!Utils\runningOnHHVM()) { - $aliases = $declaringClass->getTraitAliases(); - if (isset($aliases[$method])) { - list($trait, $method) = explode('::', $aliases[$method]); - } + $aliases = $declaringClass->getTraitAliases(); + if (isset($aliases[$method])) { + list($trait, $method) = explode('::', $aliases[$method]); } $routes = &State::$routes[$class][$method]; $offset = Utils\append($routes, [$target, $handle]); $handle->addReference($routes[$offset]); - if (Utils\runningOnHHVM()) { - connectOnHHVM("$class::$method", $handle); - } return $handle; } @@ -361,6 +341,9 @@ function relay(array $args = null) return $result; } +/** + * @deprecated 2.2.0 + */ function connectOnHHVM($function, Handle $handle) { fb_intercept($function, function($name, $obj, $args, $data, &$done) { @@ -380,6 +363,9 @@ function connectOnHHVM($function, Handle $handle) $handle->addExpirationHandler(getHHVMExpirationHandler($function)); } +/** + * @deprecated 2.2.0 + */ function getHHVMExpirationHandler($function) { return function() use ($function) { diff --git a/src/Exceptions.php b/src/Exceptions.php index c4ae4a6..5792867 100644 --- a/src/Exceptions.php +++ b/src/Exceptions.php @@ -52,6 +52,9 @@ class InternalMethodsNotSupported extends CallbackException protected $message = "Methods of internal classes (such as %s) are not yet redefinable in Patchwork 2.1."; } +/** + * @deprecated 2.2.0 + */ class InternalsNotSupportedOnHHVM extends CallbackException { protected $message = "As of version 2.1, Patchwork cannot redefine internal functions and methods (such as %s) on HHVM."; diff --git a/src/Utils.php b/src/Utils.php index 4ddaf20..aa8a681 100644 --- a/src/Utils.php +++ b/src/Utils.php @@ -37,6 +37,9 @@ function generatorsSupported() return version_compare(PHP_VERSION, "5.5", ">="); } +/** + * @deprecated 2.2.0 + */ function runningOnHHVM() { return defined("HHVM_VERSION"); @@ -235,18 +238,8 @@ function getUserDefinedMethods() static $traitCount = 0; $classes = getUserDefinedClasses(); $traits = getUserDefinedTraits(); - if (runningOnHHVM()) { - # cannot rely on the order of get_declared_classes() - static $previousClasses = []; - static $previousTraits = []; - $newClasses = array_diff($classes, $previousClasses); - $newTraits = array_diff($traits, $previousTraits); - $previousClasses = $classes; - $previousTraits = $traits; - } else { - $newClasses = array_slice($classes, $classCount); - $newTraits = array_slice($traits, $traitCount); - } + $newClasses = array_slice($classes, $classCount); + $newTraits = array_slice($traits, $traitCount); foreach (array_merge($newClasses, $newTraits) as $newClass) { foreach (get_class_methods($newClass) as $method) { $result[] = $newClass . '::' . $method; diff --git a/tests/inheritance-delayed-redefinition.phpt b/tests/inheritance-delayed-redefinition.phpt index adb7663..629b272 100644 --- a/tests/inheritance-delayed-redefinition.phpt +++ b/tests/inheritance-delayed-redefinition.phpt @@ -1,5 +1,5 @@ --TEST-- -Inheriting method patches + delayed redefinition (suspected HHVM issue) +Inheriting method patches + delayed redefinition --FILE-- - --FILE-- - --FILE-- =") or die("skip because this bug only occurs in PHP 5.6 and up"); -!defined('HHVM_VERSION') - or die('skip because the redefinition of internals is not yet implemented for HHVM'); - ?> --FILE--