Skip to content

Commit 444e08e

Browse files
authored
Merge branch 'master' into fix/svg-error
2 parents 880a7a4 + a5f52d5 commit 444e08e

48 files changed

Lines changed: 206 additions & 371 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/php.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
strategy:
4848
fail-fast: false
4949
matrix:
50-
php: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4']
50+
php: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5']
5151
steps:
5252
- name: Setup PHP
5353
uses: shivammathur/setup-php@v2
@@ -68,30 +68,30 @@ jobs:
6868
strategy:
6969
fail-fast: false
7070
matrix:
71-
php: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4']
71+
php: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5']
7272
steps:
7373
- name: Setup PHP
7474
uses: shivammathur/setup-php@v2
7575
with:
7676
php-version: ${{ matrix.php }}
7777
extensions: gd, xml, zip
78-
coverage: ${{ (matrix.php == '7.3') && 'xdebug' || 'none' }}
78+
coverage: ${{ (matrix.php == '8.3') && 'xdebug' || 'none' }}
7979

8080
- uses: actions/checkout@v2
8181

8282
- name: Composer Install
8383
run: composer install --ansi --prefer-dist --no-interaction --no-progress
8484

8585
- name: Run phpunit
86-
if: matrix.php != '7.3'
86+
if: matrix.php != '8.3'
8787
run: ./vendor/bin/phpunit -c phpunit.xml.dist --no-coverage
8888

8989
- name: Run phpunit
90-
if: matrix.php == '7.3'
90+
if: matrix.php == '8.3'
9191
run: ./vendor/bin/phpunit -c phpunit.xml.dist --coverage-clover build/clover.xml
9292

9393
- name: Upload coverage results to Coveralls
94-
if: matrix.php == '7.3'
94+
if: matrix.php == '8.3'
9595
env:
9696
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9797
run: |
@@ -105,7 +105,7 @@ jobs:
105105
strategy:
106106
fail-fast: false
107107
matrix:
108-
php: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4']
108+
php: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5']
109109
steps:
110110
- name: Setup PHP
111111
uses: shivammathur/setup-php@v2

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
}
2020
],
2121
"require": {
22-
"php": "^7.1|^8.0",
22+
"php": "^7.4|^8.0",
2323
"ext-xml": "*",
2424
"ext-zip": "*",
2525
"phpoffice/common": "^1",
@@ -28,7 +28,7 @@
2828
"require-dev": {
2929
"phpunit/phpunit": ">=7.0",
3030
"phpmd/phpmd": "2.*",
31-
"phpstan/phpstan": "^0.12.88 || ^1.0.0",
31+
"phpstan/phpstan": "^2.2",
3232
"dompdf/dompdf": "^3.1"
3333
},
3434
"suggest": {

docs/changes/1.3.0.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44

55
## Enhancements
66
- `phpoffice/phpspreadsheet`: Allow version 5.0 by [@seanlynchwv](http://github.com/seanlynchwv) in [#879](https://github.com/PHPOffice/PHPPresentation/pull/879)
7+
- Raised the minimum PHP version to 7.4 (dropped 7.1, 7.2 and 7.3) by [@slayerfx](http://github.com/slayerfx) in [#894](https://github.com/PHPOffice/PHPPresentation/pull/894)
78

89
## Bug fixes
910
- Fixed adding custom SVGs by [@seanlynchwv](http://github.com/seanlynchwv) in [#881](https://github.com/PHPOffice/PHPPresentation/pull/881)
11+
- Guarded `imagedestroy()` calls behind a PHP version check (no-op since PHP 8.0, deprecated in PHP 8.5) by [@slayerfx](http://github.com/slayerfx) in [#893](https://github.com/PHPOffice/PHPPresentation/pull/893)
12+
- Fixed code coverage configuration for PHPUnit 10+ by [@slayerfx](http://github.com/slayerfx) in [#895](https://github.com/PHPOffice/PHPPresentation/pull/895)
13+
- Fixed static analysis on PHP 8.4 and 8.5 (PHPStan 1.x could not resolve the symbols of PHPUnit 13) by [@yasumorishima](http://github.com/yasumorishima) in [#897](https://github.com/PHPOffice/PHPPresentation/pull/897)
1014

phpunit.xml.dist

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,17 @@
22
<phpunit
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
44
backupGlobals="false"
5-
backupStaticAttributes="false"
65
bootstrap="./tests/bootstrap.php"
76
colors="true"
8-
convertErrorsToExceptions="true"
9-
convertNoticesToExceptions="true"
10-
convertWarningsToExceptions="true"
11-
convertDeprecationsToExceptions="true"
127
processIsolation="false"
138
stopOnFailure="false"
149
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
15-
<coverage>
10+
<source>
1611
<include>
1712
<directory suffix=".php">./src</directory>
1813
</include>
14+
</source>
15+
<coverage>
1916
<report>
2017
<clover outputFile="./build/logs/clover.xml"/>
2118
<html outputDirectory="./build/coverage"/>

src/PhpPresentation/GeometryCalculator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public static function calculateOffsets(ShapeContainerInterface $container): arr
3737
{
3838
$offsets = [self::X => 0, self::Y => 0];
3939

40-
if (null !== $container && 0 != count($container->getShapeCollection())) {
40+
if (0 != count($container->getShapeCollection())) {
4141
$shapes = $container->getShapeCollection();
4242
if (null !== $shapes[0]) {
4343
$offsets[self::X] = $shapes[0]->getOffsetX();
@@ -70,7 +70,7 @@ public static function calculateExtents(ShapeContainerInterface $container): arr
7070
/** @var array<string, int> $extents */
7171
$extents = [self::X => 0, self::Y => 0];
7272

73-
if (null !== $container && 0 != count($container->getShapeCollection())) {
73+
if (0 != count($container->getShapeCollection())) {
7474
$shapes = $container->getShapeCollection();
7575
if (null !== $shapes[0]) {
7676
$extents[self::X] = (int) ($shapes[0]->getOffsetX() + $shapes[0]->getWidth());

src/PhpPresentation/Reader/ODPresentation.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class ODPresentation implements ReaderInterface
6363
protected $oZip;
6464

6565
/**
66-
* @var array<string, array{alignment: null|Alignment, background: null, shadow: null|Shadow, fill: null|Fill, spacingAfter: null|int, spacingBefore: null|int, lineSpacingMode: null, lineSpacing: null, font: null, listStyle: null}>
66+
* @var array<string, array{alignment: null|Alignment, background: null|BackgroundColor|Image, fill: null|Fill, font: null|Font, shadow: null|Shadow, listStyle: null|array<int, array{alignment: Alignment, bullet: Bullet}>, spacingAfter: null|float, spacingBefore: null|float, lineSpacingMode: null|string, lineSpacing: null|string}>
6767
*/
6868
protected $arrayStyles = [];
6969

@@ -662,7 +662,7 @@ protected function readParagraph(RichText $oShape, DOMElement $oNodeParent): voi
662662
$oParagraph->setLineSpacingMode($this->arrayStyles[$keyStyle]['lineSpacingMode']);
663663
}
664664
if (!empty($this->arrayStyles[$keyStyle]['lineSpacing'])) {
665-
$oParagraph->setLineSpacing($this->arrayStyles[$keyStyle]['lineSpacing']);
665+
$oParagraph->setLineSpacing((int) $this->arrayStyles[$keyStyle]['lineSpacing']);
666666
}
667667
}
668668
}

src/PhpPresentation/Reader/PowerPoint2007.php

Lines changed: 43 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -237,20 +237,26 @@ protected function loadDocumentProperties(string $sPart): void
237237
'/cp:coreProperties/dc:subject' => 'setSubject',
238238
'/cp:coreProperties/cp:keywords' => 'setKeywords',
239239
'/cp:coreProperties/cp:category' => 'setCategory',
240-
'/cp:coreProperties/dcterms:created' => 'setCreated',
241-
'/cp:coreProperties/dcterms:modified' => 'setModified',
242240
'/cp:coreProperties/cp:revision' => 'setRevision',
243241
'/cp:coreProperties/cp:contentStatus' => 'setStatus',
244242
];
243+
$arrayDateProperties = [
244+
'/cp:coreProperties/dcterms:created' => 'setCreated',
245+
'/cp:coreProperties/dcterms:modified' => 'setModified',
246+
];
245247
$oProperties = $this->oPhpPresentation->getDocumentProperties();
246248
foreach ($arrayProperties as $path => $property) {
247249
$oElement = $xmlReader->getElement($path);
248250
if ($oElement instanceof DOMElement) {
249-
if ($oElement->hasAttribute('xsi:type') && 'dcterms:W3CDTF' == $oElement->getAttribute('xsi:type')) {
250-
$dateTime = DateTime::createFromFormat(DateTime::W3C, $oElement->nodeValue);
251+
$oProperties->{$property}((string) $oElement->nodeValue);
252+
}
253+
}
254+
foreach ($arrayDateProperties as $path => $property) {
255+
$oElement = $xmlReader->getElement($path);
256+
if ($oElement instanceof DOMElement) {
257+
$dateTime = DateTime::createFromFormat(DateTime::W3C, (string) $oElement->nodeValue);
258+
if (false !== $dateTime) {
251259
$oProperties->{$property}($dateTime->getTimestamp());
252-
} else {
253-
$oProperties->{$property}($oElement->nodeValue);
254260
}
255261
}
256262
}
@@ -905,44 +911,42 @@ protected function loadShapeDrawing(XMLReader $document, DOMElement $node, Abstr
905911
*/
906912
protected function loadShadow(XMLReader $document, DOMElement $node): ?Shadow
907913
{
908-
if ($node instanceof DOMElement) {
909-
$aNodes = $document->getElements('*', $node);
910-
foreach ($aNodes as $nodeShadow) {
911-
$type = explode(':', $nodeShadow->tagName);
912-
$type = array_pop($type);
913-
if ($type == Shadow::TYPE_SHADOW_INNER || $type == Shadow::TYPE_SHADOW_OUTER || $type == Shadow::TYPE_REFLECTION) {
914-
$oShadow = new Shadow();
915-
$oShadow->setVisible(true);
916-
$oShadow->setType($type);
917-
if ($nodeShadow->hasAttribute('blurRad')) {
918-
$oShadow->setBlurRadius((int) CommonDrawing::emuToPixels((int) $nodeShadow->getAttribute('blurRad')));
919-
}
920-
if ($nodeShadow->hasAttribute('dist')) {
921-
$oShadow->setDistance((int) CommonDrawing::emuToPixels((int) $nodeShadow->getAttribute('dist')));
922-
}
923-
if ($nodeShadow->hasAttribute('dir')) {
924-
$oShadow->setDirection((int) CommonDrawing::angleToDegrees((int) $nodeShadow->getAttribute('dir')));
925-
}
926-
if ($nodeShadow->hasAttribute('algn')) {
927-
$oShadow->setAlignment($node->getAttribute('algn'));
928-
}
929-
930-
// Get color define by prstClr
931-
$oSubElement = $document->getElement('a:prstClr', $nodeShadow);
932-
if ($oSubElement instanceof DOMElement && $oSubElement->hasAttribute('val')) {
933-
$oColor = new Color();
934-
$oColor->setRGB($oSubElement->getAttribute('val'));
914+
$aNodes = $document->getElements('*', $node);
915+
foreach ($aNodes as $nodeShadow) {
916+
$type = explode(':', $nodeShadow->tagName);
917+
$type = array_pop($type);
918+
if ($type == Shadow::TYPE_SHADOW_INNER || $type == Shadow::TYPE_SHADOW_OUTER || $type == Shadow::TYPE_REFLECTION) {
919+
$oShadow = new Shadow();
920+
$oShadow->setVisible(true);
921+
$oShadow->setType($type);
922+
if ($nodeShadow->hasAttribute('blurRad')) {
923+
$oShadow->setBlurRadius((int) CommonDrawing::emuToPixels((int) $nodeShadow->getAttribute('blurRad')));
924+
}
925+
if ($nodeShadow->hasAttribute('dist')) {
926+
$oShadow->setDistance((int) CommonDrawing::emuToPixels((int) $nodeShadow->getAttribute('dist')));
927+
}
928+
if ($nodeShadow->hasAttribute('dir')) {
929+
$oShadow->setDirection((int) CommonDrawing::angleToDegrees((int) $nodeShadow->getAttribute('dir')));
930+
}
931+
if ($nodeShadow->hasAttribute('algn')) {
932+
$oShadow->setAlignment($node->getAttribute('algn'));
933+
}
935934

936-
$oSubElt = $document->getElement('a:alpha', $oSubElement);
937-
if ($oSubElt instanceof DOMElement && $oSubElt->hasAttribute('val')) {
938-
$oColor->setAlpha((int) $oSubElt->getAttribute('val') / 1000);
939-
}
935+
// Get color define by prstClr
936+
$oSubElement = $document->getElement('a:prstClr', $nodeShadow);
937+
if ($oSubElement instanceof DOMElement && $oSubElement->hasAttribute('val')) {
938+
$oColor = new Color();
939+
$oColor->setRGB($oSubElement->getAttribute('val'));
940940

941-
$oShadow->setColor($oColor);
941+
$oSubElt = $document->getElement('a:alpha', $oSubElement);
942+
if ($oSubElt instanceof DOMElement && $oSubElt->hasAttribute('val')) {
943+
$oColor->setAlpha((int) $oSubElt->getAttribute('val') / 1000);
942944
}
943945

944-
return $oShadow;
946+
$oShadow->setColor($oColor);
945947
}
948+
949+
return $oShadow;
946950
}
947951
}
948952

src/PhpPresentation/Shape/Chart/Series.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ class Series implements ComparableInterface
134134
/**
135135
* Values (key/value).
136136
*
137-
* @var array<string, null|string>
137+
* @var array<array-key, null|string>
138138
*/
139139
private $values = [];
140140

@@ -146,7 +146,7 @@ class Series implements ComparableInterface
146146
private $hashIndex;
147147

148148
/**
149-
* @param array<string, null|string> $values
149+
* @param array<array-key, null|string> $values
150150
*/
151151
public function __construct(string $title = 'Series Title', array $values = [])
152152
{
@@ -239,7 +239,7 @@ public function getDataPointFills(): array
239239
/**
240240
* Get Values.
241241
*
242-
* @return array<string, null|string>
242+
* @return array<array-key, null|string>
243243
*/
244244
public function getValues(): array
245245
{
@@ -249,7 +249,7 @@ public function getValues(): array
249249
/**
250250
* Set Values.
251251
*
252-
* @param array<string, null|string> $values
252+
* @param array<array-key, null|string> $values
253253
*/
254254
public function setValues(array $values = []): self
255255
{

src/PhpPresentation/Writer/ODPresentation/Content.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -461,9 +461,7 @@ protected function writeShapeDrawing(XMLWriter $objWriter, AbstractDrawingAdapte
461461
$objWriter->writeAttribute('draw:style-name', 'gr' . $this->shapeId);
462462
// draw:image
463463
$objWriter->startElement('draw:image');
464-
if ($shape instanceof AbstractDrawingAdapter) {
465-
$objWriter->writeAttribute('xlink:href', 'Pictures/' . $shape->getIndexedFilename());
466-
}
464+
$objWriter->writeAttribute('xlink:href', 'Pictures/' . $shape->getIndexedFilename());
467465
$objWriter->writeAttribute('xlink:type', 'simple');
468466
$objWriter->writeAttribute('xlink:show', 'embed');
469467
$objWriter->writeAttribute('xlink:actuate', 'onLoad');

src/PhpPresentation/Writer/ODPresentation/MetaInfManifest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,9 @@ public function render(): ZipInterface
106106
// PNG : 8bit, non-interlaced with full alpha transparency
107107
$gdImage = imagecreatefromstring(file_get_contents($pathThumbnail));
108108
if ($gdImage) {
109-
imagedestroy($gdImage);
109+
if (PHP_VERSION_ID < 80000) {
110+
imagedestroy($gdImage);
111+
}
110112
$objWriter->startElement('manifest:file-entry');
111113
$objWriter->writeAttribute('manifest:media-type', 'image/png');
112114
$objWriter->writeAttribute('manifest:full-path', 'Thumbnails/thumbnail.png');

0 commit comments

Comments
 (0)