diff --git a/src/PhpWord/Shared/ZipArchive.php b/src/PhpWord/Shared/ZipArchive.php index 7ef0889e..46d5c036 100644 --- a/src/PhpWord/Shared/ZipArchive.php +++ b/src/PhpWord/Shared/ZipArchive.php @@ -170,6 +170,8 @@ class ZipArchive $list = $this->zip->listContent(); $listCount = count($list); $listIndex = -1; + $contents = null; + for ($i = 0; $i < $listCount; ++$i) { if (strtolower($list[$i]["filename"]) == strtolower($fileName) || strtolower($list[$i]["stored_filename"]) == strtolower($fileName)) { diff --git a/src/PhpWord/Writer/ODText/Content.php b/src/PhpWord/Writer/ODText/Content.php index 0669bc41..7fc0d2df 100644 --- a/src/PhpWord/Writer/ODText/Content.php +++ b/src/PhpWord/Writer/ODText/Content.php @@ -39,6 +39,10 @@ class Content extends WriterPart */ public function writeContent(PhpWord $phpWord = null) { + if (is_null($phpWord)) { + throw new Exception("No PhpWord assigned."); + } + // Create XML writer $xmlWriter = $this->getXmlWriter(); diff --git a/src/PhpWord/Writer/ODText/Meta.php b/src/PhpWord/Writer/ODText/Meta.php index d0d593e2..fc5314e9 100644 --- a/src/PhpWord/Writer/ODText/Meta.php +++ b/src/PhpWord/Writer/ODText/Meta.php @@ -24,6 +24,10 @@ class Meta extends WriterPart */ public function writeMeta(PhpWord $phpWord = null) { + if (is_null($phpWord)) { + throw new Exception("No PhpWord assigned."); + } + // Create XML writer $xmlWriter = $this->getXmlWriter(); diff --git a/src/PhpWord/Writer/ODText/Styles.php b/src/PhpWord/Writer/ODText/Styles.php index fa81ea9e..8839f568 100644 --- a/src/PhpWord/Writer/ODText/Styles.php +++ b/src/PhpWord/Writer/ODText/Styles.php @@ -28,6 +28,10 @@ class Styles extends WriterPart */ public function writeStyles(PhpWord $phpWord = null) { + if (is_null($phpWord)) { + throw new Exception("No PhpWord assigned."); + } + // Create XML writer $xmlWriter = $this->getXmlWriter(); diff --git a/src/PhpWord/Writer/Word2007/ContentTypes.php b/src/PhpWord/Writer/Word2007/ContentTypes.php index 9e6853d0..9a383e9b 100755 --- a/src/PhpWord/Writer/Word2007/ContentTypes.php +++ b/src/PhpWord/Writer/Word2007/ContentTypes.php @@ -66,12 +66,10 @@ class ContentTypes extends WriterPart $xmlWriter->startDocument('1.0', 'UTF-8', 'yes'); $xmlWriter->startElement('Types'); $xmlWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/content-types'); - foreach ($defaults as $key => $value) - { + foreach ($defaults as $key => $value) { $this->writeContentType($xmlWriter, true, $key, $value); } - foreach ($overrides as $key => $value) - { + foreach ($overrides as $key => $value) { $this->writeContentType($xmlWriter, false, $key, $value); } $xmlWriter->endElement(); diff --git a/src/PhpWord/Writer/Word2007/DocProps.php b/src/PhpWord/Writer/Word2007/DocProps.php index ceb5db04..cfa238e5 100644 --- a/src/PhpWord/Writer/Word2007/DocProps.php +++ b/src/PhpWord/Writer/Word2007/DocProps.php @@ -21,6 +21,10 @@ class DocProps extends WriterPart */ public function writeDocPropsApp(PhpWord $phpWord = null) { + if (is_null($phpWord)) { + throw new Exception("No PhpWord assigned."); + } + // Create XML writer $xmlWriter = $this->getXmlWriter(); diff --git a/src/PhpWord/Writer/Word2007/Document.php b/src/PhpWord/Writer/Word2007/Document.php index 8bf46a0b..499aad19 100644 --- a/src/PhpWord/Writer/Word2007/Document.php +++ b/src/PhpWord/Writer/Word2007/Document.php @@ -28,6 +28,10 @@ class Document extends Base */ public function writeDocument(PhpWord $phpWord = null) { + if (is_null($phpWord)) { + throw new Exception("No PhpWord assigned."); + } + // Create XML writer $xmlWriter = $this->getXmlWriter();