Skip to content

Commit

Permalink
Add all changes from styleCi
Browse files Browse the repository at this point in the history
  • Loading branch information
tarjei committed May 15, 2024
1 parent 060c305 commit 43625fd
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 15 deletions.
3 changes: 0 additions & 3 deletions src/Event/ErrorEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Vich\UploaderBundle\Event;


use Vich\UploaderBundle\Mapping\PropertyMapping;

class ErrorEvent extends Event
Expand All @@ -19,6 +18,4 @@ public function getThrowable(): \Throwable
{
return $this->throwable;
}


}
2 changes: 1 addition & 1 deletion src/Event/Events.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ final class Events
*
* @Event("Vich\UploaderBundle\Event\Event")
*/
public const POST_REMOVE = 'vich_uploader.post_remove';
public const POST_REMOVE = 'vich_uploader.post_remove';

/**
* Triggered if writing to storage fails.
Expand Down
3 changes: 1 addition & 2 deletions src/Handler/UploadHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Vich\UploaderBundle\Handler;

use Symfony\Component\HttpFoundation\File\Exception\CannotWriteFileException;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
use Vich\UploaderBundle\Event\ErrorEvent;
Expand Down Expand Up @@ -50,7 +49,7 @@ public function upload(object $obj, string $fieldName): void
$this->dispatch(Events::PRE_UPLOAD, new Event($obj, $mapping));
try {
$this->storage->upload($obj, $mapping);
} catch(\Throwable $exception) {
} catch (\Throwable $exception) {
$this->dispatch(Events::UPLOAD_ERROR, new ErrorEvent($obj, $mapping, $exception));
throw $exception;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Storage/FileSystemStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ protected function doRemove(PropertyMapping $mapping, ?string $dir, string $name
$file = $this->doResolvePath($mapping, $dir, $name);

if (!\file_exists($file) || !unlink($file)) {
throw new \Exception("Cannot remove file ".$file);
throw new \Exception('Cannot remove file '.$file);
}

return true;
Expand Down
1 change: 0 additions & 1 deletion src/Storage/GaufretteStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Vich\UploaderBundle\Storage;

use Gaufrette\Adapter\MetadataSupporter;
use Gaufrette\Exception\FileNotFound;
use Gaufrette\FilesystemInterface;
use Gaufrette\FilesystemMapInterface;
use Symfony\Component\HttpFoundation\File\File;
Expand Down
1 change: 1 addition & 0 deletions src/Storage/StorageInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public function upload(object $obj, PropertyMapping $mapping): void;
*
* @param object $obj The object
* @param PropertyMapping $mapping The mapping representing the field to remove
*
* @throw \Exception Throws an exception
*/
public function remove(object $obj, PropertyMapping $mapping): ?bool;
Expand Down
11 changes: 4 additions & 7 deletions tests/Handler/UploadHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ public function testRemoveFailsInStorageDriverEmitsEvent(): void
->expects(self::once())
->method('remove')
->with($this->object, $this->mapping)
->willThrowException(new \RuntimeException("Test exception"))
->willThrowException(new \RuntimeException('Test exception'))
;

$this->handler->remove($this->object, self::FILE_FIELD);
Expand All @@ -223,7 +223,6 @@ public function testUploadFailsEmitsEventAndException(): void

$this->expectEvents([Events::PRE_UPLOAD, Events::UPLOAD_ERROR]);


$this->mapping
->expects(self::once())
->method('getFile')
Expand All @@ -234,15 +233,14 @@ public function testUploadFailsEmitsEventAndException(): void
->expects(self::once())
->method('upload')
->with($this->object, $this->mapping)
->willThrowException(new \RuntimeException("This is a test"));
->willThrowException(new \RuntimeException('This is a test'));

$this->injector
->expects(self::never())
->method('injectFile')
->with($this->object, $this->mapping);

$this->handler->upload($this->object, self::FILE_FIELD);

}

public function testremoveFailsWithCannotWriteException(): void
Expand All @@ -262,12 +260,11 @@ public function testremoveFailsWithCannotWriteException(): void
->expects(self::once())
->method('remove')
->with($this->object, $this->mapping)
->willThrowException(new CannotWriteFileException("this is a test"));

->willThrowException(new CannotWriteFileException('this is a test'));

$this->handler->remove($this->object, self::FILE_FIELD);

}

public function testRemoveIfEventIsCanceled(): void
{
$this->expectEvents([Events::PRE_REMOVE]);
Expand Down

0 comments on commit 43625fd

Please sign in to comment.