Skip to content

move from "zendframework/zend-escaper" to "laminas/laminas-escaper" #1795

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
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
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ php:
- 7.1
- 7.2
- 7.3
- 7.4snapshot
- 7.4

matrix:
include:
Expand All @@ -33,7 +33,7 @@ matrix:
- php: 7.0
- php: 7.3
allow_failures:
- php: 7.4snapshot
- php: 7.4

cache:
directories:
Expand Down
1 change: 0 additions & 1 deletion bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* @copyright 2010-2018 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/

$vendorDirPath = realpath(__DIR__ . '/vendor');
if (file_exists($vendorDirPath . '/autoload.php')) {
require $vendorDirPath . '/autoload.php';
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,20 @@
"require": {
"php": "^5.3.3 || ^7.0",
"ext-xml": "*",
"zendframework/zend-escaper": "^2.2",
"laminas/laminas-escaper": "^2.2",
"phpoffice/common": "^0.2.9"
},
"require-dev": {
"ext-zip": "*",
"ext-gd": "*",
"phpunit/phpunit": "^4.8.36 || ^7.0",
"squizlabs/php_codesniffer": "^2.9",
"squizlabs/php_codesniffer": "^2.9 || ^3.5",
"friendsofphp/php-cs-fixer": "^2.2",
"phpmd/phpmd": "2.*",
"phploc/phploc": "2.* || 3.* || 4.*",
"phploc/phploc": "2.* || 3.* || 4.* || 5.*",
"dompdf/dompdf":"0.8.*",
"tecnickcom/tcpdf": "6.*",
"mpdf/mpdf": "5.7.4 || 6.* || 7.*",
"mpdf/mpdf": "5.7.4 || 6.* || 7.* || 8.*",
"php-coveralls/php-coveralls": "1.1.0 || ^2.0"
},
"suggest": {
Expand Down
84 changes: 42 additions & 42 deletions src/PhpWord/Shared/OLERead.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* @copyright 2010-2018 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/

namespace PhpOffice\PhpWord\Shared;

use PhpOffice\PhpWord\Exception\Exception;
Expand All @@ -29,40 +30,37 @@ class OLERead
const IDENTIFIER_OLE = IDENTIFIER_OLE;

// Size of a sector = 512 bytes
const BIG_BLOCK_SIZE = 0x200;
const BIG_BLOCK_SIZE = 0x200;

// Size of a short sector = 64 bytes
const SMALL_BLOCK_SIZE = 0x40;
const SMALL_BLOCK_SIZE = 0x40;

// Size of a directory entry always = 128 bytes
const PROPERTY_STORAGE_BLOCK_SIZE = 0x80;
const PROPERTY_STORAGE_BLOCK_SIZE = 0x80;

// Minimum size of a standard stream = 4096 bytes, streams smaller than this are stored as short streams
const SMALL_BLOCK_THRESHOLD = 0x1000;
const SMALL_BLOCK_THRESHOLD = 0x1000;

// header offsets
const NUM_BIG_BLOCK_DEPOT_BLOCKS_POS = 0x2c;
const ROOT_START_BLOCK_POS = 0x30;
const SMALL_BLOCK_DEPOT_BLOCK_POS = 0x3c;
const EXTENSION_BLOCK_POS = 0x44;
const NUM_EXTENSION_BLOCK_POS = 0x48;
const BIG_BLOCK_DEPOT_BLOCKS_POS = 0x4c;
const NUM_BIG_BLOCK_DEPOT_BLOCKS_POS = 0x2c;
const ROOT_START_BLOCK_POS = 0x30;
const SMALL_BLOCK_DEPOT_BLOCK_POS = 0x3c;
const EXTENSION_BLOCK_POS = 0x44;
const NUM_EXTENSION_BLOCK_POS = 0x48;
const BIG_BLOCK_DEPOT_BLOCKS_POS = 0x4c;

// property storage offsets (directory offsets)
const SIZE_OF_NAME_POS = 0x40;
const TYPE_POS = 0x42;
const START_BLOCK_POS = 0x74;
const SIZE_POS = 0x78;



public $wrkdocument = null;
public $wrk1Table = null;
public $wrkData = null;
public $wrkObjectPool = null;
public $summaryInformation = null;
public $docSummaryInfos = null;

const SIZE_OF_NAME_POS = 0x40;
const TYPE_POS = 0x42;
const START_BLOCK_POS = 0x74;
const SIZE_POS = 0x78;

public $wrkdocument = null;
public $wrk1Table = null;
public $wrkData = null;
public $wrkObjectPool = null;
public $summaryInformation = null;
public $docSummaryInfos = null;

/**
* Read the file
Expand All @@ -75,7 +73,7 @@ public function read($sFileName)
{
// Check if file exists and is readable
if (!is_readable($sFileName)) {
throw new Exception("Could not open " . $sFileName . " for reading! File does not exist, or it is not readable.");
throw new Exception('Could not open ' . $sFileName . ' for reading! File does not exist, or it is not readable.');
}

// Get the file identifier
Expand Down Expand Up @@ -112,7 +110,7 @@ public function read($sFileName)

// @codeCoverageIgnoreStart
if ($this->numExtensionBlocks != 0) {
$bbdBlocks = (self::BIG_BLOCK_SIZE - self::BIG_BLOCK_DEPOT_BLOCKS_POS)/4;
$bbdBlocks = (self::BIG_BLOCK_SIZE - self::BIG_BLOCK_DEPOT_BLOCKS_POS) / 4;
}
// @codeCoverageIgnoreEnd

Expand Down Expand Up @@ -144,8 +142,8 @@ public function read($sFileName)
for ($i = 0; $i < $this->numBigBlockDepotBlocks; ++$i) {
$pos = ($bigBlockDepotBlocks[$i] + 1) * self::BIG_BLOCK_SIZE;

$this->bigBlockChain .= substr($this->data, $pos, 4*$bbs);
$pos += 4*$bbs;
$this->bigBlockChain .= substr($this->data, $pos, 4 * $bbs);
$pos += 4 * $bbs;
}

$pos = 0;
Expand All @@ -154,10 +152,10 @@ public function read($sFileName)
while ($sbdBlock != -2) {
$pos = ($sbdBlock + 1) * self::BIG_BLOCK_SIZE;

$this->smallBlockChain .= substr($this->data, $pos, 4*$bbs);
$pos += 4*$bbs;
$this->smallBlockChain .= substr($this->data, $pos, 4 * $bbs);
$pos += 4 * $bbs;

$sbdBlock = self::getInt4d($this->bigBlockChain, $sbdBlock*4);
$sbdBlock = self::getInt4d($this->bigBlockChain, $sbdBlock * 4);
}

// read the directory stream
Expand All @@ -170,6 +168,7 @@ public function read($sFileName)
/**
* Extract binary stream data
*
* @param mixed $stream
* @return string
*/
public function getStream($stream)
Expand All @@ -189,7 +188,7 @@ public function getStream($stream)
$pos = $block * self::SMALL_BLOCK_SIZE;
$streamData .= substr($rootdata, $pos, self::SMALL_BLOCK_SIZE);

$block = self::getInt4d($this->smallBlockChain, $block*4);
$block = self::getInt4d($this->smallBlockChain, $block * 4);
}

return $streamData;
Expand All @@ -201,15 +200,15 @@ public function getStream($stream)
}

if ($numBlocks == 0) {
return '';// @codeCoverageIgnore
return ''; // @codeCoverageIgnore
}

$block = $this->props[$stream]['startBlock'];

while ($block != -2) {
$pos = ($block + 1) * self::BIG_BLOCK_SIZE;
$streamData .= substr($this->data, $pos, self::BIG_BLOCK_SIZE);
$block = self::getInt4d($this->bigBlockChain, $block*4);
$block = self::getInt4d($this->bigBlockChain, $block * 4);
}

return $streamData;
Expand All @@ -229,8 +228,9 @@ private function readData($blSectorId)
while ($block != -2) {
$pos = ($block + 1) * self::BIG_BLOCK_SIZE;
$data .= substr($this->data, $pos, self::BIG_BLOCK_SIZE);
$block = self::getInt4d($this->bigBlockChain, $block*4);
$block = self::getInt4d($this->bigBlockChain, $block * 4);
}

return $data;
}

Expand All @@ -248,7 +248,7 @@ private function readPropertySets()
$data = substr($this->entry, $offset, self::PROPERTY_STORAGE_BLOCK_SIZE);

// size in bytes of name
$nameSize = ord($data[self::SIZE_OF_NAME_POS]) | (ord($data[self::SIZE_OF_NAME_POS+1]) << 8);
$nameSize = ord($data[self::SIZE_OF_NAME_POS]) | (ord($data[self::SIZE_OF_NAME_POS + 1]) << 8);

// type of entry
$type = ord($data[self::TYPE_POS]);
Expand All @@ -259,14 +259,13 @@ private function readPropertySets()

$size = self::getInt4d($data, self::SIZE_POS);

$name = str_replace("\x00", "", substr($data, 0, $nameSize));
$name = str_replace("\x00", '', substr($data, 0, $nameSize));


$this->props[] = array (
'name' => $name,
'type' => $type,
$this->props[] = array(
'name' => $name,
'type' => $type,
'startBlock' => $startBlock,
'size' => $size);
'size' => $size, );

// tmp helper to simplify checks
$upName = strtoupper($name);
Expand Down Expand Up @@ -318,6 +317,7 @@ private static function getInt4d($data, $pos)
} else {
$ord24 = ($or24 & 127) << 24;
}

return ord($data[$pos]) | (ord($data[$pos + 1]) << 8) | (ord($data[$pos + 2]) << 16) | $ord24;
}
}
4 changes: 2 additions & 2 deletions src/PhpWord/Writer/HTML/Element/AbstractElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@

namespace PhpOffice\PhpWord\Writer\HTML\Element;

use Laminas\Escaper\Escaper;
use PhpOffice\PhpWord\Element\AbstractElement as Element;
use PhpOffice\PhpWord\Writer\AbstractWriter;
use Zend\Escaper\Escaper;

/**
* Abstract HTML element writer
Expand Down Expand Up @@ -50,7 +50,7 @@ abstract class AbstractElement
protected $withoutP = false;

/**
* @var \Zend\Escaper\Escaper|\PhpOffice\PhpWord\Escaper\AbstractEscaper
* @var \Laminas\Escaper\Escaper|\PhpOffice\PhpWord\Escaper\AbstractEscaper
*/
protected $escaper;

Expand Down
4 changes: 2 additions & 2 deletions src/PhpWord/Writer/HTML/Part/AbstractPart.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@

namespace PhpOffice\PhpWord\Writer\HTML\Part;

use Laminas\Escaper\Escaper;
use PhpOffice\PhpWord\Exception\Exception;
use PhpOffice\PhpWord\Writer\AbstractWriter;
use Zend\Escaper\Escaper;

/**
* @since 0.11.0
Expand All @@ -32,7 +32,7 @@ abstract class AbstractPart
private $parentWriter;

/**
* @var \Zend\Escaper\Escaper
* @var \Laminas\Escaper\Escaper
*/
protected $escaper;

Expand Down