Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sf7 + removed symfony/templating #438

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
147 changes: 80 additions & 67 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,80 +1,93 @@
name: CI

on:
pull_request: ~
push:
branches:
- master
tags:
- '*'
pull_request: ~
push:
branches:
- master
tags:
- '*'

jobs:
coding-style:
name: Coding Style
runs-on: ubuntu-latest
steps:
- name: Setup PHP
uses: shivammathur/setup-php@2.9.0
with:
php-version: 7.4
extensions: dom, fileinfo, filter, gd, hash, intl, json, mbstring, pcre, pdo, zlib
coverage: none
coding-style:
name: Coding Style
runs-on: ubuntu-latest
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.0
extensions: dom, fileinfo, filter, gd, hash, intl, json, mbstring, pcre, pdo, zlib
coverage: none

- name: Checkout
uses: actions/checkout@v2
- name: Checkout
uses: actions/checkout@v3

- name: Install the dependencies
run: composer install --no-interaction --no-suggest
- name: Check the coding style
run: vendor/bin/php-cs-fixer fix --diff --dry-run
- name: Analyze the code
run: vendor/bin/phpstan analyze src/ tests/ --level=max
- name: Install the dependencies
run: composer install --no-interaction

tests:
name: PHP ${{ matrix.php }} / SF ^${{ matrix.symfony }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: [7.4, 8.0]
symfony: [4.4, 5.4, 6.0]
exclude:
# Symfony 6.0 does not supports php <8.0
- php: 7.4
symfony: 6.0
steps:
- name: Setup PHP
uses: shivammathur/setup-php@2.9.0
with:
php-version: ${{ matrix.php }}
extensions: dom, fileinfo, filter, gd, hash, intl, json, mbstring, pcre, pdo_mysql, zlib
coverage: none
- name: Check the coding style
run: vendor/bin/php-cs-fixer fix --diff --dry-run

- name: Checkout
uses: actions/checkout@v2
- name: Analyze the code
run: vendor/bin/phpstan analyze

- name: Install the dependencies
run: |
composer require symfony/framework-bundle:^${{ matrix.symfony }} symfony/http-foundation:^${{ matrix.symfony }}
composer install --no-interaction --no-suggest
- name: Run the unit tests
run: vendor/bin/phpunit --colors=always
tests:
name: PHP ${{ matrix.php }} / SF ^${{ matrix.symfony }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: [8.0, 8.1, 8.2]
symfony: [5.4, 6.0, 6.1, 6.2, 6.3, 6.4, 7.0]
exclude:
- php: 8.0
symfony: 6.1
- php: 8.0
symfony: 6.2
- php: 8.0
symfony: 6.3
- php: 8.0
symfony: 6.4
- php: 8.0
symfony: 7.0
- php: 8.1
symfony: 7.0
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, fileinfo, filter, gd, hash, intl, json, mbstring, pcre, pdo_mysql, zlib
coverage: none

prefer-lowest:
name: Prefer Lowest
runs-on: ubuntu-latest
steps:
- name: Setup PHP
uses: shivammathur/setup-php@2.7.0
with:
php-version: 7.4
extensions: dom, fileinfo, filter, gd, hash, intl, json, mbstring, pcre, pdo_mysql, zlib
coverage: none
- name: Checkout
uses: actions/checkout@v3

- name: Checkout
uses: actions/checkout@v2
- name: Install the dependencies
run: |
composer require symfony/framework-bundle:^${{ matrix.symfony }} symfony/http-foundation:^${{ matrix.symfony }}
composer install --no-interaction --no-suggest

- name: Install the dependencies
run: composer update --prefer-lowest --prefer-stable --no-interaction --no-suggest
- name: Run the unit tests
run: vendor/bin/phpunit --colors=always
- name: Run the unit tests
run: vendor/bin/phpunit --colors=always

prefer-lowest:
name: Prefer Lowest
runs-on: ubuntu-latest
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.0
extensions: dom, fileinfo, filter, gd, hash, intl, json, mbstring, pcre, pdo_mysql, zlib
coverage: none

- name: Checkout
uses: actions/checkout@v3

- name: Install the dependencies
run: composer update --prefer-lowest --prefer-stable --no-interaction

- name: Run the unit tests
run: vendor/bin/phpunit --colors=always
14 changes: 6 additions & 8 deletions .php_cs.dist → .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
<?php
use PhpCsFixer\Config;

$finder = PhpCsFixer\Finder::create()
->in([__DIR__ . '/src', __DIR__ . '/tests'])
->exclude(['App/cache', 'App/var'])
;

return PhpCsFixer\Config::create()
$config = new Config();
return $config
->setRules([
'@DoctrineAnnotation' => true,
'@Symfony' => true,
'@Symfony:risky' => true,
'@PHP71Migration' => true,
'@PHP71Migration:risky' => true,
'@PHP80Migration' => true,
'@PHP80Migration:risky' => true,
'@PHPUnit60Migration:risky' => true,
'@PHPUnit75Migration:risky' => true,
'align_multiline_comment' => true,
Expand All @@ -21,11 +23,7 @@
],
'combine_consecutive_issets' => true,
'combine_consecutive_unsets' => true,
'general_phpdoc_annotation_remove' => [
'author',
'expectedException',
'expectedExceptionMessage',
],
'general_phpdoc_annotation_remove' => true,
'heredoc_to_nowdoc' => true,
'linebreak_after_opening_tag' => true,
'list_syntax' => ['syntax' => 'short'],
Expand Down
30 changes: 14 additions & 16 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,33 +32,31 @@
}
],
"require": {
"php": "^7.4 || ^8.0",
"symfony/asset": "^4.4 || ^5.4 || ^6.0",
"php": "^8.0",
"symfony/asset": "^4.4 || ^5.4 || ^6.0 || ^7.0",
"symfony/event-dispatcher-contracts": "^1.0 || ^2.0 || ^3.0",
"symfony/finder": "^4.4 || ^5.4 || ^6.0",
"symfony/framework-bundle": "^4.4 || ^5.4 || ^6.0",
"symfony/mime": "^4.4 || ^5.4 || ^6.0",
"symfony/templating": "^4.4 || ^5.4 || ^6.0",
"symfony/translation": "^4.4 || ^5.4 || ^6.0",
"symfony/finder": "^4.4 || ^5.4 || ^6.0 || ^7.0",
"symfony/framework-bundle": "^4.4 || ^5.4 || ^6.0 || ^7.0",
"symfony/mime": "^4.4 || ^5.4 || ^6.0 || ^7.0",
"symfony/translation": "^4.4 || ^5.4 || ^6.0 || ^7.0",
"symfony/translation-contracts": "^1.0 || ^2.0 || ^3.0",
"symfony/yaml": "^4.4 || ^5.4 || ^6.0",
"symfony/yaml": "^4.4 || ^5.4 || ^6.0 || ^7.0",
"twig/twig": "^2.4 || ^3.0"
},
"require-dev": {
"amazonwebservices/aws-sdk-for-php": "1.5.*",
"doctrine/common": "^2.12 || ^3.0",
"doctrine/doctrine-bundle": "^2.4",
"friendsofphp/php-cs-fixer": "^2.16",
"friendsofphp/php-cs-fixer": "^3.40",
"knplabs/gaufrette": "^0.9",
"m2mtech/flysystem-stream-wrapper": "^1.0",
"oneup/flysystem-bundle": "^4.1",
"phpstan/phpstan": "^0.12.10",
"phpstan/phpstan": "^1.8",
"phpunit/phpunit": "^9.5",
"sensio/framework-extra-bundle": "^5.0 || ^6.0",
"m2mtech/flysystem-stream-wrapper": "^1.0",
"symfony/browser-kit": "^4.4 || ^5.4 || ^6.0",
"symfony/phpunit-bridge": "^5.4",
"symfony/security-bundle": "^4.4 || ^5.4 || ^6.0",
"symfony/var-dumper": "^4.4 || ^5.4 || ^6.0",
"symfony/browser-kit": "^4.4 || ^5.4 || ^6.0 || ^7.0",
"symfony/phpunit-bridge": "^6.0.17 || ^7.0",
"symfony/security-bundle": "^4.4 || ^5.4 || ^6.0 || ^7.0",
"symfony/var-dumper": "^4.4 || ^5.4 || ^6.0 || ^7.0",
"twistor/flysystem-stream-wrapper": "^1.0"
},
"suggest": {
Expand Down
10 changes: 7 additions & 3 deletions doc/custom_uploader.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,18 @@ namespace Acme\DemoBundle\Controller;
use Symfony\Component\HttpFoundation\File\Exception\UploadException;
use Symfony\Component\HttpFoundation\JsonResponse;
use Oneup\UploaderBundle\Controller\UploaderController;
use Oneup\UploaderBundle\Uploader\Response\EmptyResponse;
use Oneup\UploaderBundle\Uploader\Response\EmptyResponse;use Symfony\Component\HttpFoundation\RequestStack;

class CustomUploader extends UploaderController
{

public function __construct(protected RequestStack $requestStack) {
}

public function upload()
{
// get some basic stuff together
$request = $this->container->get('request_stack')->getMasterRequest();
$request = $this->requestStack->getMainRequest();
$response = new EmptyResponse();

// get file from request (your own logic)
Expand Down Expand Up @@ -100,7 +104,7 @@ class FineUploaderResponse extends AbstractResponse
public function assemble()
{
// explicitly overwrite success and error key
// as these keys are used internaly by the
// as these keys are used internally by the
// frontend uploader
$data = $this->data;
$data['success'] = $this->success;
Expand Down
33 changes: 28 additions & 5 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,21 +1,44 @@
parameters:
bootstrapFiles:
- %rootDir%/../../../vendor/autoload.php

excludes_analyse:
level: 9
paths:
- src
- tests
excludePaths:
- src/DependencyInjection/Configuration.php
- tests/App/cache
- tests/App/logs
- tests/App/var
- var
- vendor

checkGenericClassInNonGenericObjectType: false
checkMissingIterableValueType: false
reportUnmatchedIgnoredErrors: false

ignoreErrors:
- '#Cannot cast mixed to int\.#'
- '#Cannot call method addListener\(\) on mixed\.#'
- '#Cannot call method getSize\(\) on mixed\.#'
- '#Cannot call method maxSize\(\) on mixed\.#'
- '#Cannot call method getPathname\(\) on mixed\.#'
- '#Cannot call method getPath\(\) on mixed\.#'
- '#Cannot call method getRealPath\(\) on mixed\.#'
- '#Cannot call method getBasename\(\) on mixed\.#'
- '#Method Symfony\\Contracts\\EventDispatcher\\EventDispatcherInterface::dispatch\(\) invoked with 2 parameters, 1 required\.#'
-
message: '#Cannot use array destructuring on array<int, string>\|false\.#'
path: '%currentWorkingDirectory%/src/Controller/BlueimpController.php'
-
message: '#Binary operation "/" between string and int results in an error\.#'
path: '%currentWorkingDirectory%/src/Controller/BlueimpController.php'
-
message: '#Dead catch - Gaufrette\\Exception\\FileNotFound is never thrown in the try block\.#'
path: '%currentWorkingDirectory%/src/Uploader/Chunk/Storage/GaufretteStorage.php'
-
message: '#Parameter \#1 \$finfo of function finfo_file|finfo_close expects finfo, resource given\.#'
path: '%currentWorkingDirectory%/src/Uploader/File/GaufretteFile.php'
-
message: '#Parameter \#2 ...\$values of function sprintf expects bool\|float\|int\|string\|null, mixed given\.#'
path: '%currentWorkingDirectory%/src/Controller/PluploadController.php'
-
message: '#Parameter \#1 \$parameters of class Symfony\\Component\\HttpFoundation\\FileBag constructor expects array<Symfony\\Component\\HttpFoundation\\File\\UploadedFile>, array<int, Symfony\\Component\\HttpFoundation\\File\\UploadedFile\|null> given\.#'
path: '%currentWorkingDirectory%/tests/Controller/FileBagExtractorTest.php'
6 changes: 4 additions & 2 deletions src/Command/ClearChunkCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@
namespace Oneup\UploaderBundle\Command;

use Oneup\UploaderBundle\Uploader\Chunk\ChunkManager;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

#[AsCommand(
name: 'oneup:uploader:clear-chunks'
)]
class ClearChunkCommand extends Command
{
protected static $defaultName = 'oneup:uploader:clear-chunks'; // Make command lazy load

/**
* @var ChunkManager
*/
Expand Down
6 changes: 4 additions & 2 deletions src/Command/ClearOrphansCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@
namespace Oneup\UploaderBundle\Command;

use Oneup\UploaderBundle\Uploader\Orphanage\OrphanageManager;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

#[AsCommand(
name: 'oneup:uploader:clear-orphans'
)]
class ClearOrphansCommand extends Command
{
protected static $defaultName = 'oneup:uploader:clear-orphans';

/**
* @var OrphanageManager
*/
Expand Down
6 changes: 5 additions & 1 deletion src/Controller/AbstractChunkedController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Oneup\UploaderBundle\Event\PostChunkUploadEvent;
use Oneup\UploaderBundle\Uploader\Chunk\ChunkManagerInterface;
use Oneup\UploaderBundle\Uploader\Response\ResponseInterface;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\HttpFoundation\Request;

Expand Down Expand Up @@ -70,7 +71,10 @@ protected function handleChunkedUpload(UploadedFile $file, ResponseInterface $re
// with reassembling the parts
if ($last) {
$path = $assembled->getPath();
$this->handleUpload($assembled, $response, $request);
if ($assembled instanceof File) {
$this->handleUpload($assembled, $response, $request);
}
// @todo $assembled is of type mixed, so would error without check

$chunkManager->cleanup($path);
}
Expand Down
Loading
Loading