Skip to content

Commit

Permalink
chore: Bumped
Browse files Browse the repository at this point in the history
  • Loading branch information
roadiz-ci committed Jun 6, 2024
1 parent 7746677 commit 8fba305
Show file tree
Hide file tree
Showing 27 changed files with 1,960 additions and 1,372 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/run-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 --coverage-clover ./build/logs/clover.xml src/Test
- 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
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
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
test:
vendor/bin/phpunit -v --whitelist ./src --coverage-clover ./build/logs/clover.xml src/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/phpunit -v --whitelist ./src --coverage-clover ./build/logs/clover.xml src/Test
vendor/bin/atoum -d tests -l

phpcs:
vendor/bin/phpcs --report=full --report-file=./report.txt -p ./src
Expand Down
25 changes: 12 additions & 13 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,26 @@
"ext-zip": "*",
"ext-simplexml": "*",
"ext-fileinfo": "*",
"doctrine/orm": "~2.19.0",
"doctrine/orm": "~2.17.0",
"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 @@ -63,8 +62,8 @@
},
"extra": {
"branch-alias": {
"dev-master": "2.3.x-dev",
"dev-develop": "2.4.x-dev"
"dev-master": "2.2.x-dev",
"dev-develop": "2.3.x-dev"
}
}
}
6 changes: 3 additions & 3 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 @@ -22,6 +20,8 @@ parameters:
- '#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
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.1)

Parameter #1 $value of function intval expects array|bool|float|int|resource|string|null, mixed given.

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

View workflow job for this annotation

GitHub Actions / run-tests (8.2)

Parameter #1 $value of function intval expects array|bool|float|int|resource|string|null, mixed given.

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

View workflow job for this annotation

GitHub Actions / run-tests (8.3)

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
108 changes: 38 additions & 70 deletions src/Models/DocumentTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace RZ\Roadiz\Documents\Models;

use ApiPlatform\Metadata\ApiProperty;
use Symfony\Component\Serializer\Annotation as SymfonySerializer;

trait DocumentTrait
Expand All @@ -13,7 +12,6 @@ trait DocumentTrait
* Associate mime type to simple types.
*
* - code
* - text
* - image
* - word
* - video
Expand All @@ -23,116 +21,86 @@ trait DocumentTrait
* - excel
* - powerpoint
* - font
* - 3d
*
* @var array<string, string>
* @internal
*/
#[SymfonySerializer\Ignore()]
protected static array $mimeToIcon = [
// Code
'text/html' => 'code',
'application/javascript' => 'code',
'application/json' => 'code',
'application/ld+json' => 'code',
'text/css' => 'code',
'text/html' => 'code',
'text/rtf' => 'word',
'text/xml' => 'code',
// Text
'text/plain' => 'text',
// Images types
'image/avif' => 'image',
'image/bmp' => 'image',
'image/png' => 'image',
'image/jpeg' => 'image',
'image/gif' => 'image',
'image/tiff' => 'image',
'image/webp' => 'image',
'image/avif' => 'image',
'image/heic' => 'image',
'image/heif' => 'image',
'image/jpeg' => 'image',
'image/png' => 'image',
'image/svg' => 'image',
'image/svg+xml' => 'image',
'image/tiff' => 'image',
'image/vnd.microsoft.icon' => 'image',
'image/webp' => 'image',
'image/x-icon' => 'image',
// PDF
'application/pdf' => 'pdf',
// Audio types
'audio/mpeg' => 'audio',
'audio/x-m4a' => 'audio',
'audio/x-wav' => 'audio',
'audio/wav' => 'audio',
'audio/aac' => 'audio',
'audio/ac3' => 'audio',
'audio/eac3' => 'audio',
'audio/flac' => 'audio',
'audio/matroska' => 'audio',
'audio/mp4' => 'audio',
'audio/mpeg' => 'audio',
'audio/webm' => 'audio',
'audio/ogg' => 'audio',
'audio/vorbis' => 'audio',
'audio/wav' => 'audio',
'audio/webm' => 'audio',
'audio/x-m4a' => 'audio',
'audio/ac3' => 'audio',
'audio/x-matroska' => 'audio',
'audio/x-wav' => 'audio',
// Video types
'application/ogg' => 'video',
'video/3gpp' => 'video',
'video/3gpp-tt' => 'video',
'video/3gpp2' => 'video',
'video/VP8' => 'video',
'video/matroska' => 'video',
'video/matroska-3d' => 'video',
'video/mp4' => 'video',
'video/mpeg' => 'video',
'video/ogg' => 'video',
'video/quicktime' => 'video',
'video/webm' => 'video',
'video/x-flv' => 'video',
'video/mpeg' => 'video',
'video/mp4' => 'video',
'video/x-m4v' => 'video',
'video/quicktime' => 'video',
'video/x-flv' => 'video',
'video/3gpp' => 'video',
'video/3gpp2' => 'video',
'video/3gpp-tt' => 'video',
'video/VP8' => 'video',
'video/x-matroska' => 'video',
// Epub type
'application/epub+zip' => 'epub',
// Archives types
'application/gzip' => 'archive',
'application/zip' => 'archive',
'application/x-bzip2' => 'archive',
'application/x-tar' => 'archive',
'application/x-7z-compressed' => 'archive',
'application/x-apple-diskimage' => 'archive',
'application/x-bzip2' => 'archive',
'application/x-rar-compressed' => 'archive',
'application/x-tar' => 'archive',
'application/zip' => 'archive',
// Office types
'application/msword' => 'word',
'application/vnd.ms-excel' => 'excel',
'application/vnd.ms-office' => 'excel',
'application/vnd.ms-powerpoint' => 'powerpoint',
'application/vnd.oasis.opendocument.presentation' => 'powerpoint',
'application/vnd.oasis.opendocument.spreadsheet' => 'excel',
'application/vnd.openxmlformats-officedocument.wordprocessingml.document' => 'word',
'application/vnd.oasis.opendocument.text ' => 'word',
'application/vnd.openxmlformats-officedocument.presentationml.presentation' => 'powerpoint',
'application/vnd.openxmlformats-officedocument.presentationml.slideshow' => 'powerpoint',
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' => 'excel',
'application/vnd.openxmlformats-officedocument.spreadsheetml.template' => 'excel',
'application/vnd.openxmlformats-officedocument.wordprocessingml.document' => 'word',
'text/rtf' => 'word',
'application/vnd.oasis.opendocument.spreadsheet' => 'excel',
'application/vnd.openxmlformats-officedocument.presentationml.slideshow' => 'powerpoint',
'application/vnd.oasis.opendocument.presentation' => 'powerpoint',
'application/vnd.openxmlformats-officedocument.presentationml.presentation' => 'powerpoint',
// Fonts types
'image/svg+xml' => 'font',
'application/x-font-ttf' => 'font',
'application/x-font-truetype' => 'font',
'application/x-font-opentype' => 'font',
'application/font-woff' => 'font',
'application/font-woff2' => 'font',
'application/vnd.ms-fontobject' => 'font',
'application/x-font-opentype' => 'font',
'application/x-font-truetype' => 'font',
'application/x-font-ttf' => 'font',
'font/opentype' => 'font',
'font/ttf' => 'font',
'font/woff' => 'font',
'font/woff2' => 'font',
// 3d
'model/gltf+binary' => '3d',
'model/gltf+json' => '3d',
'model/gltf-binary' => '3d',
'model/mtl' => '3d',
'model/obj' => '3d',
'model/stl' => '3d',
'model/u3d' => '3d',
'model/vnd.gltf+json' => '3d',
'model/vnd.gltf.binary' => '3d',
'model/vnd.usda' => '3d',
'model/vnd.usdz+zip' => '3d',
];

/**
Expand Down Expand Up @@ -309,14 +277,14 @@ protected function initDocumentTrait(): void
#[
SymfonySerializer\Groups(["document", "document_display", "nodes_sources", "tag", "attribute"]),
SymfonySerializer\SerializedName("processable"),
ApiProperty(
description: 'Document can be processed as an image for resampling and other image operations.',
writable: false,
)
]
public function isProcessable(): bool
{
return $this->isImage() && in_array($this->getMimeType(), static::$processableMimeTypes, true);
if ($this->isImage() && in_array($this->getMimeType(), static::$processableMimeTypes)) {
return true;
}

return false;
}

#[
Expand Down
Loading

0 comments on commit 8fba305

Please sign in to comment.