Skip to content

Commit

Permalink
chore: bumped
Browse files Browse the repository at this point in the history
  • Loading branch information
roadiz-ci committed Sep 16, 2024
1 parent 9a7d391 commit c6b0956
Show file tree
Hide file tree
Showing 38 changed files with 2,071 additions and 1,414 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/run-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php-version: ['8.1', '8.2', '8.3']
php-version: ['8.0', '8.1']
steps:
- uses: shivammathur/setup-php@v2
with:
Expand All @@ -35,8 +35,8 @@ jobs:
${{ runner.os }}-php-${{ matrix.php-version }}-
- name: Install Dependencies
run: composer install --no-scripts --no-ansi --no-interaction --no-progress
- name: Run Unit tests
run: vendor/bin/phpunit -v --whitelist ./src tests
- name: Run atoum unit tests
run: vendor/bin/atoum -d tests
- name: Run PHP Code Sniffer
run: vendor/bin/phpcs -p ./src
- name: Run PHPStan
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#
# Roadiz
#
/pimple.json

# Ignore Google webmaster tool verification
/google*.html
Expand Down
19 changes: 19 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
language: php
sudo: required
php:
- 7.4
- 8.0
- 8.1
- nightly
env:
- XDEBUG_MODE=coverage
install:
- curl -s http://getcomposer.org/installer | php
- php composer.phar install --dev --no-interaction
script:
- vendor/bin/phpcs --report=full --report-file=./report.txt -p ./src
- vendor/bin/atoum -d tests
- vendor/bin/phpstan analyse -c phpstan.neon
jobs:
allow_failures:
- php: nightly
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright © 2024 Ambroise Maupate
Copyright © 2023 Ambroise Maupate

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
13 changes: 13 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
test:
vendor/bin/atoum -d tests
vendor/bin/phpstan analyse -c phpstan.neon
vendor/bin/phpcs --report=full --report-file=./report.txt -p ./src

dev-test:
vendor/bin/atoum -d tests -l

phpcs:
vendor/bin/phpcs --report=full --report-file=./report.txt -p ./src

phpcbf:
vendor/bin/phpcbf --report=full --report-file=./report.txt -p ./src
32 changes: 13 additions & 19 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,34 +18,33 @@
}
],
"require": {
"php": ">=8.1",
"php": ">=8.0",
"ext-json": "*",
"ext-gd": "*",
"ext-dom": "*",
"ext-zip": "*",
"ext-simplexml": "*",
"ext-fileinfo": "*",
"doctrine/orm": "~2.19.0",
"doctrine/orm": "<2.17",
"enshrined/svg-sanitize": "^0.15",
"guzzlehttp/guzzle": "^7.2.0",
"guzzlehttp/psr7": "^2.0",
"intervention/image": "^2.5",
"league/flysystem": "^3.0",
"monolog/monolog": "^1.24.0 || ^2.1.1",
"symfony/asset": "6.4.*",
"symfony/console": "6.4.*",
"symfony/event-dispatcher": "6.4.*",
"symfony/filesystem": "6.4.*",
"symfony/finder": "6.4.*",
"symfony/http-foundation": "6.4.*",
"symfony/options-resolver": "6.4.*",
"symfony/serializer": "6.4.*",
"symfony/asset": "5.4.*",
"symfony/console": "5.4.*",
"symfony/event-dispatcher": "5.4.*",
"symfony/filesystem": "5.4.*",
"symfony/finder": "5.4.*",
"symfony/http-foundation": "5.4.*",
"symfony/options-resolver": "5.4.*",
"symfony/serializer": "5.4.*",
"twig/twig": "^3.1"
},
"require-dev": {
"php-coveralls/php-coveralls": "^2.4",
"phpunit/phpunit": "^9.5",
"api-platform/metadata": "^3.2.12",
"atoum/atoum": "^4.0.0",
"squizlabs/php_codesniffer": "^3.5",
"phpstan/phpstan": "^1.5.3",
"phpstan/phpstan-doctrine": "^1.3"
Expand All @@ -55,11 +54,6 @@
"RZ\\Roadiz\\Documents\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"RZ\\Roadiz\\Documents\\Tests\\": "tests/"
}
},
"config": {
"allow-plugins": {
"composer/package-versions-deprecated": true,
Expand All @@ -68,8 +62,8 @@
},
"extra": {
"branch-alias": {
"dev-master": "2.3.x-dev",
"dev-develop": "2.4.x-dev"
"dev-master": "2.1.x-dev",
"dev-develop": "2.2.x-dev"
}
}
}
11 changes: 11 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: "3"
services:
test80:
image: roadiz/php80-runner
working_dir: /build
command: >
bash -c "
composer install -o &&
make test"
volumes:
- ./:/build
8 changes: 3 additions & 5 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
parameters:
level: 7
level: max
paths:
- src
excludePaths:
- */node_modules/*
- */bower_components/*
- */static/*
ignoreErrors:
- identifier: missingType.iterableValue
- identifier: missingType.generics
- '#Call to an undefined method Doctrine\\Persistence\\ObjectRepository#'
- '#Call to an undefined method Doctrine\\Persistence\\ObjectManager#'
- '#Call to an undefined method Doctrine\\ORM\\EntityRepository#'
Expand All @@ -19,9 +17,9 @@ parameters:
- '#Doctrine\\ORM\\Mapping\\GeneratedValue constructor expects#'
- '#type mapping mismatch: property can contain Doctrine\\Common\\Collections\\Collection<int, [^\>]+> but database expects Doctrine\\Common\\Collections\\Collection&iterable<[^\>]+>#'
- '#should return Doctrine\\Common\\Collections\\Collection<int, [^\>]+Interface> but returns Doctrine\\Common\\Collections\\Collection<int, [^\>]+>#'
- '#but returns Doctrine\\Common\\Collections\\ReadableCollection<int, [^\>]+>#'
- '#does not accept Doctrine\\Common\\Collections\\ReadableCollection<int, [^\>]+>#'
reportUnmatchedIgnoredErrors: false
checkMissingIterableValueType: false
checkGenericClassInNonGenericObjectType: false

includes:
- vendor/phpstan/phpstan-doctrine/extension.neon
Expand Down
5 changes: 1 addition & 4 deletions src/AbstractDocumentFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,7 @@ public function findPicturesWithFilename(string $fileName): iterable
{
$pathInfo = pathinfo($fileName);
$basename = $pathInfo['filename'];
$currentExtension = $pathInfo['extension'] ?? null;
if (null === $currentExtension) {
return [];
}
$currentExtension = $pathInfo['extension'];

Check failure on line 56 in src/AbstractDocumentFinder.php

View workflow job for this annotation

GitHub Actions / run-tests (8.0)

Offset 'extension' does not exist on array{dirname?: string, basename: string, extension?: string, filename: string}.
$extensionsList = [
'jpg',
'gif',
Expand Down
4 changes: 2 additions & 2 deletions src/Console/DocumentClearFolderCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ protected function getDocumentQueryBuilder(FolderInterface $folder): QueryBuilde
protected function execute(InputInterface $input, OutputInterface $output): int
{
$this->io = new SymfonyStyle($input, $output);
$folderId = $input->getArgument('folderId');

if (!\is_numeric($folderId) || $folderId <= 0) {
$folderId = intval($input->getArgument('folderId'));

Check failure on line 40 in src/Console/DocumentClearFolderCommand.php

View workflow job for this annotation

GitHub Actions / run-tests (8.0)

Parameter #1 $value of function intval expects array|bool|float|int|resource|string|null, mixed given.
if ($folderId <= 0) {
throw new \InvalidArgumentException('Folder ID must be a valid ID');
}
$em = $this->getManager();
Expand Down
19 changes: 7 additions & 12 deletions src/DocumentArchiver.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,21 @@
*/
final class DocumentArchiver
{
public function __construct(private readonly FilesystemOperator $documentsStorage)
private FilesystemOperator $documentsStorage;

public function __construct(FilesystemOperator $documentsStorage)
{
$this->documentsStorage = $documentsStorage;
}

/**
* @param iterable<DocumentInterface> $documents
* @param array $documents
* @param string $name
* @param bool $keepFolders
* @return string Zip file path
* @throws FilesystemException
*/
public function archive(iterable $documents, string $name, bool $keepFolders = true): string
public function archive(array $documents, string $name, bool $keepFolders = true): string
{
$filename = (new AsciiSlugger())->slug($name . ' ' . date('YmdHis'), '_') . '.zip';
$tmpFileName = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $filename;
Expand Down Expand Up @@ -57,16 +60,8 @@ public function archive(iterable $documents, string $name, bool $keepFolders = t
return $tmpFileName;
}

/**
* @param iterable<DocumentInterface> $documents
* @param string $name
* @param bool $keepFolders
* @param bool $unlink
* @return BinaryFileResponse
* @throws FilesystemException
*/
public function archiveAndServe(
iterable $documents,
array $documents,
string $name,
bool $keepFolders = true,
bool $unlink = true
Expand Down
27 changes: 20 additions & 7 deletions src/DownscaleImageManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,27 @@

final class DownscaleImageManager
{
protected EntityManagerInterface $em;
protected ?LoggerInterface $logger;
protected int $maxPixelSize = 0;
protected string $rawImageSuffix = ".raw";
protected ImageManager $imageManager;
private FilesystemOperator $documentsStorage;

public function __construct(
private readonly EntityManagerInterface $em,
private readonly FilesystemOperator $documentsStorage,
private readonly ImageManager $imageManager,
private readonly ?LoggerInterface $logger = null,
private readonly int $maxPixelSize = 0,
private readonly string $rawImageSuffix = ".raw"
EntityManagerInterface $em,
FilesystemOperator $documentsStorage,
ImageManager $imageManager,
?LoggerInterface $logger = null,
int $maxPixelSize = 0,
string $rawImageSuffix = ".raw"
) {
$this->maxPixelSize = $maxPixelSize;
$this->rawImageSuffix = $rawImageSuffix;
$this->em = $em;
$this->logger = $logger;
$this->imageManager = $imageManager;
$this->documentsStorage = $documentsStorage;
}

/**
Expand Down Expand Up @@ -84,7 +97,7 @@ public function processDocumentFromExistingRaw(?DocumentInterface $document = nu
null !== $this->createDocumentFromImage($document, $processImage, true)
&& null !== $this->logger
) {
$this->logger->info('Document has been downscaled.', ['path' => $documentPath, 'entity' => $document]);
$this->logger->info('Document has been downscaled.', ['path' => $documentPath]);
}
}
}
Expand Down
8 changes: 7 additions & 1 deletion src/Exceptions/DocumentWithoutFileException.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,17 @@

final class DocumentWithoutFileException extends \RuntimeException
{
public function __construct(private readonly DocumentInterface $document)
private DocumentInterface $document;

public function __construct(DocumentInterface $document)
{
$this->document = $document;
parent::__construct(sprintf('Document (%s) does not have a file on system.', (string) $document));
}

/**
* @return DocumentInterface
*/
public function getDocument(): DocumentInterface
{
return $this->document;
Expand Down
13 changes: 12 additions & 1 deletion src/Models/AdvancedDocumentInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,19 @@

namespace RZ\Roadiz\Documents\Models;

interface AdvancedDocumentInterface extends DocumentInterface, SizeableInterface, DisplayableInterface
interface AdvancedDocumentInterface extends DocumentInterface, SizeableInterface
{
/**
* @return string|null
*/
public function getImageAverageColor(): ?string;

/**
* @param string|null $imageAverageColor
* @return $this
*/
public function setImageAverageColor(?string $imageAverageColor): static;

/**
* @return int|null
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Models/DocumentInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public function setRawDocument(?DocumentInterface $rawDocument = null): static;
public function isRaw(): bool;

/**
* @param bool $raw the raw
* @param boolean $raw the raw
* @return $this
*/
public function setRaw(bool $raw): static;
Expand Down
Loading

0 comments on commit c6b0956

Please sign in to comment.