Skip to content

Commit 0e8bcb6

Browse files
committed
Drop PHP 7.3 and older
This is according to our formal, published, policy to only support eol PHP after 6 months within PHPOffice organisation. See https://phpspreadsheet.readthedocs.io/en/latest/#php-version-support
1 parent 2ee6df6 commit 0e8bcb6

File tree

11 files changed

+17
-116
lines changed

11 files changed

+17
-116
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ jobs:
88
strategy:
99
matrix:
1010
php-version:
11-
- '7.2'
12-
- "7.3"
1311
- "7.4"
1412
- "8.0"
1513
- "8.1"

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Read more about PHPWord:
3232

3333
## Features
3434

35-
With PHPWord, you can create OOXML, ODF, or RTF documents dynamically using your PHP 5.3.3+ scripts. Below are some of the things that you can do with PHPWord library:
35+
With PHPWord, you can create OOXML, ODF, or RTF documents dynamically using your PHP scripts. Below are some of the things that you can do with PHPWord library:
3636

3737
- Set document properties, e.g. title, subject, and creator.
3838
- Create document sections with different settings, e.g. portrait/landscape, page size, and page numbering
@@ -60,7 +60,7 @@ With PHPWord, you can create OOXML, ODF, or RTF documents dynamically using your
6060

6161
PHPWord requires the following:
6262

63-
- PHP 5.3.3+
63+
- PHP 7.4+
6464
- [XML Parser extension](http://www.php.net/manual/en/xml.installation.php)
6565
- [Laminas Escaper component](https://docs.laminas.dev/laminas-escaper/intro/)
6666
- [Zip extension](http://php.net/manual/en/book.zip.php) (optional, used to write OOXML and ODF)

composer.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,10 @@
5858
"fix": "Fixes issues found by PHP-CS"
5959
},
6060
"require": {
61-
"php": "^5.3.3 || ^7.0 || ^8.0",
61+
"php": "^7.4 || ^8.0",
6262
"ext-xml": "*",
63-
"laminas/laminas-escaper": "^2.2"
63+
"laminas/laminas-escaper": "^2.2",
64+
"symfony/process": "^5.4"
6465
},
6566
"require-dev": {
6667
"ext-zip": "*",
@@ -71,7 +72,7 @@
7172
"phpmd/phpmd": "2.*",
7273
"phploc/phploc": "2.* || 3.* || 4.* || 5.* || 6.* || 7.*",
7374
"dompdf/dompdf":"0.8.* || 1.0.*",
74-
"tecnickcom/tcpdf": "6.*",
75+
"tecnickcom/tcpdf": "^6.4",
7576
"mpdf/mpdf": "5.7.4 || 6.* || 7.* || 8.*",
7677
"php-coveralls/php-coveralls": "1.1.0 || ^2.0"
7778
},

docs/faq.rst

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,3 @@ Frequently asked questions
66
How contribute to PHPWord?
77
--------------------------
88
- Improve the documentation (`Sphinx Format <http://documentation-style-guide-sphinx.readthedocs.org/en/latest/index.html>`__)
9-
10-
Is this the same with PHPWord that I found in CodePlex?
11-
-------------------------------------------------------
12-
13-
No. This one is much better with tons of new features that you can’t
14-
find in PHPWord 0.6.3. The development in CodePlex is halted and
15-
switched to GitHub to allow more participation from the crowd. The more
16-
the merrier, right?
17-
18-
I’ve been running PHPWord from CodePlex flawlessly, but I can’t use the latest PHPWord from GitHub. Why?
19-
--------------------------------------------------------------------------------------------------------
20-
21-
PHPWord requires PHP 5.3+ since 0.8, while PHPWord 0.6.3 from CodePlex
22-
can run with PHP 5.2. There’s a lot of new features that we can get from
23-
PHP 5.3 and it’s been around since 2009! You should upgrade your PHP
24-
version to use PHPWord 0.8+.

docs/installing.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ Requirements
88

99
Mandatory:
1010

11-
- PHP 5.3.3+
11+
- composer
12+
- PHP 7.4+
1213
- `XML Parser <http://www.php.net/manual/en/xml.installation.php>`__ extension
13-
- `Laminas Escaper <https://docs.laminas.dev/laminas-escaper/intro/>`__ component
1414

1515
Optional:
1616

samples/index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
use PhpOffice\PhpWord\Settings;
55

66
$requirements = array(
7-
'php' => array('PHP 5.3.3', version_compare(PHP_VERSION, '5.3.3', '>=')),
7+
'php' => array('PHP 7.4', version_compare(PHP_VERSION, '7.4', '>=')),
88
'xml' => array('PHP extension XML', extension_loaded('xml')),
99
'temp' => array('Temp folder "<code>' . Settings::getTempDir() . '</code>" is writable', is_writable(Settings::getTempDir())),
1010
'zip' => array('PHP extension ZipArchive (optional)', extension_loaded('zip')),

src/PhpWord/Element/Image.php

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ private function checkImage()
410410
if ($this->sourceType == self::SOURCE_ARCHIVE) {
411411
$imageData = $this->getArchiveImageSize($this->source);
412412
} elseif ($this->sourceType == self::SOURCE_STRING) {
413-
$imageData = $this->getStringImageSize($this->source);
413+
$imageData = @getimagesizefromstring($this->source);
414414
} else {
415415
$imageData = @getimagesize($this->source);
416416
}
@@ -501,26 +501,6 @@ private function getArchiveImageSize($source)
501501
return $imageData;
502502
}
503503

504-
/**
505-
* get image size from string
506-
*
507-
* @param string $source
508-
*
509-
* @codeCoverageIgnore this method is just a replacement for getimagesizefromstring which exists only as of PHP 5.4
510-
*/
511-
private function getStringImageSize($source)
512-
{
513-
$result = false;
514-
if (!function_exists('getimagesizefromstring')) {
515-
$uri = 'data://application/octet-stream;base64,' . base64_encode($source);
516-
$result = @getimagesize($uri);
517-
} else {
518-
$result = @getimagesizefromstring($source);
519-
}
520-
521-
return $result;
522-
}
523-
524504
/**
525505
* Set image functions and extensions.
526506
*/

src/PhpWord/Escaper/Xml.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ class Xml extends AbstractEscaper
2626
{
2727
protected function escapeSingleValue($input)
2828
{
29-
// todo: omit encoding parameter after migration onto PHP 5.4
30-
return (!is_null($input)) ? htmlspecialchars($input, ENT_QUOTES, 'UTF-8') : '';
29+
return (!is_null($input)) ? htmlspecialchars($input, ENT_QUOTES) : '';
3130
}
3231
}

src/PhpWord/Shared/PCLZip/pclzip.lib.php

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3258,17 +3258,6 @@ public function privExtractByRule(&$p_file_list, $p_path, $p_remove_path, $p_rem
32583258
$v_extract = true;
32593259
}
32603260
}
3261-
// ----- Look for extract by ereg rule
3262-
// ereg() is deprecated with PHP 5.3
3263-
/*
3264-
elseif ( (isset($p_options[PCLZIP_OPT_BY_EREG]))
3265-
&& ($p_options[PCLZIP_OPT_BY_EREG] != "")) {
3266-
3267-
if (ereg($p_options[PCLZIP_OPT_BY_EREG], $v_header['stored_filename'])) {
3268-
$v_extract = true;
3269-
}
3270-
}
3271-
*/
32723261

32733262
// ----- Look for extract by preg rule
32743263
} elseif ((isset($p_options[PCLZIP_OPT_BY_PREG])) && ($p_options[PCLZIP_OPT_BY_PREG] != "")) {
@@ -4545,18 +4534,6 @@ public function privDeleteByRule(&$p_result_list, &$p_options)
45454534
}
45464535
}
45474536

4548-
// ----- Look for extract by ereg rule
4549-
// ereg() is deprecated with PHP 5.3
4550-
/*
4551-
elseif ( (isset($p_options[PCLZIP_OPT_BY_EREG]))
4552-
&& ($p_options[PCLZIP_OPT_BY_EREG] != "")) {
4553-
4554-
if (ereg($p_options[PCLZIP_OPT_BY_EREG], $v_header_list[$v_nb_extracted]['stored_filename'])) {
4555-
$v_found = true;
4556-
}
4557-
}
4558-
*/
4559-
45604537
// ----- Look for extract by preg rule
45614538
} elseif ((isset($p_options[PCLZIP_OPT_BY_PREG])) && ($p_options[PCLZIP_OPT_BY_PREG] != "")) {
45624539

tests/PhpWord/Writer/PDF/TCPDFTest.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,6 @@ class TCPDFTest extends \PHPUnit\Framework\TestCase
3333
*/
3434
public function testConstruct()
3535
{
36-
// TCPDF version 6.3.5 doesn't support PHP 5.3, fixed via https://github.com/tecnickcom/TCPDF/pull/197,
37-
// pending new release.
38-
if (version_compare(PHP_VERSION, '5.4.0', '<')) {
39-
return;
40-
}
41-
42-
// TCPDF version 6.3.5 doesn't support PHP 8.0, fixed via https://github.com/tecnickcom/TCPDF/pull/293,
43-
// pending new release.
44-
if (version_compare(PHP_VERSION, '8.0.0', '>=')) {
45-
return;
46-
}
47-
4836
$file = __DIR__ . '/../../_files/tcpdf.pdf';
4937

5038
$phpWord = new PhpWord();

tests/PhpWord/_includes/AbstractWebServerEmbeddedTest.php

Lines changed: 6 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -25,39 +25,18 @@ abstract class AbstractWebServerEmbeddedTest extends \PHPUnit\Framework\TestCase
2525

2626
public static function setUpBeforeClass()
2727
{
28-
if (self::isBuiltinServerSupported()) {
29-
$commandLine = 'php -S localhost:8080 -t tests/PhpWord/_files';
28+
$commandLine = 'php -S localhost:8080 -t tests/PhpWord/_files';
3029

31-
/*
32-
* Make sure to invoke \Symfony\Component\Process\Process correctly
33-
* regardless of PHP version used.
34-
*
35-
* In Process version >= 5 / PHP >= 7.2.5, the constructor requires
36-
* an array, while in version < 3.3 / PHP < 5.5.9 it requires a string.
37-
* In between, it can accept both.
38-
*
39-
* Process::fromShellCommandLine() was introduced in version 4.2.0,
40-
* to enable recent versions of Process to parse a command string,
41-
* so if it is not available it means it is still possible to pass
42-
* a string to the constructor.
43-
*/
44-
if (method_exists('Symfony\Component\Process\Process', 'fromShellCommandLine')) {
45-
self::$httpServer = Process::fromShellCommandline($commandLine);
46-
} else {
47-
self::$httpServer = new Process($commandLine);
48-
}
49-
self::$httpServer->start();
50-
while (!self::$httpServer->isRunning()) {
51-
usleep(1000);
52-
}
30+
self::$httpServer = Process::fromShellCommandline($commandLine);
31+
self::$httpServer->start();
32+
while (!self::$httpServer->isRunning()) {
33+
usleep(1000);
5334
}
5435
}
5536

5637
public static function tearDownAfterClass()
5738
{
58-
if (self::isBuiltinServerSupported()) {
59-
self::$httpServer->stop();
60-
}
39+
self::$httpServer->stop();
6140
}
6241

6342
protected static function getBaseUrl()
@@ -91,9 +70,4 @@ protected static function getRemoteBmpImageUrl()
9170

9271
return 'https://samples.libav.org/image-samples/RACECAR.BMP';
9372
}
94-
95-
private static function isBuiltinServerSupported()
96-
{
97-
return version_compare(PHP_VERSION, '5.4.0', '>=');
98-
}
9973
}

0 commit comments

Comments
 (0)