Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php declare(strict_types=1); namespace PhpOffice\PhpSpreadsheetTests\Reader\Html; use..

Decoded Output download

<?php

declare(strict_types=1);

namespace PhpOffice\PhpSpreadsheetTests\Reader\Html;

use PhpOffice\PhpSpreadsheet\Reader\Html;
use PHPUnit\Framework\TestCase;

/**
 * There were problems running this test in HtmlTest with PhpUnit 10.
 * This replacement seem to work. I want it run in a separate
 * process because I am nervous about set_error_handler.
 *
 * @runTestsInSeparateProcesses
 */
class HtmlPhpunit10Test extends TestCase
{
    private static string $errorString;

    protected function setUp(): void
    {
        self::$errorString = '';
        set_error_handler([self::class, 'errorHandler']);
    }

    protected function tearDown(): void
    {
        restore_error_handler();
    }

    public static function errorHandler(int $errno, string $errstr): bool
    {
        if ($errno === E_WARNING) {
            self::$errorString = $errstr;

            return true; // stop error handling
        }

        return false; // continue error handling
    }

    public function testBadHtml(): void
    {
        $filename = 'tests/data/Reader/HTML/badhtml.html';
        $reader = new Html();
        self::assertTrue($reader->canRead($filename));
        $reader->load($filename);
        self::assertStringContainsString('DOMDocument::loadHTML', self::$errorString);
    }

    public function testLoadInvalidString(): void
    {
        $html = '<table<>';
        (new Html())->loadFromString($html);
        self::assertStringContainsString('DOMDocument::loadHTML', self::$errorString);
    }
}
 ?>

Did this file decode correctly?

Original Code

<?php

declare(strict_types=1);

namespace PhpOffice\PhpSpreadsheetTests\Reader\Html;

use PhpOffice\PhpSpreadsheet\Reader\Html;
use PHPUnit\Framework\TestCase;

/**
 * There were problems running this test in HtmlTest with PhpUnit 10.
 * This replacement seem to work. I want it run in a separate
 * process because I am nervous about set_error_handler.
 *
 * @runTestsInSeparateProcesses
 */
class HtmlPhpunit10Test extends TestCase
{
    private static string $errorString;

    protected function setUp(): void
    {
        self::$errorString = '';
        set_error_handler([self::class, 'errorHandler']);
    }

    protected function tearDown(): void
    {
        restore_error_handler();
    }

    public static function errorHandler(int $errno, string $errstr): bool
    {
        if ($errno === E_WARNING) {
            self::$errorString = $errstr;

            return true; // stop error handling
        }

        return false; // continue error handling
    }

    public function testBadHtml(): void
    {
        $filename = 'tests/data/Reader/HTML/badhtml.html';
        $reader = new Html();
        self::assertTrue($reader->canRead($filename));
        $reader->load($filename);
        self::assertStringContainsString('DOMDocument::loadHTML', self::$errorString);
    }

    public function testLoadInvalidString(): void
    {
        $html = '<table<>';
        (new Html())->loadFromString($html);
        self::assertStringContainsString('DOMDocument::loadHTML', self::$errorString);
    }
}

Function Calls

None

Variables

None

Stats

MD5 63543860c410cd8950fcf534bf5641e2
Eval Count 0
Decode Time 83 ms