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\Csv; use ..

Decoded Output download

<?php

declare(strict_types=1);

namespace PhpOffice\PhpSpreadsheetTests\Reader\Csv;

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

class CsvIssue2840Test extends TestCase
{
    public function testNullStringIgnore(): void
    {
        $reader = new Csv();
        self::assertFalse($reader->getPreserveNullString());
        $inputData = <<<EOF
            john,,doe,,
            mary,,jane,,
            EOF;
        $expected = [
            ['john', null, 'doe'],
            ['mary', null, 'jane'],
        ];
        $spreadsheet = $reader->loadSpreadsheetFromString($inputData);
        $sheet = $spreadsheet->getActiveSheet();
        self::assertSame($expected, $sheet->toArray());
        $spreadsheet->disconnectWorksheets();
    }

    public function testNullStringLoad(): void
    {
        $reader = new Csv();
        $reader->setPreserveNullString(true);
        $inputData = <<<EOF
            john,,doe,,
            mary,,jane,,
            EOF;
        $expected = [
            ['john', '', 'doe', '', ''],
            ['mary', '', 'jane', '', ''],
        ];
        $spreadsheet = $reader->loadSpreadsheetFromString($inputData);
        $sheet = $spreadsheet->getActiveSheet();
        self::assertSame($expected, $sheet->toArray());
        $spreadsheet->disconnectWorksheets();
    }
}
 ?>

Did this file decode correctly?

Original Code

<?php

declare(strict_types=1);

namespace PhpOffice\PhpSpreadsheetTests\Reader\Csv;

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

class CsvIssue2840Test extends TestCase
{
    public function testNullStringIgnore(): void
    {
        $reader = new Csv();
        self::assertFalse($reader->getPreserveNullString());
        $inputData = <<<EOF
            john,,doe,,
            mary,,jane,,
            EOF;
        $expected = [
            ['john', null, 'doe'],
            ['mary', null, 'jane'],
        ];
        $spreadsheet = $reader->loadSpreadsheetFromString($inputData);
        $sheet = $spreadsheet->getActiveSheet();
        self::assertSame($expected, $sheet->toArray());
        $spreadsheet->disconnectWorksheets();
    }

    public function testNullStringLoad(): void
    {
        $reader = new Csv();
        $reader->setPreserveNullString(true);
        $inputData = <<<EOF
            john,,doe,,
            mary,,jane,,
            EOF;
        $expected = [
            ['john', '', 'doe', '', ''],
            ['mary', '', 'jane', '', ''],
        ];
        $spreadsheet = $reader->loadSpreadsheetFromString($inputData);
        $sheet = $spreadsheet->getActiveSheet();
        self::assertSame($expected, $sheet->toArray());
        $spreadsheet->disconnectWorksheets();
    }
}

Function Calls

None

Variables

None

Stats

MD5 92d3c34b67289c3c2f8c8b3a39e1747b
Eval Count 0
Decode Time 88 ms