/** * @test */ public function notCauseAStrictStandardsErrorToBeRaised() { error_reporting(E_ALL); Stagehand_LegacyError_PHPError::enableConversion(E_STRICT); try { class_exists('Stagehand_LegacyError_PEARErrorStack'); } catch (Stagehand_LegacyError_PHPError_Exception $e) { Stagehand_LegacyError_PHPError::disableConversion(); $this->fail($e->getMessage()); } Stagehand_LegacyError_PHPError::disableConversion(); }
/** */ public static function disable() { restore_exception_handler(); Stagehand_LegacyError_PEARErrorStack::disableConversion(); Stagehand_LegacyError_PEARError::disableConversion(); Stagehand_LegacyError_PHPError::disableConversion(); }
/** * Scans the directory and invoke the callback. * * @param string $directory * @throws Stagehand_DirectoryScanner_Exception */ public function scan($directory) { Stagehand_LegacyError_PHPError::enableConversion(E_WARNING); try { $files = scandir($directory); } catch (Stagehand_LegacyError_PHPError $e) { Stagehand_LegacyError_PHPError::disableConversion(); throw new Stagehand_DirectoryScanner_Exception($e->getMessage()); } Stagehand_LegacyError_PHPError::disableConversion(); if ($files === false) { throw new Stagehand_DirectoryScanner_Exception('Failed to scan the directory [ ' . $directory . ' ], possible reasons are the directory is not found or not readable'); } for ($i = 0, $count = count($files); $i < $count; ++$i) { if ($this->denyAllow->evaluate($files[$i]) == Stagehand_AccessControl_AccessState::DENY) { continue; } $absoluteFilePath = $directory . DIRECTORY_SEPARATOR . $files[$i]; call_user_func($this->callback, $absoluteFilePath); if (is_dir($absoluteFilePath) && $this->recursivelyScans) { $this->scan($absoluteFilePath); } } }
/** */ public static function disableConversion() { $oldErrorReportingLevel = error_reporting(error_reporting() & ~E_STRICT); Stagehand_LegacyError_PHPError::enableConversion(error_reporting()); PEAR::staticPopErrorHandling(); Stagehand_LegacyError_PHPError::disableConversion(); error_reporting($oldErrorReportingLevel); }
/** * Parses the command line options. * * @return array */ protected function parseOptions() { Stagehand_LegacyError_PEARError::enableConversion(); $oldErrorReportingLevel = error_reporting(error_reporting() & ~E_STRICT & ~E_NOTICE); Stagehand_LegacyError_PHPError::enableConversion(error_reporting()); try { $argv = Console_Getopt::readPHPArgv(); array_shift($argv); $parsedOptions = Console_Getopt::getopt2($argv, $this->shortOptions, $this->longOptions); } catch (Stagehand_LegacyError_PEARError_Exception $e) { Stagehand_LegacyError_PHPError::disableConversion(); error_reporting($oldErrorReportingLevel); Stagehand_LegacyError_PEARError::disableConversion(); throw new $this->exceptionClass(preg_replace('/^Console_Getopt: /', '', $e->getMessage())); } catch (Exception $e) { Stagehand_LegacyError_PHPError::disableConversion(); error_reporting($oldErrorReportingLevel); Stagehand_LegacyError_PEARError::disableConversion(); throw $e; } Stagehand_LegacyError_PHPError::disableConversion(); error_reporting($oldErrorReportingLevel); Stagehand_LegacyError_PEARError::disableConversion(); return $parsedOptions; }
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * @package Stagehand_LegacyError * @copyright 2009, 2011 KUBO Atsuhiro <*****@*****.**> * @license http://www.opensource.org/licenses/bsd-license.php New BSD License * @version Release: 1.0.2 * @since File available since Release 0.1.0 */ $Stagehand_LegacyError_PEARErrorStack_oldErrorReportingLevel = error_reporting(error_reporting() & ~E_STRICT); Stagehand_LegacyError_PHPError::enableConversion(error_reporting()); require_once 'PEAR/ErrorStack.php'; Stagehand_LegacyError_PHPError::disableConversion(); error_reporting($Stagehand_LegacyError_PEARErrorStack_oldErrorReportingLevel); unset($Stagehand_LegacyError_PEARErrorStack_oldErrorReportingLevel); // {{{ Stagehand_LegacyError_PEARErrorStack /** * @package Stagehand_LegacyError * @copyright 2009, 2011 KUBO Atsuhiro <*****@*****.**> * @license http://www.opensource.org/licenses/bsd-license.php New BSD License * @version Release: 1.0.2 * @since Class available since Release 0.1.0 */ class Stagehand_LegacyError_PEARErrorStack { // {{{ properties /**#@+ * @access public
/** * @test */ public function notRaiseAnExceptionWhenAnUnrelatedErrorIsRaised() { Stagehand_LegacyError_PHPError::enableConversion(E_ALL); error_reporting(E_ALL & ~E_USER_WARNING); try { trigger_error('An expected exception has not been raised', E_USER_ERROR); $this->fail($e->getMessage()); Stagehand_LegacyError_PHPError::disableConversion(); } catch (Stagehand_LegacyError_PHPError_Exception $e) { } try { trigger_error('An unexpected exception has been raised', E_USER_WARNING); } catch (Stagehand_LegacyError_PHPError_Exception $e) { Stagehand_LegacyError_PHPError::disableConversion(); $this->fail($e->getMessage()); } Stagehand_LegacyError_PHPError::disableConversion(); }