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
This commit is contained in:
Adrien Crivelli 2022-09-16 10:17:31 +02:00
parent 2ee6df65bc
commit 0e8bcb63e7
No known key found for this signature in database
GPG Key ID: 16D79B903B4B5874
11 changed files with 17 additions and 116 deletions

View File

@ -8,8 +8,6 @@ jobs:
strategy: strategy:
matrix: matrix:
php-version: php-version:
- '7.2'
- "7.3"
- "7.4" - "7.4"
- "8.0" - "8.0"
- "8.1" - "8.1"

View File

@ -32,7 +32,7 @@ Read more about PHPWord:
## Features ## 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. - Set document properties, e.g. title, subject, and creator.
- Create document sections with different settings, e.g. portrait/landscape, page size, and page numbering - 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
PHPWord requires the following: PHPWord requires the following:
- PHP 5.3.3+ - PHP 7.4+
- [XML Parser extension](http://www.php.net/manual/en/xml.installation.php) - [XML Parser extension](http://www.php.net/manual/en/xml.installation.php)
- [Laminas Escaper component](https://docs.laminas.dev/laminas-escaper/intro/) - [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) - [Zip extension](http://php.net/manual/en/book.zip.php) (optional, used to write OOXML and ODF)

View File

@ -58,9 +58,10 @@
"fix": "Fixes issues found by PHP-CS" "fix": "Fixes issues found by PHP-CS"
}, },
"require": { "require": {
"php": "^5.3.3 || ^7.0 || ^8.0", "php": "^7.4 || ^8.0",
"ext-xml": "*", "ext-xml": "*",
"laminas/laminas-escaper": "^2.2" "laminas/laminas-escaper": "^2.2",
"symfony/process": "^5.4"
}, },
"require-dev": { "require-dev": {
"ext-zip": "*", "ext-zip": "*",
@ -71,7 +72,7 @@
"phpmd/phpmd": "2.*", "phpmd/phpmd": "2.*",
"phploc/phploc": "2.* || 3.* || 4.* || 5.* || 6.* || 7.*", "phploc/phploc": "2.* || 3.* || 4.* || 5.* || 6.* || 7.*",
"dompdf/dompdf":"0.8.* || 1.0.*", "dompdf/dompdf":"0.8.* || 1.0.*",
"tecnickcom/tcpdf": "6.*", "tecnickcom/tcpdf": "^6.4",
"mpdf/mpdf": "5.7.4 || 6.* || 7.* || 8.*", "mpdf/mpdf": "5.7.4 || 6.* || 7.* || 8.*",
"php-coveralls/php-coveralls": "1.1.0 || ^2.0" "php-coveralls/php-coveralls": "1.1.0 || ^2.0"
}, },

View File

@ -6,19 +6,3 @@ Frequently asked questions
How contribute to PHPWord? How contribute to PHPWord?
-------------------------- --------------------------
- Improve the documentation (`Sphinx Format <http://documentation-style-guide-sphinx.readthedocs.org/en/latest/index.html>`__) - 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 cant
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?
Ive been running PHPWord from CodePlex flawlessly, but I cant 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. Theres a lot of new features that we can get from
PHP 5.3 and its been around since 2009! You should upgrade your PHP
version to use PHPWord 0.8+.

View File

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

View File

@ -4,7 +4,7 @@ include_once 'Sample_Header.php';
use PhpOffice\PhpWord\Settings; use PhpOffice\PhpWord\Settings;
$requirements = array( $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')), 'xml' => array('PHP extension XML', extension_loaded('xml')),
'temp' => array('Temp folder "<code>' . Settings::getTempDir() . '</code>" is writable', is_writable(Settings::getTempDir())), 'temp' => array('Temp folder "<code>' . Settings::getTempDir() . '</code>" is writable', is_writable(Settings::getTempDir())),
'zip' => array('PHP extension ZipArchive (optional)', extension_loaded('zip')), 'zip' => array('PHP extension ZipArchive (optional)', extension_loaded('zip')),

View File

@ -410,7 +410,7 @@ class Image extends AbstractElement
if ($this->sourceType == self::SOURCE_ARCHIVE) { if ($this->sourceType == self::SOURCE_ARCHIVE) {
$imageData = $this->getArchiveImageSize($this->source); $imageData = $this->getArchiveImageSize($this->source);
} elseif ($this->sourceType == self::SOURCE_STRING) { } elseif ($this->sourceType == self::SOURCE_STRING) {
$imageData = $this->getStringImageSize($this->source); $imageData = @getimagesizefromstring($this->source);
} else { } else {
$imageData = @getimagesize($this->source); $imageData = @getimagesize($this->source);
} }
@ -501,26 +501,6 @@ class Image extends AbstractElement
return $imageData; 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. * Set image functions and extensions.
*/ */

View File

@ -26,7 +26,6 @@ class Xml extends AbstractEscaper
{ {
protected function escapeSingleValue($input) protected function escapeSingleValue($input)
{ {
// todo: omit encoding parameter after migration onto PHP 5.4 return (!is_null($input)) ? htmlspecialchars($input, ENT_QUOTES) : '';
return (!is_null($input)) ? htmlspecialchars($input, ENT_QUOTES, 'UTF-8') : '';
} }
} }

View File

@ -3258,17 +3258,6 @@ class PclZip
$v_extract = true; $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 // ----- Look for extract by preg rule
} elseif ((isset($p_options[PCLZIP_OPT_BY_PREG])) && ($p_options[PCLZIP_OPT_BY_PREG] != "")) { } elseif ((isset($p_options[PCLZIP_OPT_BY_PREG])) && ($p_options[PCLZIP_OPT_BY_PREG] != "")) {
@ -4545,18 +4534,6 @@ class PclZip
} }
} }
// ----- 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 // ----- Look for extract by preg rule
} elseif ((isset($p_options[PCLZIP_OPT_BY_PREG])) && ($p_options[PCLZIP_OPT_BY_PREG] != "")) { } elseif ((isset($p_options[PCLZIP_OPT_BY_PREG])) && ($p_options[PCLZIP_OPT_BY_PREG] != "")) {

View File

@ -33,18 +33,6 @@ class TCPDFTest extends \PHPUnit\Framework\TestCase
*/ */
public function testConstruct() 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'; $file = __DIR__ . '/../../_files/tcpdf.pdf';
$phpWord = new PhpWord(); $phpWord = new PhpWord();

View File

@ -25,40 +25,19 @@ abstract class AbstractWebServerEmbeddedTest extends \PHPUnit\Framework\TestCase
public static function setUpBeforeClass() 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); self::$httpServer = Process::fromShellCommandline($commandLine);
} else {
self::$httpServer = new Process($commandLine);
}
self::$httpServer->start(); self::$httpServer->start();
while (!self::$httpServer->isRunning()) { while (!self::$httpServer->isRunning()) {
usleep(1000); usleep(1000);
} }
} }
}
public static function tearDownAfterClass() public static function tearDownAfterClass()
{ {
if (self::isBuiltinServerSupported()) {
self::$httpServer->stop(); self::$httpServer->stop();
} }
}
protected static function getBaseUrl() protected static function getBaseUrl()
{ {
@ -91,9 +70,4 @@ abstract class AbstractWebServerEmbeddedTest extends \PHPUnit\Framework\TestCase
return 'https://samples.libav.org/image-samples/RACECAR.BMP'; return 'https://samples.libav.org/image-samples/RACECAR.BMP';
} }
private static function isBuiltinServerSupported()
{
return version_compare(PHP_VERSION, '5.4.0', '>=');
}
} }