Skip to content

Drop PHP 7.3 and older #2297

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ jobs:
strategy:
matrix:
php-version:
- '7.2'
- "7.3"
- "7.4"
- "8.0"
- "8.1"
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Read more about PHPWord:

## Features

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:
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:

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

PHPWord requires the following:

- PHP 5.3.3+
- PHP 7.4+
- [XML Parser extension](http://www.php.net/manual/en/xml.installation.php)
- [Laminas Escaper component](https://docs.laminas.dev/laminas-escaper/intro/)
- [Zip extension](http://php.net/manual/en/book.zip.php) (optional, used to write OOXML and ODF)
Expand Down
7 changes: 4 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,10 @@
"fix": "Fixes issues found by PHP-CS"
},
"require": {
"php": "^5.3.3 || ^7.0 || ^8.0",
"php": "^7.4 || ^8.0",
"ext-xml": "*",
"laminas/laminas-escaper": "^2.2"
"laminas/laminas-escaper": "^2.2",
"symfony/process": "^5.4"
},
"require-dev": {
"ext-zip": "*",
Expand All @@ -71,7 +72,7 @@
"phpmd/phpmd": "2.*",
"phploc/phploc": "2.* || 3.* || 4.* || 5.* || 6.* || 7.*",
"dompdf/dompdf":"0.8.* || 1.0.*",
"tecnickcom/tcpdf": "6.*",
"tecnickcom/tcpdf": "^6.4",
"mpdf/mpdf": "5.7.4 || 6.* || 7.* || 8.*",
"php-coveralls/php-coveralls": "1.1.0 || ^2.0"
},
Expand Down
16 changes: 0 additions & 16 deletions docs/faq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,3 @@ Frequently asked questions
How contribute to PHPWord?
--------------------------
- Improve the documentation (`Sphinx Format <http://documentation-style-guide-sphinx.readthedocs.org/en/latest/index.html>`__)

Is this the same with PHPWord that I found in CodePlex?
-------------------------------------------------------

No. This one is much better with tons of new features that you can’t
find in PHPWord 0.6.3. The development in CodePlex is halted and
switched to GitHub to allow more participation from the crowd. The more
the merrier, right?

I’ve been running PHPWord from CodePlex flawlessly, but I can’t use the latest PHPWord from GitHub. Why?
--------------------------------------------------------------------------------------------------------

PHPWord requires PHP 5.3+ since 0.8, while PHPWord 0.6.3 from CodePlex
can run with PHP 5.2. There’s a lot of new features that we can get from
PHP 5.3 and it’s been around since 2009! You should upgrade your PHP
version to use PHPWord 0.8+.
4 changes: 2 additions & 2 deletions docs/installing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ Requirements

Mandatory:

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

Optional:

Expand Down
7 changes: 1 addition & 6 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,4 @@
</exclude>
</whitelist>
</filter>
<logging>
<log type="coverage-html" target="./build/coverage" />
<log type="coverage-clover" target="./build/logs/clover.xml" />
<log type="junit" target="./build/logs/logfile.xml"/>
</logging>
</phpunit>
</phpunit>
2 changes: 1 addition & 1 deletion samples/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use PhpOffice\PhpWord\Settings;

$requirements = array(
'php' => array('PHP 5.3.3', version_compare(PHP_VERSION, '5.3.3', '>=')),
'php' => array('PHP 7.4', version_compare(PHP_VERSION, '7.4', '>=')),
'xml' => array('PHP extension XML', extension_loaded('xml')),
'temp' => array('Temp folder "<code>' . Settings::getTempDir() . '</code>" is writable', is_writable(Settings::getTempDir())),
'zip' => array('PHP extension ZipArchive (optional)', extension_loaded('zip')),
Expand Down
22 changes: 1 addition & 21 deletions src/PhpWord/Element/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ private function checkImage()
if ($this->sourceType == self::SOURCE_ARCHIVE) {
$imageData = $this->getArchiveImageSize($this->source);
} elseif ($this->sourceType == self::SOURCE_STRING) {
$imageData = $this->getStringImageSize($this->source);
$imageData = @getimagesizefromstring($this->source);
} else {
$imageData = @getimagesize($this->source);
}
Expand Down Expand Up @@ -501,26 +501,6 @@ private function getArchiveImageSize($source)
return $imageData;
}

/**
* get image size from string
*
* @param string $source
*
* @codeCoverageIgnore this method is just a replacement for getimagesizefromstring which exists only as of PHP 5.4
*/
private function getStringImageSize($source)
{
$result = false;
if (!function_exists('getimagesizefromstring')) {
$uri = 'data://application/octet-stream;base64,' . base64_encode($source);
$result = @getimagesize($uri);
} else {
$result = @getimagesizefromstring($source);
}

return $result;
}

/**
* Set image functions and extensions.
*/
Expand Down
3 changes: 1 addition & 2 deletions src/PhpWord/Escaper/Xml.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class Xml extends AbstractEscaper
{
protected function escapeSingleValue($input)
{
// todo: omit encoding parameter after migration onto PHP 5.4
return (!is_null($input)) ? htmlspecialchars($input, ENT_QUOTES, 'UTF-8') : '';
return (!is_null($input)) ? htmlspecialchars($input, ENT_QUOTES) : '';
}
}
23 changes: 0 additions & 23 deletions src/PhpWord/Shared/PCLZip/pclzip.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -3258,17 +3258,6 @@ public function privExtractByRule(&$p_file_list, $p_path, $p_remove_path, $p_rem
$v_extract = true;
}
}
// ----- Look for extract by ereg rule
// ereg() is deprecated with PHP 5.3
/*
elseif ( (isset($p_options[PCLZIP_OPT_BY_EREG]))
&& ($p_options[PCLZIP_OPT_BY_EREG] != "")) {

if (ereg($p_options[PCLZIP_OPT_BY_EREG], $v_header['stored_filename'])) {
$v_extract = true;
}
}
*/

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

// ----- Look for extract by ereg rule
// ereg() is deprecated with PHP 5.3
/*
elseif ( (isset($p_options[PCLZIP_OPT_BY_EREG]))
&& ($p_options[PCLZIP_OPT_BY_EREG] != "")) {

if (ereg($p_options[PCLZIP_OPT_BY_EREG], $v_header_list[$v_nb_extracted]['stored_filename'])) {
$v_found = true;
}
}
*/

// ----- Look for extract by preg rule
} elseif ((isset($p_options[PCLZIP_OPT_BY_PREG])) && ($p_options[PCLZIP_OPT_BY_PREG] != "")) {

Expand Down
12 changes: 0 additions & 12 deletions tests/PhpWord/Writer/PDF/TCPDFTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,6 @@ class TCPDFTest extends \PHPUnit\Framework\TestCase
*/
public function testConstruct()
{
// TCPDF version 6.3.5 doesn't support PHP 5.3, fixed via https://github.com/tecnickcom/TCPDF/pull/197,
// pending new release.
if (version_compare(PHP_VERSION, '5.4.0', '<')) {
return;
}

// TCPDF version 6.3.5 doesn't support PHP 8.0, fixed via https://github.com/tecnickcom/TCPDF/pull/293,
// pending new release.
if (version_compare(PHP_VERSION, '8.0.0', '>=')) {
return;
}

$file = __DIR__ . '/../../_files/tcpdf.pdf';

$phpWord = new PhpWord();
Expand Down
38 changes: 6 additions & 32 deletions tests/PhpWord/_includes/AbstractWebServerEmbeddedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,39 +25,18 @@ abstract class AbstractWebServerEmbeddedTest extends \PHPUnit\Framework\TestCase

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

/*
* Make sure to invoke \Symfony\Component\Process\Process correctly
* regardless of PHP version used.
*
* In Process version >= 5 / PHP >= 7.2.5, the constructor requires
* an array, while in version < 3.3 / PHP < 5.5.9 it requires a string.
* In between, it can accept both.
*
* Process::fromShellCommandLine() was introduced in version 4.2.0,
* to enable recent versions of Process to parse a command string,
* so if it is not available it means it is still possible to pass
* a string to the constructor.
*/
if (method_exists('Symfony\Component\Process\Process', 'fromShellCommandLine')) {
self::$httpServer = Process::fromShellCommandline($commandLine);
} else {
self::$httpServer = new Process($commandLine);
}
self::$httpServer->start();
while (!self::$httpServer->isRunning()) {
usleep(1000);
}
self::$httpServer = Process::fromShellCommandline($commandLine);
self::$httpServer->start();
while (!self::$httpServer->isRunning()) {
usleep(1000);
}
}

public static function tearDownAfterClass()
{
if (self::isBuiltinServerSupported()) {
self::$httpServer->stop();
}
self::$httpServer->stop();
}

protected static function getBaseUrl()
Expand Down Expand Up @@ -91,9 +70,4 @@ protected static function getRemoteBmpImageUrl()

return 'https://samples.libav.org/image-samples/RACECAR.BMP';
}

private static function isBuiltinServerSupported()
{
return version_compare(PHP_VERSION, '5.4.0', '>=');
}
}