Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 0 additions & 24 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,6 @@ parameters:
count: 1
path: src/PhpSpreadsheet/Calculation/LookupRef/Sort.php

-
message: '#^Cannot call method getAllSpContainers\(\) on mixed\.$#'
identifier: method.nonObject
count: 1
path: src/PhpSpreadsheet/Reader/Xls/LoadSpreadsheet.php

-
message: '#^Cannot call method getBSECollection\(\) on mixed\.$#'
identifier: method.nonObject
count: 1
path: src/PhpSpreadsheet/Reader/Xls/LoadSpreadsheet.php

-
message: '#^Cannot call method getBstoreContainer\(\) on mixed\.$#'
identifier: method.nonObject
count: 1
path: src/PhpSpreadsheet/Reader/Xls/LoadSpreadsheet.php

-
message: '#^Cannot call method getSpgrContainer\(\) on mixed\.$#'
identifier: method.nonObject
count: 1
path: src/PhpSpreadsheet/Reader/Xls/LoadSpreadsheet.php

-
message: '#^Cannot access offset 0 on mixed\.$#'
identifier: offsetAccess.nonOffsetAccessible
Expand Down
9 changes: 9 additions & 0 deletions src/PhpSpreadsheet/Reader/Xls/Escher.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
use PhpOffice\PhpSpreadsheet\Shared\Escher\DggContainer\BstoreContainer\BSE;
use PhpOffice\PhpSpreadsheet\Shared\Escher\DggContainer\BstoreContainer\BSE\Blip;

/**
* @template T of BSE|BstoreContainer|DgContainer|DggContainer|\PhpOffice\PhpSpreadsheet\Shared\Escher|SpContainer|SpgrContainer
*/
class Escher
{
const DGGCONTAINER = 0xF000;
Expand Down Expand Up @@ -50,11 +53,15 @@ class Escher

/**
* The object to be returned by the reader. Modified during load.
*
* @var T
*/
private BSE|BstoreContainer|DgContainer|DggContainer|\PhpOffice\PhpSpreadsheet\Shared\Escher|SpContainer|SpgrContainer $object;

/**
* Create a new Escher instance.
*
* @param T $object
*/
public function __construct(BSE|BstoreContainer|DgContainer|DggContainer|\PhpOffice\PhpSpreadsheet\Shared\Escher|SpContainer|SpgrContainer $object)
{
Expand Down Expand Up @@ -84,6 +91,8 @@ public function __construct(BSE|BstoreContainer|DgContainer|DggContainer|\PhpOff

/**
* Load Escher stream data. May be a partial Escher stream.
*
* @return T
*/
public function load(string $data): BSE|BstoreContainer|DgContainer|DggContainer|\PhpOffice\PhpSpreadsheet\Shared\Escher|SpContainer|SpgrContainer
{
Expand Down
4 changes: 2 additions & 2 deletions src/PhpSpreadsheet/Reader/Xls/LoadSpreadsheet.php
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ protected function loadSpreadsheetFromFile2(string $filename, Xls $xls): Spreads

// get all spContainers in one long array, so they can be mapped to OBJ records
/** @var SpContainer[] $allSpContainers */
$allSpContainers = method_exists($escherWorksheet, 'getDgContainer') ? $escherWorksheet->getDgContainer()->getSpgrContainer()->getAllSpContainers() : [];
$allSpContainers = $escherWorksheet->getDgContainerOrThrow()->getSpgrContainerOrThrow()->getAllSpContainers();
}

// treat OBJ records
Expand Down Expand Up @@ -497,7 +497,7 @@ protected function loadSpreadsheetFromFile2(string $filename, Xls $xls): Spreads

if ($escherWorkbook) {
/** @var BSE[] */
$BSECollection = method_exists($escherWorkbook, 'getDggContainer') ? $escherWorkbook->getDggContainer()->getBstoreContainer()->getBSECollection() : [];
$BSECollection = $escherWorkbook->getDggContainerOrThrow()->getBstoreContainerOrThrow()->getBSECollection();
$BSE = $BSECollection[$BSEindex - 1];
$blipType = $BSE->getBlipType();

Expand Down
26 changes: 26 additions & 0 deletions src/PhpSpreadsheet/Shared/Escher.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace PhpOffice\PhpSpreadsheet\Shared;

use PhpOffice\PhpSpreadsheet\Exception as SpreadsheetException;

class Escher
{
/**
Expand All @@ -22,6 +24,18 @@ public function getDggContainer(): ?Escher\DggContainer
return $this->dggContainer;
}

/**
* Get Drawing Group Container.
*/
public function getDggContainerOrThrow(): Escher\DggContainer
{
if ($this->dggContainer !== null) {
return $this->dggContainer;
}

throw new SpreadsheetException('dggContainer is unexpectedly null');
}

/**
* Set Drawing Group Container.
*/
Expand All @@ -38,6 +52,18 @@ public function getDgContainer(): ?Escher\DgContainer
return $this->dgContainer;
}

/**
* Get Drawing Container.
*/
public function getDgContainerOrThrow(): Escher\DgContainer
{
if ($this->dgContainer !== null) {
return $this->dgContainer;
}

throw new SpreadsheetException('dgContainer is unexpectedly null');
}

/**
* Set Drawing Container.
*/
Expand Down
14 changes: 14 additions & 0 deletions src/PhpSpreadsheet/Shared/Escher/DggContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace PhpOffice\PhpSpreadsheet\Shared\Escher;

use PhpOffice\PhpSpreadsheet\Exception as SpreadsheetException;

class DggContainer
{
/**
Expand Down Expand Up @@ -94,6 +96,18 @@ public function getBstoreContainer(): ?DggContainer\BstoreContainer
return $this->bstoreContainer;
}

/**
* Get BLIP Store Container.
*/
public function getBstoreContainerOrThrow(): DggContainer\BstoreContainer
{
if ($this->bstoreContainer !== null) {
return $this->bstoreContainer;
}

throw new SpreadsheetException('bstoreContainer is unexpectedly null');
}

/**
* Set BLIP Store Container.
*/
Expand Down