2017 © Pedro Peláez
 

library hack-error-suppressor

Suppress HHVM's automatic conversion of typechecker errors to fatals.

image

fredemmott/hack-error-suppressor

Suppress HHVM's automatic conversion of typechecker errors to fatals.

  • Tuesday, May 2, 2017
  • by fredemmott
  • Repository
  • 0 Watchers
  • 1 Stars
  • 20,279 Installations
  • Hack
  • 1 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 3 Versions
  • 42 % Grown

The README.md

INACTIVE PROJECT

THIS PROJECT IS NO LONGER ACTIVE; it is not needed with HHVM 3.25 and later., (*1)

Hack Error Suppressor Build Status

Unless the hhvm.hack.lang.look_for_typechecker ini setting is set to false, by default HHVM will try to run the typechecker when loading any Hack files, and raise a catchable runtime fatal error., (*2)

This is a PHP library that makes it convenient to temporarily disable this behavior., (*3)

When This Is Useful

HHVM's behavior is problematic when:, (*4)

  • HHVM can't work out where the project root is - for example, if you're trying to run Hack code from a composer plugin
  • If your Hack code needs to operate on an incomplete project - for example, if you wish to write Hack code to fetch dependencies
  • If your Hack code needs to operate on known-bad projects - for example, when updating generated code, the code may be inconsistent while your codegen is in process

When You Shouldn't Use This

It's probably not appropriate if any of these are true: - it's used outside of a build/install or codegen process - it's used when using generated code - it's called during normal use of your software, rather than just by developers - it's used outside of the CLI, (*5)

Typechecker errors are real problems with code, and mean that things are broken; ignoring enforcement is only a good idea if you are expecting your code to be running on a temporarily-broken codebase, and your code fixes it., (*6)

Installation

$ composer require fredemmott/hack-error-suppressor

Usage

You must enable error suppression before any Hack code is loaded., (*7)

You can explicitly enable and disable the suppression:, (*8)

<?php
use FredEmmott\HackErrorSuppressor;

$it = new HackErrorSuppressor();
$it->enable();
call_some_hack_code();
$it->disable();

You can also enable the suppression with a scope:, (*9)

<?php

use FredEmmott\ScopedHackErrorSuppressor;

function do_unsafe_stuff() {
  $suppressor = new ScopedHackErrorSuppressor();
  call_some_hack_code(); // this works
}

do_unsafe_stuff();
call_some_hack_code(); // this fails, as we're out of scope

Using Outside Of The CLI

This is disallowed by default; if you're absolutely certain you need to do this (keeping in mind that typechecker errors are real problems with your code, not just lint) you can disable the check:, (*10)

FredEmmott\HackErrorSuppressor::allowRealRequestsAgainstBrokenCode();

The Versions

02/05 2017

dev-master

9999999-dev

Suppress HHVM's automatic conversion of typechecker errors to fatals.

  Sources   Download

ISC

The Development Requires

by Fred Emmott

02/05 2017

v1.0.1

1.0.1.0

Suppress HHVM's automatic conversion of typechecker errors to fatals.

  Sources   Download

ISC

The Development Requires

by Fred Emmott

23/01 2017

v1.0.0

1.0.0.0

Suppress HHVM's automatic conversion of typechecker errors to fatals.

  Sources   Download

ISC

The Development Requires

by Fred Emmott