cs: Fix code style (safe rules only).

This commit is contained in:
Pol Dellaiera
2021-11-23 14:06:38 +01:00
parent 149d7ce991
commit 8f96a1121d
1223 changed files with 65199 additions and 64625 deletions

View File

@@ -1,6 +1,8 @@
<?php
/**
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/

View File

@@ -1,6 +1,8 @@
<?php
/**
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
@@ -22,22 +24,26 @@ use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Routing\RouterInterface;
use Symfony\Component\Security\Core\Security;
/**
* @internal
* @coversNothing
*/
final class Test
{
private DiscoveryInterface $wopiDiscovery;
private DocumentManagerInterface $documentManager;
private ConfigurationInterface $wopiConfiguration;
private ResponderInterface $responder;
private Security $security;
private Psr17Interface $psr17;
private ResponderInterface $responder;
private RouterInterface $router;
private Security $security;
private ConfigurationInterface $wopiConfiguration;
private DiscoveryInterface $wopiDiscovery;
public function __construct(
ConfigurationInterface $wopiConfiguration,
DiscoveryInterface $wopiDiscovery,
@@ -88,7 +94,7 @@ final class Test
],
UrlGeneratorInterface::ABSOLUTE_URL
),
'closebutton' => 1
'closebutton' => 1,
]
)
);
@@ -99,6 +105,5 @@ final class Test
'@ChillWopi/Editor/page.html.twig',
$configuration
);
}
}

View File

@@ -1,6 +1,8 @@
<?php
/**
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/

View File

@@ -1,6 +1,8 @@
<?php
/**
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/

View File

@@ -1,6 +1,8 @@
<?php
/**
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/

View File

@@ -1,6 +1,8 @@
<?php
/**
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
@@ -10,10 +12,10 @@ declare(strict_types=1);
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
use ChampsLibres\AsyncUploaderBundle\TempUrl\TempUrlGeneratorInterface;
use Chill\WopiBundle\Service\Wopi\ChillWopi;
use ChampsLibres\WopiBundle\Service\Wopi as CLWopi;
use ChampsLibres\WopiLib\Contract\Service\DocumentManagerInterface;
use Chill\WopiBundle\Service\Wopi\ChillDocumentManager;
use Chill\WopiBundle\Service\Wopi\ChillWopi;
return static function (ContainerConfigurator $container) {
$services = $container

View File

@@ -1,6 +1,8 @@
<?php
/**
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/

View File

@@ -1,6 +1,8 @@
<?php
/**
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/

View File

@@ -1,6 +1,8 @@
<?php
/**
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
@@ -86,14 +88,16 @@ final class ChillDocumentManager implements DocumentManagerInterface
return $document;
}
public function deleteLock(Document $document): void {
public function deleteLock(Document $document): void
{
$this->documentLockManager->deleteLock($document, $this->request);
}
/**
* @param string $documentFilename without extension !
*/
public function findByDocumentFilename(string $documentFilename): ?Document {
public function findByDocumentFilename(string $documentFilename): ?Document
{
return $this->storedObjectRepository->findOneBy(
[
'filename' => $documentFilename,
@@ -101,7 +105,8 @@ final class ChillDocumentManager implements DocumentManagerInterface
);
}
public function findByDocumentId(string $documentId): ?Document {
public function findByDocumentId(string $documentId): ?Document
{
return $this->storedObjectRepository->findOneBy(
[
'uuid' => Uuid::fromString($documentId),
@@ -109,6 +114,22 @@ final class ChillDocumentManager implements DocumentManagerInterface
);
}
/**
* @param StoredObject $document
*
* @return string The document filename with its extension.
*/
public function getBasename(Document $document): string
{
$exts = (new MimeTypes())->getExtensions($document->getType());
if ([] === $exts) {
throw new Error('Unknown mimetype for stored document.');
}
return sprintf('%s.%s', $document->getFilename(), reset($exts));
}
/**
* @param StoredObject $document
*/
@@ -117,6 +138,14 @@ final class ChillDocumentManager implements DocumentManagerInterface
return $document->getCreationDate();
}
/**
* @param StoredObject $document
*/
public function getDocumentId(Document $document): string
{
return (string) $document->getUuid();
}
/**
* @param StoredObject $document
*/
@@ -126,24 +155,46 @@ final class ChillDocumentManager implements DocumentManagerInterface
return $document->getCreationDate();
}
public function getLock(Document $document): string {
public function getLock(Document $document): string
{
return $this->documentLockManager->getLock($document, $this->request);
}
public function getVersion(Document $document): string {
public function getSha256(Document $document): string
{
return base64_encode(hash('sha256', $this->getContent($document)));
}
public function getSize(Document $document): int
{
return strlen($this->getContent($document));
}
public function getVersion(Document $document): string
{
// TODO ?
return '0';
}
public function hasLock(Document $document): bool {
public function hasLock(Document $document): bool
{
return $this->documentLockManager->hasLock($document, $this->request);
}
public function lock(Document $document, string $lock): void {
public function lock(Document $document, string $lock): void
{
$this->documentLockManager->setLock($document, $lock, $this->request);
}
public function remove(Document $document): void {
public function read(Document $document): StreamInterface
{
return $this
->psr17
->createStream($this->getContent($document));
}
public function remove(Document $document): void
{
$entityIsDeleted = false;
try {
@@ -153,7 +204,7 @@ final class ChillDocumentManager implements DocumentManagerInterface
$entityIsDeleted = false;
}
if ($entityIsDeleted === true) {
if (true === $entityIsDeleted) {
$this->deleteContent($document);
}
}
@@ -163,42 +214,6 @@ final class ChillDocumentManager implements DocumentManagerInterface
$this->setContent($document, $properties['content']);
}
/**
* @param StoredObject $document
*
* @return string The document filename with its extension.
*/
public function getBasename(Document $document): string {
$exts = (new MimeTypes())->getExtensions($document->getType());
if ([] === $exts) {
throw new Error('Unknown mimetype for stored document.');
}
return sprintf('%s.%s', $document->getFilename(), reset($exts));
}
/**
* @param StoredObject $document
*/
public function getDocumentId(Document $document): string {
return (string) $document->getUuid();
}
public function getSha256(Document $document): string {
return base64_encode(hash('sha256', $this->getContent($document)));
}
public function getSize(Document $document): int {
return strlen($this->getContent($document));
}
public function read(Document $document): StreamInterface {
return $this
->psr17
->createStream($this->getContent($document));
}
private function deleteContent(StoredObject $storedObject): void
{
/** @var StdClass $object */
@@ -206,8 +221,7 @@ final class ChillDocumentManager implements DocumentManagerInterface
$response = $this->httpClient->request('DELETE', $object->url);
if (200 !== $response->getStatusCode())
{
if (200 !== $response->getStatusCode()) {
throw new Error('Unable to delete stored object.');
}
}
@@ -219,8 +233,7 @@ final class ChillDocumentManager implements DocumentManagerInterface
$response = $this->httpClient->request('GET', $object->url);
if (200 !== $response->getStatusCode())
{
if (200 !== $response->getStatusCode()) {
throw new Error('Unable to retrieve stored object.');
}
@@ -235,10 +248,8 @@ final class ChillDocumentManager implements DocumentManagerInterface
$response = $this->httpClient->request('PUT', $object->url, ['body' => $content]);
if (201 !== $response->getStatusCode())
{
if (201 !== $response->getStatusCode()) {
throw new Error('Unable to save stored object.');
}
}
}

View File

@@ -1,6 +1,8 @@
<?php
/**
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/