Skip to content

Commit

Permalink
style: Fix php-cs issues
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Knorr <[email protected]>
  • Loading branch information
juliusknorr committed Dec 3, 2024
1 parent 37961d2 commit adfadfc
Show file tree
Hide file tree
Showing 16 changed files with 42 additions and 42 deletions.
2 changes: 1 addition & 1 deletion lib/AppConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@

namespace OCA\Officeonline;

use \OCP\IConfig;
use OCA\Officeonline\AppInfo\Application;
use OCP\IConfig;

class AppConfig {
private $defaults = [
Expand Down
18 changes: 9 additions & 9 deletions lib/Controller/DocumentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,17 @@

namespace OCA\Officeonline\Controller;

use \OCA\Officeonline\AppConfig;
use \OCA\Officeonline\Helper;
use \OCP\AppFramework\Controller;
use \OCP\AppFramework\Http\ContentSecurityPolicy;
use \OCP\AppFramework\Http\TemplateResponse;
use \OCP\IConfig;
use \OCP\IL10N;
use \OCP\IRequest;
use OC\Files\Type\TemplateManager;
use OCA\Officeonline\AppConfig;
use OCA\Officeonline\Helper;
use OCA\Officeonline\Service\FederationService;
use OCA\Officeonline\TokenManager;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\ContentSecurityPolicy;
use OCP\AppFramework\Http\JSONResponse;
use OCP\AppFramework\Http\RedirectResponse;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\Constants;
use OCP\Files\File;
use OCP\Files\Folder;
Expand All @@ -33,6 +30,9 @@
use OCP\Files\Node;
use OCP\Files\NotFoundException;
use OCP\Files\NotPermittedException;
use OCP\IConfig;
use OCP\IL10N;
use OCP\IRequest;
use OCP\ISession;
use OCP\Share\Exceptions\ShareNotFound;
use OCP\Share\IManager;
Expand Down Expand Up @@ -255,7 +255,7 @@ public function index($fileId, $path = null) {
if ($encryptionManager->isEnabled()) {
// Update the current file to be accessible with system public shared key
$owner = $item->getOwner()->getUID();
$absPath = '/' . $owner . '/' . $item->getInternalPath();
$absPath = '/' . $owner . '/' . $item->getInternalPath();
$accessList = \OC::$server->getEncryptionFilesHelper()->getAccessList($absPath);
$accessList['public'] = true;
$encryptionManager->getEncryptionModule()->update($absPath, $owner, $accessList);
Expand Down
2 changes: 1 addition & 1 deletion lib/Controller/FederationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
*/
namespace OCA\Officeonline\Controller;

use \OCP\AppFramework\OCSController;
use OCA\Officeonline\Db\WopiMapper;
use OCP\AppFramework\Db\DoesNotExistException;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\OCSController;
use OCP\IConfig;
use OCP\IRequest;
use OCP\Share\IManager;
Expand Down
8 changes: 4 additions & 4 deletions lib/Controller/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@

namespace OCA\Officeonline\Controller;

use \OCP\AppFramework\Controller;
use \OCP\IL10N;
use \OCP\IRequest;
use Exception;
use OCA\Officeonline\AppConfig;
use OCA\Officeonline\WOPI\DiscoveryManager;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\Http\JSONResponse;
use OCP\IL10N;
use OCP\IRequest;
use Psr\Log\LoggerInterface;

class SettingsController extends Controller {
Expand All @@ -28,7 +28,7 @@ class SettingsController extends Controller {
private $l10n;
/** @var AppConfig */
private $appConfig;
/** @var DiscoveryManager */
/** @var DiscoveryManager */
private $discoveryManager;
/** @var LoggerInterface */
private $logger;
Expand Down
12 changes: 6 additions & 6 deletions lib/Controller/WopiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -349,12 +349,12 @@ private function fallbackLock($fileId, $access_token) {
}
$lck = $this->request->getHeader('X-WOPI-Lock');
$wover = $this->request->getHeader('X-WOPI-Override');
if (strlen($lck) === 0 && $wover !== "GET_LOCK" && strpos($wover, "LOCK") !== false) {
if (strlen($lck) === 0 && $wover !== 'GET_LOCK' && strpos($wover, 'LOCK') !== false) {
return new DataResponse([], Http::STATUS_BAD_REQUEST);
}
$result = new DataResponse([], Http::STATUS_NOT_IMPLEMENTED);
switch ($wover) {
case "LOCK":
case 'LOCK':
$oldLck = $this->request->getHeader('X-WOPI-OldLock');
if (strlen($oldLck) > 0) {
$fLock = $this->lockMapper->find($fileId);
Expand Down Expand Up @@ -392,12 +392,12 @@ private function fallbackLock($fileId, $access_token) {
$result->setStatus(Http::STATUS_OK);
}
break;
case "GET_LOCK":
case 'GET_LOCK':
$fLock = $this->lockMapper->find($fileId);
$result->setStatus(Http::STATUS_OK);
$result->addHeader('X-WOPI-Lock', empty($fLock) ? '' : $fLock->getValue());
break;
case "REFRESH_LOCK":
case 'REFRESH_LOCK':
$fLock = $this->lockMapper->find($fileId);
if (!empty($fLock)) {
if ($fLock->getValue() !== $lck) {
Expand All @@ -414,7 +414,7 @@ private function fallbackLock($fileId, $access_token) {
$result->addHeader('X-WOPI-Lock', '');
}
break;
case "UNLOCK":
case 'UNLOCK':
$fLock = $this->lockMapper->find($fileId);
if (!empty($fLock)) {
if ($fLock->getValue() !== $lck) {
Expand Down Expand Up @@ -664,7 +664,7 @@ public function postFile($fileId, $access_token) {
return new JSONResponse([], Http::STATUS_UNAUTHORIZED);
}

if ((int) $fileId !== $wopi->getFileid()) {
if ((int)$fileId !== $wopi->getFileid()) {
return new JSONResponse([], Http::STATUS_FORBIDDEN);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Db/DirectMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class DirectMapper extends QBMapper {
/** @var ISecureRandom */
protected $random;

/**@var ITimeFactory */
/** @var ITimeFactory */
protected $timeFactory;

public function __construct(IDBConnection $db,
Expand Down
4 changes: 2 additions & 2 deletions lib/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

namespace OCA\Officeonline;

use \DateTime;
use \DateTimeZone;
use DateTime;
use DateTimeZone;
use OCP\Files\Folder;

class Helper {
Expand Down
12 changes: 6 additions & 6 deletions lib/Middleware/WOPIMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public function isWOPIAllowed(): bool {
* @copyright (IPv6) MW. https://stackoverflow.com/questions/7951061/matching-ipv6-address-to-a-cidr-subnet via
*/
private function matchCidr(string $ip, string $range): bool {
list($subnet, $bits) = array_pad(explode('/', $range), 2, null);
[$subnet, $bits] = array_pad(explode('/', $range), 2, null);
if ($bits === null) {
$bits = 32;
}
Expand All @@ -133,23 +133,23 @@ private function matchCidr(string $ip, string $range): bool {
$subnet = inet_pton($subnet);
$ip = inet_pton($ip);

$binMask = str_repeat("f", $bits / 4);
$binMask = str_repeat('f', $bits / 4);
switch ($bits % 4) {
case 0:
break;
case 1:
$binMask .= "8";
$binMask .= '8';
break;
case 2:
$binMask .= "c";
$binMask .= 'c';
break;
case 3:
$binMask .= "e";
$binMask .= 'e';
break;
}

$binMask = str_pad($binMask, 32, '0');
$binMask = pack("H*", $binMask);
$binMask = pack('H*', $binMask);

if (($ip & $binMask) === $subnet) {
return true;
Expand Down
2 changes: 1 addition & 1 deletion lib/Preview/Office.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) {
$options['multipart'] = [['name' => $path, 'contents' => $stream]];

try {
$response = $client->post($this->getWopiURL(). '/lool/convert-to/png', $options);
$response = $client->post($this->getWopiURL() . '/lool/convert-to/png', $options);
} catch (\Exception $e) {
$this->logger->info('Failed to convert file to preview', [
'exception' => $e,
Expand Down
2 changes: 1 addition & 1 deletion lib/Service/FederationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class FederationService {
private $cache;
/** @var IClientService */
private $clientService;
/** @var LoggerInterface */
/** @var LoggerInterface */
private $logger;
/** @var TrustedServers */
private $trustedServers;
Expand Down
2 changes: 1 addition & 1 deletion lib/Service/UserScopeService.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function __construct(IUserSession $userSession, IUserManager $userManager
* @param $uid
* @throws \InvalidArgumentException
*/
public function setUserScope(string $uid = null) {
public function setUserScope(?string $uid = null) {
if ($uid === null) {
return;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/Settings/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ public function getSection() {
}
/**
* @return int whether the form should be rather on the top or bottom of
* the admin section. The forms are arranged in ascending order of the
* priority values. It is required to return a value between 0 and 100.
* the admin section. The forms are arranged in ascending order of the
* priority values. It is required to return a value between 0 and 100.
*
* keep the server setting at the top, right after "server settings"
*/
Expand Down
2 changes: 1 addition & 1 deletion lib/WOPI/DiscoveryManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function get() {
try {
$file = $this->appData->getFile('discovery.xml');
$decodedFile = json_decode($file->getContent(), true);
if ($decodedFile['timestamp'] + 3600 > $this->timeFactory->getTime()) {
if ($this->timeFactory->getTime() < $decodedFile['timestamp'] + 3600) {
return $decodedFile['data'];
}
} catch (NotFoundException $e) {
Expand Down
4 changes: 2 additions & 2 deletions lib/WOPI/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ public function getUrlSrcForFile(File $file, bool $edit): string {
'internal-' . $fallbackProtocol,
];

$userAgent = $_SERVER["HTTP_USER_AGENT"];
if (preg_match("/(android|mobile)/i", $userAgent)) {
$userAgent = $_SERVER['HTTP_USER_AGENT'];
if (preg_match('/(android|mobile)/i', $userAgent)) {
$edit = false;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
define('PHPUNIT_RUN', 1);
}

require_once __DIR__.'/../../../lib/base.php';
require_once __DIR__ . '/../../../lib/base.php';

if (!class_exists('\PHPUnit\Framework\TestCase')) {
require_once('PHPUnit/Autoload.php');
Expand Down
6 changes: 3 additions & 3 deletions tests/features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function userOpens($user, $file) {
preg_match_all($re, $contents, $matches, PREG_SET_ORDER, 0);
$result = [];
foreach ($matches as $match) {
$result[$match[1]] = str_replace("'", "", $match[2]);
$result[$match[1]] = str_replace("'", '', $match[2]);
}

$this->fileId = $result['fileId'];
Expand All @@ -69,7 +69,7 @@ public function aGuestOpensTheShareLink() {
preg_match_all($re, $contents, $matches, PREG_SET_ORDER, 0);
$result = [];
foreach ($matches as $match) {
$result[$match[1]] = str_replace("'", "", $match[2]);
$result[$match[1]] = str_replace("'", '', $match[2]);
}

$this->fileId = $result['fileId'];
Expand Down Expand Up @@ -101,7 +101,7 @@ public function aGuestOpensTheShareLinkAs($user) {
preg_match_all($re, $contents, $matches, PREG_SET_ORDER, 0);
$result = [];
foreach ($matches as $match) {
$result[$match[1]] = str_replace("'", "", $match[2]);
$result[$match[1]] = str_replace("'", '', $match[2]);
}

$this->fileId = $result['fileId'];
Expand Down

0 comments on commit adfadfc

Please sign in to comment.