Skip to content

Commit

Permalink
Remove support for PHP 8.0, cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mbardelmeijer committed Feb 9, 2022
1 parent c4f4222 commit 28fa90b
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
fail-fast: true
matrix:
os: [ubuntu-latest]
php: [8.0]
php: [8.1]
dependency-version: [prefer-stable, prefer-lowest]

name: P${{ matrix.php }} - ${{ matrix.dependency-version }} - ${{ matrix.os }}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ sudo pip install unoserver
```

## Converters
It's highly recommend using the new `unoconvert` converter. If you are unable to upgrade, we still provide the deprecated `UnoconvConverter` for the time being.
It's highly recommend using the new `unoconvert` converter. If you are unable to upgrade, we still provide the deprecated `UnoconvConverter` for the time being. `UnoconvConverter` is deprecated and will be removed in 3.0.

## Server
Unoserver works together with unoconvert. Unoserver runs as a daemon on the server, and unoconvert connects through it to pass the files. To see why this is more efficient, see https://github.com/unoconv/unoserver/#overview
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
}
],
"require": {
"php": "^8.0",
"php": "^8.1",
"phpoffice/phpword": "^0.18.2",
"symfony/process": "^5.0|^6.0"
"symfony/process": "^6.0"
},
"require-dev": {
"phpunit/phpunit": "^9.0",
"friendsofphp/php-cs-fixer": "^3.0"
"phpunit/phpunit": "^9.5",
"friendsofphp/php-cs-fixer": "^3.2"
},
"autoload": {
"psr-4": {
Expand Down
5 changes: 1 addition & 4 deletions src/Converters/AbstractConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@

abstract class AbstractConverter
{
private function __construct(
protected DocumentReplacer $documentReplacer,
protected array $options
) {
private function __construct(protected DocumentReplacer $documentReplacer, protected array $options) {
}

public static function make(DocumentReplacer $documentReplacer, array $options = []): self
Expand Down
1 change: 1 addition & 0 deletions src/Converters/UnoconvConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Symfony\Component\Process\Process;

/** @deprecated */
/** Will be removed in 3.0 */
class UnoconvConverter extends AbstractConverter
{
private const BINARY = '/usr/bin/unoconv';
Expand Down
6 changes: 2 additions & 4 deletions src/DocumentReplacer.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,13 @@

class DocumentReplacer
{
private Template $template;
private TemplateProcessor $templateProcessor;
private ?string $converter = null;
private array $converterOptions = [];

private function __construct(Template $template)
private function __construct(private Template $template)
{
$this->template = $template;
$this->templateProcessor = new TemplateProcessor($this->template->path());
$this->templateProcessor = new TemplateProcessor($template->path());
}

public function variables(): array
Expand Down
4 changes: 1 addition & 3 deletions src/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class Template
{
private function __construct(string $path)
private function __construct(private string $path)
{
if (! file_exists($path)) {
throw new InvalidArgumentException("File at '{$path}' cannot be found.");
Expand All @@ -15,8 +15,6 @@ private function __construct(string $path)
if (! is_file($path)) {
throw new InvalidArgumentException("File at '{$path}' must be a file.");
}

$this->path = $path;
}

public function path(): string
Expand Down
13 changes: 5 additions & 8 deletions src/ValueTypes/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,13 @@

class Image
{
/** @var string|Closure */
private $image;

private ?bool $ratio = null;
private ?int $width = null;
private ?int $height = null;

private function __construct($image)
private function __construct(private Closure|string $image)
{
$this->image = $image;

}

public static function forPath(string $path): self
Expand All @@ -26,7 +23,7 @@ public static function forPath(string $path): self
public static function forBase64(string $base64data): self
{
// strip out data uri scheme information (see RFC 2397)
if (strpos($base64data, ';base64') !== false) {
if (str_contains($base64data, ';base64')) {
[$_, $base64data] = explode(';', $base64data);
[$_, $base64data] = explode(',', $base64data);
}
Expand All @@ -36,14 +33,14 @@ public static function forBase64(string $base64data): self

public static function forBinary($binary): self
{
// temporarily store the decoded data on the filesystem to be able to pass it trough the template replacer
// Temporarily store the decoded data on the filesystem to be able to pass it through the template replacer
$tmpFile = tempnam(sys_get_temp_dir(), 'document-replacer');
file_put_contents($tmpFile, $binary);

return new static($tmpFile);
}

public static function lazy(Closure $closure)
public static function lazy(Closure $closure): self
{
return new static($closure);
}
Expand Down

0 comments on commit 28fa90b

Please sign in to comment.