Skip to content

Commit e0df640

Browse files
committed
move from "zendframework/zend-escaper" to "laminas/laminas-escaper" due to Zend Framework migration
1 parent 733f845 commit e0df640

File tree

5 files changed

+47
-48
lines changed

5 files changed

+47
-48
lines changed

bootstrap.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
* @copyright 2010-2018 PHPWord contributors
1515
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
1616
*/
17-
1817
$vendorDirPath = realpath(__DIR__ . '/vendor');
1918
if (file_exists($vendorDirPath . '/autoload.php')) {
2019
require $vendorDirPath . '/autoload.php';

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
"require": {
6161
"php": "^5.3.3 || ^7.0",
6262
"ext-xml": "*",
63-
"zendframework/zend-escaper": "^2.2",
63+
"laminas/laminas-escaper": "^2.2",
6464
"phpoffice/common": "^0.2.9"
6565
},
6666
"require-dev": {

src/PhpWord/Shared/OLERead.php

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* @copyright 2010-2018 PHPWord contributors
1515
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
1616
*/
17+
1718
namespace PhpOffice\PhpWord\Shared;
1819

1920
use PhpOffice\PhpWord\Exception\Exception;
@@ -29,40 +30,37 @@ class OLERead
2930
const IDENTIFIER_OLE = IDENTIFIER_OLE;
3031

3132
// Size of a sector = 512 bytes
32-
const BIG_BLOCK_SIZE = 0x200;
33+
const BIG_BLOCK_SIZE = 0x200;
3334

3435
// Size of a short sector = 64 bytes
35-
const SMALL_BLOCK_SIZE = 0x40;
36+
const SMALL_BLOCK_SIZE = 0x40;
3637

3738
// Size of a directory entry always = 128 bytes
38-
const PROPERTY_STORAGE_BLOCK_SIZE = 0x80;
39+
const PROPERTY_STORAGE_BLOCK_SIZE = 0x80;
3940

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

4344
// header offsets
44-
const NUM_BIG_BLOCK_DEPOT_BLOCKS_POS = 0x2c;
45-
const ROOT_START_BLOCK_POS = 0x30;
46-
const SMALL_BLOCK_DEPOT_BLOCK_POS = 0x3c;
47-
const EXTENSION_BLOCK_POS = 0x44;
48-
const NUM_EXTENSION_BLOCK_POS = 0x48;
49-
const BIG_BLOCK_DEPOT_BLOCKS_POS = 0x4c;
45+
const NUM_BIG_BLOCK_DEPOT_BLOCKS_POS = 0x2c;
46+
const ROOT_START_BLOCK_POS = 0x30;
47+
const SMALL_BLOCK_DEPOT_BLOCK_POS = 0x3c;
48+
const EXTENSION_BLOCK_POS = 0x44;
49+
const NUM_EXTENSION_BLOCK_POS = 0x48;
50+
const BIG_BLOCK_DEPOT_BLOCKS_POS = 0x4c;
5051

5152
// property storage offsets (directory offsets)
52-
const SIZE_OF_NAME_POS = 0x40;
53-
const TYPE_POS = 0x42;
54-
const START_BLOCK_POS = 0x74;
55-
const SIZE_POS = 0x78;
56-
57-
58-
59-
public $wrkdocument = null;
60-
public $wrk1Table = null;
61-
public $wrkData = null;
62-
public $wrkObjectPool = null;
63-
public $summaryInformation = null;
64-
public $docSummaryInfos = null;
65-
53+
const SIZE_OF_NAME_POS = 0x40;
54+
const TYPE_POS = 0x42;
55+
const START_BLOCK_POS = 0x74;
56+
const SIZE_POS = 0x78;
57+
58+
public $wrkdocument = null;
59+
public $wrk1Table = null;
60+
public $wrkData = null;
61+
public $wrkObjectPool = null;
62+
public $summaryInformation = null;
63+
public $docSummaryInfos = null;
6664

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

8179
// Get the file identifier
@@ -112,7 +110,7 @@ public function read($sFileName)
112110

113111
// @codeCoverageIgnoreStart
114112
if ($this->numExtensionBlocks != 0) {
115-
$bbdBlocks = (self::BIG_BLOCK_SIZE - self::BIG_BLOCK_DEPOT_BLOCKS_POS)/4;
113+
$bbdBlocks = (self::BIG_BLOCK_SIZE - self::BIG_BLOCK_DEPOT_BLOCKS_POS) / 4;
116114
}
117115
// @codeCoverageIgnoreEnd
118116

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

147-
$this->bigBlockChain .= substr($this->data, $pos, 4*$bbs);
148-
$pos += 4*$bbs;
145+
$this->bigBlockChain .= substr($this->data, $pos, 4 * $bbs);
146+
$pos += 4 * $bbs;
149147
}
150148

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

157-
$this->smallBlockChain .= substr($this->data, $pos, 4*$bbs);
158-
$pos += 4*$bbs;
155+
$this->smallBlockChain .= substr($this->data, $pos, 4 * $bbs);
156+
$pos += 4 * $bbs;
159157

160-
$sbdBlock = self::getInt4d($this->bigBlockChain, $sbdBlock*4);
158+
$sbdBlock = self::getInt4d($this->bigBlockChain, $sbdBlock * 4);
161159
}
162160

163161
// read the directory stream
@@ -170,6 +168,7 @@ public function read($sFileName)
170168
/**
171169
* Extract binary stream data
172170
*
171+
* @param mixed $stream
173172
* @return string
174173
*/
175174
public function getStream($stream)
@@ -189,7 +188,7 @@ public function getStream($stream)
189188
$pos = $block * self::SMALL_BLOCK_SIZE;
190189
$streamData .= substr($rootdata, $pos, self::SMALL_BLOCK_SIZE);
191190

192-
$block = self::getInt4d($this->smallBlockChain, $block*4);
191+
$block = self::getInt4d($this->smallBlockChain, $block * 4);
193192
}
194193

195194
return $streamData;
@@ -201,15 +200,15 @@ public function getStream($stream)
201200
}
202201

203202
if ($numBlocks == 0) {
204-
return '';// @codeCoverageIgnore
203+
return ''; // @codeCoverageIgnore
205204
}
206205

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

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

215214
return $streamData;
@@ -229,8 +228,9 @@ private function readData($blSectorId)
229228
while ($block != -2) {
230229
$pos = ($block + 1) * self::BIG_BLOCK_SIZE;
231230
$data .= substr($this->data, $pos, self::BIG_BLOCK_SIZE);
232-
$block = self::getInt4d($this->bigBlockChain, $block*4);
231+
$block = self::getInt4d($this->bigBlockChain, $block * 4);
233232
}
233+
234234
return $data;
235235
}
236236

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

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

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

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

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

264-
265-
$this->props[] = array (
266-
'name' => $name,
267-
'type' => $type,
264+
$this->props[] = array(
265+
'name' => $name,
266+
'type' => $type,
268267
'startBlock' => $startBlock,
269-
'size' => $size);
268+
'size' => $size, );
270269

271270
// tmp helper to simplify checks
272271
$upName = strtoupper($name);
@@ -318,6 +317,7 @@ private static function getInt4d($data, $pos)
318317
} else {
319318
$ord24 = ($or24 & 127) << 24;
320319
}
320+
321321
return ord($data[$pos]) | (ord($data[$pos + 1]) << 8) | (ord($data[$pos + 2]) << 16) | $ord24;
322322
}
323323
}

src/PhpWord/Writer/HTML/Element/AbstractElement.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717

1818
namespace PhpOffice\PhpWord\Writer\HTML\Element;
1919

20+
use Laminas\Escaper\Escaper;
2021
use PhpOffice\PhpWord\Element\AbstractElement as Element;
2122
use PhpOffice\PhpWord\Writer\AbstractWriter;
22-
use Zend\Escaper\Escaper;
2323

2424
/**
2525
* Abstract HTML element writer
@@ -50,7 +50,7 @@ abstract class AbstractElement
5050
protected $withoutP = false;
5151

5252
/**
53-
* @var \Zend\Escaper\Escaper|\PhpOffice\PhpWord\Escaper\AbstractEscaper
53+
* @var \Laminas\Escaper\Escaper|\PhpOffice\PhpWord\Escaper\AbstractEscaper
5454
*/
5555
protected $escaper;
5656

src/PhpWord/Writer/HTML/Part/AbstractPart.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717

1818
namespace PhpOffice\PhpWord\Writer\HTML\Part;
1919

20+
use Laminas\Escaper\Escaper;
2021
use PhpOffice\PhpWord\Exception\Exception;
2122
use PhpOffice\PhpWord\Writer\AbstractWriter;
22-
use Zend\Escaper\Escaper;
2323

2424
/**
2525
* @since 0.11.0
@@ -32,7 +32,7 @@ abstract class AbstractPart
3232
private $parentWriter;
3333

3434
/**
35-
* @var \Zend\Escaper\Escaper
35+
* @var \Laminas\Escaper\Escaper
3636
*/
3737
protected $escaper;
3838

0 commit comments

Comments
 (0)