You are here

class HhvmExceptionPatch in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/phpspec/prophecy/src/Prophecy/Doubler/ClassPatch/HhvmExceptionPatch.php \Prophecy\Doubler\ClassPatch\HhvmExceptionPatch

Exception patch for HHVM to remove the stubs from special methods

@author Christophe Coevoet <stof@notk.org>

Hierarchy

Expanded class hierarchy of HhvmExceptionPatch

File

vendor/phpspec/prophecy/src/Prophecy/Doubler/ClassPatch/HhvmExceptionPatch.php, line 21

Namespace

Prophecy\Doubler\ClassPatch
View source
class HhvmExceptionPatch implements ClassPatchInterface {

  /**
   * Supports exceptions on HHVM.
   *
   * @param ClassNode $node
   *
   * @return bool
   */
  public function supports(ClassNode $node) {
    if (!defined('HHVM_VERSION')) {
      return false;
    }
    return 'Exception' === $node
      ->getParentClass() || is_subclass_of($node
      ->getParentClass(), 'Exception');
  }

  /**
   * Removes special exception static methods from the doubled methods.
   *
   * @param ClassNode $node
   *
   * @return void
   */
  public function apply(ClassNode $node) {
    if ($node
      ->hasMethod('setTraceOptions')) {
      $node
        ->getMethod('setTraceOptions')
        ->useParentCode();
    }
    if ($node
      ->hasMethod('getTraceOptions')) {
      $node
        ->getMethod('getTraceOptions')
        ->useParentCode();
    }
  }

  /**
   * {@inheritdoc}
   */
  public function getPriority() {
    return -50;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
HhvmExceptionPatch::apply public function Removes special exception static methods from the doubled methods. Overrides ClassPatchInterface::apply
HhvmExceptionPatch::getPriority public function Returns patch priority, which determines when patch will be applied. Overrides ClassPatchInterface::getPriority
HhvmExceptionPatch::supports public function Supports exceptions on HHVM. Overrides ClassPatchInterface::supports