Skip to content

Commit 71b625a

Browse files
committed
Update: Code conventions for PHP 8.x & Update: .gitignore to include composer.lock (in support of PR PHPOffice#2722 : Autoload)
1 parent 514c210 commit 71b625a

File tree

13 files changed

+50
-40
lines changed

13 files changed

+50
-40
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ _build
1212
/build
1313
phpunit.xml
1414
composer.phar
15+
composer.lock
1516
vendor
1617
/report
1718
/build

src/PhpWord/IOFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ abstract class IOFactory
3636
*/
3737
public static function createWriter(PhpWord $phpWord, $name = 'Word2007')
3838
{
39-
if ($name !== 'WriterInterface' && !in_array($name, ['ODText', 'RTF', 'Word2007', 'HTML', 'PDF', 'EPUB'], true)) {
39+
if ($name !== 'WriterInterface' && !in_array($name, ['ODText', 'RTF', 'Word2007', 'HTML', 'PDF', 'EPub3'], true)) {
4040
throw new Exception("\"{$name}\" is not a valid writer.");
4141
}
4242

src/PhpWord/Writer/ePub3.php renamed to src/PhpWord/Writer/EPub3.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* This file is part of PHPWord - A pure PHP library for reading and writing
45
* word processing documents.
@@ -19,17 +20,15 @@
1920

2021
use PhpOffice\PhpWord\Media;
2122
use PhpOffice\PhpWord\PhpWord;
22-
use PhpOffice\PhpWord\Writer\ePub3\Part\AbstractPart;
23+
use PhpOffice\PhpWord\Writer\EPub3\Part\AbstractPart;
2324

2425
/**
25-
* ePub3 writer.
26+
* EPub3 writer.
2627
*/
27-
class ePub3 extends AbstractWriter implements WriterInterface
28+
class EPub3 extends AbstractWriter implements WriterInterface
2829
{
2930
/**
30-
* Create new ePub3 writer.
31-
*
32-
* @param \PhpOffice\PhpWord\PhpWord
31+
* Create new EPub3 writer.
3332
*/
3433
public function __construct(?PhpWord $phpWord = null)
3534
{
@@ -47,7 +46,7 @@ public function __construct(?PhpWord $phpWord = null)
4746
foreach (array_keys($this->parts) as $partName) {
4847
$partClass = static::class . '\\Part\\' . $partName;
4948
if (class_exists($partClass)) {
50-
/** @var \PhpOffice\PhpWord\Writer\ePub3\Part\AbstractPart $partObject Type hint */
49+
/** @var AbstractPart $partObject Type hint */
5150
$partObject = new $partClass();
5251
$partObject->setParentWriter($this);
5352
$this->writerParts[strtolower($partName)] = $partObject;

src/PhpWord/Writer/ePub3/Part/AbstractPart.php renamed to src/PhpWord/Writer/EPub3/Part/AbstractPart.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* This file is part of PHPWord - A pure PHP library for reading and writing
45
* word processing documents.
@@ -15,19 +16,19 @@
1516
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
1617
*/
1718

18-
namespace PhpOffice\PhpWord\Writer\ePub3\Part;
19+
namespace PhpOffice\PhpWord\Writer\EPub3\Part;
1920

2021
use PhpOffice\PhpWord\Writer\AbstractWriter;
2122

2223
/**
23-
* Abstract class for ePub3 parts.
24+
* Abstract class for EPub3 parts.
2425
*/
2526
abstract class AbstractPart
2627
{
2728
/**
2829
* Parent writer.
2930
*
30-
* @var \PhpOffice\PhpWord\Writer\AbstractWriter
31+
* @var AbstractWriter
3132
*/
3233
protected $parentWriter;
3334

@@ -46,7 +47,7 @@ public function setParentWriter(AbstractWriter $writer)
4647
/**
4748
* Get parent writer.
4849
*
49-
* @return \PhpOffice\PhpWord\Writer\AbstractWriter
50+
* @return AbstractWriter
5051
*/
5152
public function getParentWriter()
5253
{

src/PhpWord/Writer/ePub3/Part/Content.php renamed to src/PhpWord/Writer/EPub3/Part/Content.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* This file is part of PHPWord - A pure PHP library for reading and writing
45
* word processing documents.
@@ -15,10 +16,10 @@
1516
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
1617
*/
1718

18-
namespace PhpOffice\PhpWord\Writer\ePub3\Part;
19+
namespace PhpOffice\PhpWord\Writer\EPub3\Part;
1920

2021
/**
21-
* Class for ePub3 content part.
22+
* Class for EPub3 content part.
2223
*/
2324
class Content extends AbstractPart
2425
{
@@ -32,7 +33,7 @@ public function write()
3233
$content = '<?xml version="1.0" encoding="UTF-8"?>';
3334
$content .= '<package xmlns="http://www.idpf.org/2007/opf" version="3.0">';
3435
$content .= '<metadata xmlns:dc="http://purl.org/dc/elements/1.1/">';
35-
$content .= '<dc:title>Sample ePub3 Document</dc:title>';
36+
$content .= '<dc:title>Sample EPub3 Document</dc:title>';
3637
$content .= '<dc:language>en</dc:language>';
3738
$content .= '</metadata>';
3839
$content .= '<manifest>';

src/PhpWord/Writer/ePub3/Part/Manifest.php renamed to src/PhpWord/Writer/EPub3/Part/Manifest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* This file is part of PHPWord - A pure PHP library for reading and writing
45
* word processing documents.
@@ -15,10 +16,10 @@
1516
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
1617
*/
1718

18-
namespace PhpOffice\PhpWord\Writer\ePub3\Part;
19+
namespace PhpOffice\PhpWord\Writer\EPub3\Part;
1920

2021
/**
21-
* Class for ePub3 manifest part.
22+
* Class for EPub3 manifest part.
2223
*/
2324
class Manifest extends AbstractPart
2425
{

src/PhpWord/Writer/ePub3/Part/Meta.php renamed to src/PhpWord/Writer/EPub3/Part/Meta.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* This file is part of PHPWord - A pure PHP library for reading and writing
45
* word processing documents.
@@ -15,10 +16,10 @@
1516
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
1617
*/
1718

18-
namespace PhpOffice\PhpWord\Writer\ePub3\Part;
19+
namespace PhpOffice\PhpWord\Writer\EPub3\Part;
1920

2021
/**
21-
* Class for ePub3 metadata part.
22+
* Class for EPub3 metadata part.
2223
*/
2324
class Meta extends AbstractPart
2425
{
@@ -31,7 +32,7 @@ public function write()
3132
{
3233
$content = '<?xml version="1.0" encoding="UTF-8"?>';
3334
$content .= '<metadata xmlns="http://www.idpf.org/2007/opf">';
34-
$content .= '<dc:title>Sample ePub3 Document</dc:title>';
35+
$content .= '<dc:title>Sample EPub3 Document</dc:title>';
3536
$content .= '<dc:language>en</dc:language>';
3637
$content .= '<dc:identifier id="bookid">urn:uuid:12345</dc:identifier>';
3738
$content .= '<meta property="dcterms:modified">2023-01-01T00:00:00Z</meta>';

src/PhpWord/Writer/ePub3/Part/Mimetype.php renamed to src/PhpWord/Writer/EPub3/Part/Mimetype.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* This file is part of PHPWord - A pure PHP library for reading and writing
45
* word processing documents.
@@ -15,10 +16,10 @@
1516
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
1617
*/
1718

18-
namespace PhpOffice\PhpWord\Writer\ePub3\Part;
19+
namespace PhpOffice\PhpWord\Writer\EPub3\Part;
1920

2021
/**
21-
* Class for ePub3 mimetype part.
22+
* Class for EPub3 mimetype part.
2223
*/
2324
class Mimetype extends AbstractPart
2425
{

src/PhpWord/Writer/ePub3/Style/AbstractStyle.php renamed to src/PhpWord/Writer/EPub3/Style/AbstractStyle.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* This file is part of PHPWord - A pure PHP library for reading and writing
45
* word processing documents.
@@ -15,19 +16,19 @@
1516
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
1617
*/
1718

18-
namespace PhpOffice\PhpWord\Writer\ePub3\Style;
19+
namespace PhpOffice\PhpWord\Writer\EPub3\Style;
1920

2021
use PhpOffice\PhpWord\Writer\AbstractWriter;
2122

2223
/**
23-
* Abstract class for ePub3 styles.
24+
* Abstract class for EPub3 styles.
2425
*/
2526
abstract class AbstractStyle
2627
{
2728
/**
2829
* Parent writer.
2930
*
30-
* @var \PhpOffice\PhpWord\Writer\AbstractWriter
31+
* @var AbstractWriter
3132
*/
3233
protected $parentWriter;
3334

@@ -46,7 +47,7 @@ public function setParentWriter(AbstractWriter $writer)
4647
/**
4748
* Get parent writer.
4849
*
49-
* @return \PhpOffice\PhpWord\Writer\AbstractWriter
50+
* @return AbstractWriter
5051
*/
5152
public function getParentWriter()
5253
{

src/PhpWord/Writer/ePub3/Style/Font.php renamed to src/PhpWord/Writer/EPub3/Style/Font.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* This file is part of PHPWord - A pure PHP library for reading and writing
45
* word processing documents.
@@ -15,10 +16,10 @@
1516
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
1617
*/
1718

18-
namespace PhpOffice\PhpWord\Writer\ePub3\Style;
19+
namespace PhpOffice\PhpWord\Writer\EPub3\Style;
1920

2021
/**
21-
* Class for ePub3 font styles.
22+
* Class for EPub3 font styles.
2223
*/
2324
class Font extends AbstractStyle
2425
{

src/PhpWord/Writer/ePub3/Style/Paragraph.php renamed to src/PhpWord/Writer/EPub3/Style/Paragraph.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* This file is part of PHPWord - A pure PHP library for reading and writing
45
* word processing documents.
@@ -15,10 +16,10 @@
1516
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
1617
*/
1718

18-
namespace PhpOffice\PhpWord\Writer\ePub3\Style;
19+
namespace PhpOffice\PhpWord\Writer\EPub3\Style;
1920

2021
/**
21-
* Class for ePub3 paragraph styles.
22+
* Class for EPub3 paragraph styles.
2223
*/
2324
class Paragraph extends AbstractStyle
2425
{

src/PhpWord/Writer/ePub3/Style/Table.php renamed to src/PhpWord/Writer/EPub3/Style/Table.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* This file is part of PHPWord - A pure PHP library for reading and writing
45
* word processing documents.
@@ -15,10 +16,10 @@
1516
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
1617
*/
1718

18-
namespace PhpOffice\PhpWord\Writer\ePub3\Style;
19+
namespace PhpOffice\PhpWord\Writer\EPub3\Style;
1920

2021
/**
21-
* Class for ePub3 table styles.
22+
* Class for EPub3 table styles.
2223
*/
2324
class Table extends AbstractStyle
2425
{

tests/PhpWordTests/Writer/ePub3Test.php renamed to tests/PhpWordTests/Writer/EPub3Test.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* This file is part of PHPWord - A pure PHP library for reading and writing
45
* word processing documents.
@@ -19,21 +20,21 @@
1920

2021
use PhpOffice\PhpWord\PhpWord;
2122
use PhpOffice\PhpWord\SimpleType\Jc;
22-
use PhpOffice\PhpWord\Writer\ePub3;
23+
use PhpOffice\PhpWord\Writer\EPub3;
2324

2425
/**
2526
* Test class for PhpOffice\PhpWord\Writer\Epub3.
2627
*
2728
* @runTestsInSeparateProcesses
2829
*/
29-
class ePub3Test extends \PHPUnit\Framework\TestCase
30+
class EPub3Test extends \PHPUnit\Framework\TestCase
3031
{
3132
/**
3233
* Test document construction.
3334
*/
3435
public function testConstruct(): void
3536
{
36-
$object = new ePub3(new PhpWord());
37+
$object = new EPub3(new PhpWord());
3738
self::assertInstanceOf(PhpWord::class, $object->getPhpWord());
3839
self::assertEquals('./', $object->getDiskCachingDirectory());
3940
foreach (['Content', 'Manifest', 'Mimetype'] as $part) {
@@ -55,7 +56,7 @@ public function testConstructWithNull(): void
5556
{
5657
$this->expectException(\PhpOffice\PhpWord\Exception\Exception::class);
5758
$this->expectExceptionMessage('No PhpWord assigned.');
58-
$object = new ePub3();
59+
$object = new EPub3();
5960
$object->getPhpWord();
6061
}
6162

@@ -76,7 +77,7 @@ public function testSave(): void
7677
$section->addTitle('Test', 1);
7778
$section->addPageBreak();
7879
$section->addImage($imageSrc);
79-
$writer = new ePub3($phpWord);
80+
$writer = new EPub3($phpWord);
8081
$writer->save($file);
8182
self::assertFileExists($file);
8283
unlink($file);
@@ -90,7 +91,7 @@ public function testSavePhpOutput(): void
9091
$phpWord = new PhpWord();
9192
$section = $phpWord->addSection();
9293
$section->addText('Test');
93-
$writer = new ePub3($phpWord);
94+
$writer = new EPub3($phpWord);
9495
ob_start();
9596
$writer->save('php://output');
9697
$contents = ob_get_contents();
@@ -103,7 +104,7 @@ public function testSavePhpOutput(): void
103104
*/
104105
public function testSetGetUseDiskCaching(): void
105106
{
106-
$object = new ePub3();
107+
$object = new EPub3();
107108
$object->setUseDiskCaching(true, PHPWORD_TESTS_BASE_DIR);
108109
self::assertTrue($object->isUseDiskCaching());
109110
self::assertEquals(PHPWORD_TESTS_BASE_DIR, $object->getDiskCachingDirectory());
@@ -117,7 +118,7 @@ public function testSetUseDiskCachingException(): void
117118
$this->expectException(\PhpOffice\PhpWord\Exception\Exception::class);
118119
$dir = implode(DIRECTORY_SEPARATOR, [PHPWORD_TESTS_BASE_DIR, 'foo']);
119120

120-
$object = new ePub3();
121+
$object = new EPub3();
121122
$object->setUseDiskCaching(true, $dir);
122123
}
123124
}

0 commit comments

Comments
 (0)