Skip to content

Commit cd2dba0

Browse files
committed
Element inheritance refinements
1 parent 3ef0f41 commit cd2dba0

File tree

8 files changed

+9
-98
lines changed

8 files changed

+9
-98
lines changed

src/PhpWord/Element/AbstractElement.php

-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
namespace PhpOffice\PhpWord\Element;
1111

12-
use PhpOffice\PhpWord\Exception\InvalidImageException;
1312
use PhpOffice\PhpWord\Exception\InvalidObjectException;
1413
use PhpOffice\PhpWord\Media;
1514
use PhpOffice\PhpWord\Style;
@@ -482,7 +481,6 @@ private function checkValidity($method)
482481
'table' => array('section', 'header', 'footer'),
483482
'footnote' => array('section', 'textrun', 'cell'),
484483
'preservetext' => array('header', 'footer', 'cell'),
485-
'relationid' => array('header', 'footer', 'footnote'),
486484
'title' => array('section'),
487485
);
488486
// Special condition, e.g. preservetext can only exists in cell when

src/PhpWord/Element/Image.php

-27
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,6 @@ class Image extends AbstractElement
3232
*/
3333
private $style;
3434

35-
/**
36-
* Image relation ID specific only for DOCX
37-
*
38-
* @var string
39-
*/
40-
private $rId;
41-
4235
/**
4336
* Is watermark
4437
*
@@ -155,26 +148,6 @@ public function getStyle()
155148
return $this->style;
156149
}
157150

158-
/**
159-
* Get image relation ID
160-
*
161-
* @return int
162-
*/
163-
public function getRelationId()
164-
{
165-
return $this->rId;
166-
}
167-
168-
/**
169-
* Set image relation ID
170-
*
171-
* @param int $rId
172-
*/
173-
public function setRelationId($rId)
174-
{
175-
$this->rId = $rId;
176-
}
177-
178151
/**
179152
* Get image source
180153
*

src/PhpWord/Element/Link.php

-27
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,6 @@ class Link extends AbstractElement
3131
*/
3232
private $name;
3333

34-
/**
35-
* Link Relation ID
36-
*
37-
* @var string
38-
*/
39-
private $relationId;
40-
4134
/**
4235
* Font style
4336
*
@@ -71,26 +64,6 @@ public function __construct($linkSrc, $linkName = null, $fontStyle = null, $para
7164
return $this;
7265
}
7366

74-
/**
75-
* Get Link Relation ID
76-
*
77-
* @return int
78-
*/
79-
public function getRelationId()
80-
{
81-
return $this->relationId;
82-
}
83-
84-
/**
85-
* Set Link Relation ID
86-
*
87-
* @param int $rId
88-
*/
89-
public function setRelationId($rId)
90-
{
91-
$this->relationId = $rId;
92-
}
93-
9467
/**
9568
* Get Link source
9669
*

src/PhpWord/Element/Object.php

-27
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,6 @@ class Object extends AbstractElement
3030
*/
3131
private $style;
3232

33-
/**
34-
* Object Relation ID
35-
*
36-
* @var int
37-
*/
38-
private $relationId;
39-
4033
/**
4134
* Image Relation ID
4235
*
@@ -84,26 +77,6 @@ public function getSource()
8477
return $this->source;
8578
}
8679

87-
/**
88-
* Get Object Relation ID
89-
*
90-
* @return int
91-
*/
92-
public function getRelationId()
93-
{
94-
return $this->relationId;
95-
}
96-
97-
/**
98-
* Set Object Relation ID
99-
*
100-
* @param int $rId
101-
*/
102-
public function setRelationId($rId)
103-
{
104-
$this->relationId = $rId;
105-
}
106-
10780
/**
10881
* Get Image Relation ID
10982
*

src/PhpWord/Reader/AbstractReader.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,10 @@ public function canRead($pFilename)
9090
} catch (Exception $e) {
9191
return false;
9292
}
93-
fclose($this->fileHandle);
93+
if (is_resource($this->fileHandle)) {
94+
fclose($this->fileHandle);
95+
}
96+
9497
return true;
9598
}
9699
}

src/PhpWord/Template.php

+5-12
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ public function cloneRow($search, $numberOfClones)
222222
* @param string $blockname
223223
* @param integer $clones
224224
* @param boolean $replace
225-
* @return null
225+
* @return string|null
226226
*/
227227
public function cloneBlock($blockname, $clones = 1, $replace = true)
228228
{
@@ -263,7 +263,6 @@ public function replaceBlock($blockname, $replacement)
263263
* Delete a block of text
264264
*
265265
* @param string $blockname
266-
* @param string $replacement
267266
*/
268267
public function deleteBlock($blockname)
269268
{
@@ -317,7 +316,7 @@ public function saveAs($strFilename)
317316
*
318317
* @param string $documentPartXML
319318
* @param string $search
320-
* @param mixed $replace
319+
* @param string $replace
321320
* @param integer $limit
322321
* @return string
323322
*/
@@ -335,16 +334,10 @@ protected function setValueForPart($documentPartXML, $search, $replace, $limit)
335334
$search = '${' . $search . '}';
336335
}
337336

338-
if (!is_array($replace)) {
339-
if (!String::isUTF8($replace)) {
340-
$replace = utf8_encode($replace);
341-
}
342-
$replace = htmlspecialchars($replace);
343-
} else {
344-
foreach ($replace as $key => $value) {
345-
$replace[$key] = htmlspecialchars($value);
346-
}
337+
if (!String::isUTF8($replace)) {
338+
$replace = utf8_encode($replace);
347339
}
340+
$replace = htmlspecialchars($replace);
348341

349342
$regExpDelim = '/';
350343
$escapedSearch = preg_quote($search, $regExpDelim);

src/PhpWord/Writer/ODText.php

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
use PhpOffice\PhpWord\Exception\Exception;
1313
use PhpOffice\PhpWord\PhpWord;
14-
use PhpOffice\PhpWord\Settings;
1514
use PhpOffice\PhpWord\Writer\ODText\Content;
1615
use PhpOffice\PhpWord\Writer\ODText\Manifest;
1716
use PhpOffice\PhpWord\Writer\ODText\Meta;

src/PhpWord/Writer/ODText/Manifest.php

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
namespace PhpOffice\PhpWord\Writer\ODText;
1111

12-
use PhpOffice\PhpWord\Exception\Exception;
1312
use PhpOffice\PhpWord\PhpWord;
1413

1514
/**

0 commit comments

Comments
 (0)