Skip to content

Commit

Permalink
minor #23216 Remove HHVM support (second edition) (Nek-)
Browse files Browse the repository at this point in the history
This PR was squashed before being merged into the 4.0-dev branch (closes #23216).

Discussion
----------

Remove HHVM support (second edition)

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | none
| License       | MIT
| Doc PR        | not needed

This PR removes HHVM compatiblity following #22758 as some things were missing. It also removes some useless comments.

Commits
-------

471b84c Remove HHVM support (second edition)
  • Loading branch information
nicolas-grekas committed Jul 3, 2017
2 parents 0531316 + 471b84c commit b12f215
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 41 deletions.
2 changes: 1 addition & 1 deletion src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php
Expand Up @@ -62,7 +62,7 @@ function ($key, $value, $isHit) {
*/
public static function create($file, CacheItemPoolInterface $fallbackPool)
{
// Shared memory is available in PHP 7.0+ with OPCache enabled and in HHVM
// Shared memory is available in PHP 7.0+ with OPCache enabled
if (ini_get('opcache.enable')) {
if (!$fallbackPool instanceof AdapterInterface) {
$fallbackPool = new ProxyAdapter($fallbackPool);
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Cache/Simple/PhpArrayCache.php
Expand Up @@ -45,7 +45,7 @@ public function __construct($file, CacheInterface $fallbackPool)
*/
public static function create($file, CacheInterface $fallbackPool)
{
// Shared memory is available in PHP 7.0+ with OPCache enabled and in HHVM
// Shared memory is available in PHP 7.0+ with OPCache enabled
if (ini_get('opcache.enable')) {
return new static($file, $fallbackPool);
}
Expand Down
33 changes: 8 additions & 25 deletions src/Symfony/Component/Debug/ErrorHandler.php
Expand Up @@ -382,10 +382,8 @@ public function handleError($type, $message, $file, $line)

if (4 < $numArgs = func_num_args()) {
$context = $scope ? (func_get_arg(4) ?: array()) : array();
$backtrace = 5 < $numArgs ? func_get_arg(5) : null; // defined on HHVM
} else {
$context = array();
$backtrace = null;
}

if (isset($context['GLOBALS']) && $scope) {
Expand All @@ -394,15 +392,6 @@ public function handleError($type, $message, $file, $line)
$context = $e;
}

if (null !== $backtrace && $type & E_ERROR) {
// E_ERROR fatal errors are triggered on HHVM when
// hhvm.error_handling.call_user_handler_on_fatals=1
// which is the way to get their backtrace.
$this->handleFatalError(compact('type', 'message', 'file', 'line', 'backtrace'));

return true;
}

$logMessage = $this->levels[$type].': '.$message;

if (null !== self::$toStringException) {
Expand Down Expand Up @@ -436,11 +425,12 @@ public function handleError($type, $message, $file, $line)

// Clean the trace by removing function arguments and the first frames added by the error handler itself.
if ($throw || $this->tracedErrors & $type) {
$backtrace = $backtrace ?: $errorAsException->getTrace();
$backtrace = $errorAsException->getTrace();
$lightTrace = $this->cleanTrace($backtrace, $type, $file, $line, $throw);
$this->traceReflector->setValue($errorAsException, $lightTrace);
} else {
$this->traceReflector->setValue($errorAsException, array());
$backtrace = array();
}
}

Expand All @@ -454,32 +444,25 @@ public function handleError($type, $message, $file, $line)
&& ('trigger_error' === $backtrace[$i - 1]['function'] || 'user_error' === $backtrace[$i - 1]['function'])
) {
// Here, we know trigger_error() has been called from __toString().
// HHVM is fine with throwing from __toString() but PHP triggers a fatal error instead.
// PHP triggers a fatal error when throwing from __toString().
// A small convention allows working around the limitation:
// given a caught $e exception in __toString(), quitting the method with
// `return trigger_error($e, E_USER_ERROR);` allows this error handler
// to make $e get through the __toString() barrier.

foreach ($context as $e) {
if (($e instanceof \Exception || $e instanceof \Throwable) && $e->__toString() === $message) {
if (1 === $i) {
// On HHVM
$errorAsException = $e;
break;
}
if ($e instanceof \Throwable && $e->__toString() === $message) {
self::$toStringException = $e;

return true;
}
}

if (1 < $i) {
// On PHP (not on HHVM), display the original error message instead of the default one.
$this->handleException($errorAsException);
// Display the original error message instead of the default one.
$this->handleException($errorAsException);

// Stop the process by giving back the error to the native handler.
return false;
}
// Stop the process by giving back the error to the native handler.
return false;
}
}
}
Expand Down
Expand Up @@ -52,12 +52,7 @@ private function getType(\ReflectionParameter $parameter)
if (!$type = $parameter->getType()) {
return;
}
$typeName = $type->getName();
if ('array' === $typeName && !$type->isBuiltin()) {
// Special case for HHVM with variadics
return;
}

return $typeName;
return $type->getName();
}
}
Expand Up @@ -34,7 +34,6 @@ public function read($path, $locale)
// Never enable fallback. We want to know if a bundle cannot be found
$bundle = new \ResourceBundle($locale, $path, false);
} catch (\Exception $e) {
// HHVM compatibility: constructor throws on invalid resource
$bundle = null;
}

Expand Down
Expand Up @@ -177,11 +177,6 @@ private function extractFromMutator($class, $property)
}
$type = $this->extractFromReflectionType($reflectionType);

// HHVM reports variadics with "array" but not builtin type hints
if (!$reflectionType->isBuiltin() && Type::BUILTIN_TYPE_ARRAY === $type->getBuiltinType()) {
return;
}

if (in_array($prefix, $this->arrayMutatorPrefixes)) {
$type = new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, new Type(Type::BUILTIN_TYPE_INT), $type);
}
Expand Down
Expand Up @@ -39,7 +39,6 @@ public function load($resource, $locale, $domain = 'messages')
try {
$rb = new \ResourceBundle($locale, $resource);
} catch (\Exception $e) {
// HHVM compatibility: constructor throws on invalid resource
$rb = null;
}

Expand Down
Expand Up @@ -39,7 +39,6 @@ public function load($resource, $locale, $domain = 'messages')
try {
$rb = new \ResourceBundle($locale, $resource);
} catch (\Exception $e) {
// HHVM compatibility: constructor throws on invalid resource
$rb = null;
}

Expand Down

0 comments on commit b12f215

Please sign in to comment.