Skip to content

Commit 0c69c2a

Browse files
committed
Release 1.2.1: fix PHP 8.5 finfo_close() deprecation in mime checks.
1 parent e6e1743 commit 0c69c2a

10 files changed

Lines changed: 78 additions & 21 deletions

File tree

.php-cs-fixer.dist.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,10 @@
8080
'modernize_types_casting' => true,
8181
'no_short_bool_cast' => true,
8282
'explicit_string_variable' => true,
83-
'fully_qualified_strict_types' => true,
83+
'fully_qualified_strict_types' => [
84+
// Convert \Foo\Bar to use Foo\Bar; + Bar (instanceof, new, types, ::class, etc.).
85+
'import_symbols' => true,
86+
],
8487
'global_namespace_import' => [
8588
'import_classes' => true,
8689
'import_constants' => true,

demo/symfony8/composer.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo/symfony8/config/bundles.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
<?php
22

33
declare(strict_types=1);
4+
use Nowo\TwigInspectorBundle\NowoTwigInspectorBundle;
5+
use Nowo\WordToPdfBundle\WordToPdfBundle;
6+
use Symfony\Bundle\DebugBundle\DebugBundle;
7+
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
8+
use Symfony\Bundle\TwigBundle\TwigBundle;
9+
use Symfony\Bundle\WebProfilerBundle\WebProfilerBundle;
410

511
return [
6-
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
7-
Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true],
8-
Symfony\Bundle\DebugBundle\DebugBundle::class => ['dev' => true],
9-
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true],
10-
Nowo\WordToPdfBundle\WordToPdfBundle::class => ['all' => true],
11-
Nowo\TwigInspectorBundle\NowoTwigInspectorBundle::class => ['dev' => true, 'test' => true],
12+
FrameworkBundle::class => ['all' => true],
13+
TwigBundle::class => ['all' => true],
14+
DebugBundle::class => ['dev' => true],
15+
WebProfilerBundle::class => ['dev' => true],
16+
WordToPdfBundle::class => ['all' => true],
17+
NowoTwigInspectorBundle::class => ['dev' => true, 'test' => true],
1218
];

docs/CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
77

88
## [Unreleased]
99

10+
## [1.2.1] - 2026-07-22
11+
12+
### Fixed
13+
14+
- Avoid PHP 8.5 deprecation on `finfo_close()` by using the object-oriented `\finfo` API in source mime checks (`WordToPdfConverter`).
15+
16+
### Changed
17+
18+
- PHP-CS-Fixer `fully_qualified_strict_types.import_symbols` enabled (import FQCN in `use` statements).
19+
20+
### Compatibility
21+
22+
- Unchanged from 1.2.0.
23+
1024
## [1.2.0] - 2026-07-22
1125

1226
### Added

docs/RELEASE.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,23 @@
99

1010
After creating the release commit and tag, run `make check-no-cursor-coauthor` again **before** `git push` (REQ-GIT-001). The release commit itself is not covered by an earlier `release-check` run.
1111

12+
## Example for v1.2.1
13+
14+
```bash
15+
git add -A
16+
git status # review
17+
make release-check
18+
git commit -m "$(cat <<'EOF'
19+
Release 1.2.1: fix PHP 8.5 finfo_close() deprecation in mime checks.
20+
21+
EOF
22+
)"
23+
git tag -a v1.2.1 -m "Release v1.2.1"
24+
make check-no-cursor-coauthor
25+
git push origin main
26+
git push origin v1.2.1
27+
```
28+
1229
## Example for v1.2.0
1330

1431
```bash

docs/UPGRADING.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,22 @@
44

55
*(none yet)*
66

7+
## To 1.2.1
8+
9+
No breaking public API changes. Safe to upgrade with:
10+
11+
```bash
12+
composer update nowo-tech/word-to-pdf-bundle
13+
```
14+
15+
### Behavioral notes (non-breaking)
16+
17+
- Source mime probing no longer calls `finfo_close()` (deprecated on PHP 8.5); uses `new \finfo(...)` instead. Apps that copy the old procedural pattern should apply the same change.
18+
19+
### Breaking changes
20+
21+
None.
22+
723
## To 1.2.0
824

925
No breaking public API changes. Safe to upgrade with:

src/Converter/WordToPdfConverter.php

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Nowo\WordToPdfBundle\Converter;
66

7+
use finfo;
78
use Nowo\WordToPdfBundle\Config\ProfileResolver;
89
use Nowo\WordToPdfBundle\Config\ResolvedConfig;
910
use Nowo\WordToPdfBundle\Exception\ConversionFailedException;
@@ -15,8 +16,8 @@
1516
use Throwable;
1617

1718
use function array_replace_recursive;
19+
use function class_exists;
1820
use function filesize;
19-
use function function_exists;
2021
use function in_array;
2122
use function is_file;
2223
use function is_readable;
@@ -200,15 +201,12 @@ private function assertSource(string $sourcePath, ResolvedConfig $config): void
200201
throw new ConversionFailedException(sprintf('Source file "%s" exceeds max_source_bytes (%d > %d).', $sourcePath, $size, $config->maxSourceBytes));
201202
}
202203

203-
// Light magic check when fileinfo is available
204-
if (function_exists('finfo_open')) {
205-
$finfo = finfo_open(FILEINFO_MIME_TYPE);
206-
if ($finfo !== false) {
207-
$mime = finfo_file($finfo, $sourcePath) ?: '';
208-
finfo_close($finfo);
209-
if ($mime !== '' && $mime !== 'inode/x-empty' && (str_starts_with($mime, 'text/') || str_starts_with($mime, 'image/'))) {
210-
throw new UnsupportedFormatException(sprintf('File "%s" does not look like a Word document (mime: %s).', $sourcePath, $mime));
211-
}
204+
// Light magic check when fileinfo is available (OO API: finfo_close() is deprecated since PHP 8.5)
205+
if (class_exists(finfo::class)) {
206+
$finfo = new finfo(FILEINFO_MIME_TYPE);
207+
$mime = $finfo->file($sourcePath) ?: '';
208+
if ($mime !== '' && $mime !== 'inode/x-empty' && (str_starts_with($mime, 'text/') || str_starts_with($mime, 'image/'))) {
209+
throw new UnsupportedFormatException(sprintf('File "%s" does not look like a Word document (mime: %s).', $sourcePath, $mime));
212210
}
213211
}
214212
}

src/Converter/WordToPdfConverterInterface.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Nowo\WordToPdfBundle\Converter;
66

77
use Nowo\WordToPdfBundle\Exception\InvalidProfileException;
8+
use Nowo\WordToPdfBundle\Exception\MissingDependencyException;
89
use Nowo\WordToPdfBundle\Naming\PdfNaming;
910
use Nowo\WordToPdfBundle\Result\ConvertedPdf;
1011

@@ -85,7 +86,7 @@ public function convertMany(
8586
*
8687
* @param string|null $profile Profile key, or null for the default
8788
*
88-
* @throws \Nowo\WordToPdfBundle\Exception\MissingDependencyException
89+
* @throws MissingDependencyException
8990
* @throws InvalidProfileException
9091
*
9192
* @return void

src/Naming/PdfNaming.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Nowo\WordToPdfBundle\Naming;
66

77
use InvalidArgumentException;
8+
use Nowo\WordToPdfBundle\Converter\WordToPdfConverterInterface;
89

910
use function basename;
1011
use function in_array;
@@ -19,7 +20,7 @@
1920
/**
2021
* Builds suggested PDF download filenames from Word source paths.
2122
*
22-
* Use with {@see \Nowo\WordToPdfBundle\Converter\WordToPdfConverterInterface::convertMany()}.
23+
* Use with {@see WordToPdfConverterInterface::convertMany()}.
2324
* Explicit path => filename maps passed to convertMany override this strategy.
2425
*/
2526
final readonly class PdfNaming

tests/Unit/Export/PdfExporterTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Nowo\WordToPdfBundle\Tests\Unit\Export;
66

7+
use League\Flysystem\FilesystemOperator;
78
use Nowo\WordToPdfBundle\Exception\ExportException;
89
use Nowo\WordToPdfBundle\Export\PdfExporter;
910
use Nowo\WordToPdfBundle\Result\ConvertedPdf;
@@ -70,7 +71,7 @@ public function testFlysystemUpload(): void
7071
self::assertNotFalse($src);
7172
file_put_contents($src, '%PDF');
7273

73-
$fs = $this->createMock(\League\Flysystem\FilesystemOperator::class);
74+
$fs = $this->createMock(FilesystemOperator::class);
7475
$fs->expects(self::once())->method('writeStream');
7576

7677
$exporter = new PdfExporter($fs);

0 commit comments

Comments
 (0)