style(PHP): adapt to coding-style bump

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
This commit is contained in:
Arthur Schiwon 2024-10-17 09:45:34 +02:00
Родитель 76895b5b2c
Коммит 638ae9dcb3
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 7424F1874854DF23
8 изменённых файлов: 33 добавлений и 33 удалений

Просмотреть файл

@ -49,7 +49,7 @@ class Client {
Storage::SP_PROPERTY_SIZE,
];
/** @var ClientContext */
/** @var ClientContext */
protected $context;
/** @var array */
@ -57,7 +57,7 @@ class Client {
/** @var ContextsFactory */
private $contextsFactory;
/** @var string */
/** @var string */
private $sharePointUrl;
/** @var string[] */
@ -76,7 +76,7 @@ class Client {
LoggerInterface $logger,
string $sharePointUrl,
array $credentials,
array $options
array $options,
) {
$this->contextsFactory = $contextsFactory;
$this->sharePointUrl = $sharePointUrl;
@ -95,7 +95,7 @@ class Client {
* @throws NotFoundException
* @throws Exception
*/
public function fetchFileOrFolder($path, array $properties = null) {
public function fetchFileOrFolder($path, ?array $properties = null) {
$fetchFileFunc = function ($path, $props) {
return $this->fetchFile($path, $props);
};
@ -145,7 +145,7 @@ class Client {
* @param array|null $properties
* @return File
*/
public function fetchFile($relativeServerPath, array $properties = null): File {
public function fetchFile($relativeServerPath, ?array $properties = null): File {
$this->ensureConnection();
$file = $this->context->getWeb()->getFileByServerRelativeUrl($relativeServerPath);
$this->loadAndExecute($file, $properties);
@ -159,7 +159,7 @@ class Client {
* @param array|null $properties
* @return Folder
*/
public function fetchFolder($relativeServerPath, array $properties = null) {
public function fetchFolder($relativeServerPath, ?array $properties = null) {
$this->ensureConnection();
$folder = $this->context->getWeb()->getFolderByServerRelativeUrl($relativeServerPath);
$allFields = $folder->getListItemAllFields();
@ -230,7 +230,7 @@ class Client {
$request->ensureHeader('X-HTTP-Method', 'PUT'); // yes, PUT
$this->context->ensureFormDigest($request);
$request->StreamHandle = $fp;
$request->ensureHeader("Content-Length", (string)filesize($localPath));
$request->ensureHeader('Content-Length', (string)filesize($localPath));
$this->context->executeQueryDirect($request);
}
@ -451,7 +451,7 @@ class Client {
* @param ClientObject $object
* @param array|null $properties
*/
public function loadAndExecute(ClientObject $object, array $properties = null) {
public function loadAndExecute(ClientObject $object, ?array $properties = null) {
$this->context->load($object, $properties);
$this->context->executeQuery();
}

Просмотреть файл

@ -36,7 +36,7 @@ class ClientFactory {
ContextsFactory $contextsFactory,
string $sharePointUrl,
array $credentials,
array $options = []
array $options = [],
): Client {
return new Client(
$contextsFactory,

Просмотреть файл

@ -35,7 +35,7 @@ class ContextsFactory {
string $url,
string $user,
string $password,
bool $useNtlm = false
bool $useNtlm = false,
): ClientContext {
$clientContext = new ClientContext($url);
$credentials = new UserCredentials($user, $password);
@ -50,14 +50,14 @@ class ContextsFactory {
*/
protected function withCredentials(
ClientContext $clientContext,
UserCredentials $userCredentials
UserCredentials $userCredentials,
): ClientContext {
return $clientContext->withCredentials($userCredentials);
}
protected function getWithNtlm(
ClientContext $clientContext,
UserCredentials $userCredentials
UserCredentials $userCredentials,
) {
return $clientContext->withNtlm($userCredentials);
}

Просмотреть файл

@ -37,7 +37,7 @@ class ExternalStoragesRegistrationListener implements IEventListener {
public function __construct(
private BackendService $backendService,
private BackendProvider $backendProvider
private BackendProvider $backendProvider,
) {
}

Просмотреть файл

@ -53,22 +53,22 @@ class Storage extends Common {
public const SP_PERMISSION_UPDATE = 3;
public const SP_PERMISSION_DELETE = 4;
/** @var string */
/** @var string */
protected $server;
/** @var string */
/** @var string */
protected $documentLibrary;
/** @var string */
/** @var string */
protected $authUser;
/** @var string */
/** @var string */
protected $authPwd;
/** @var Client */
/** @var Client */
protected $spClient;
/** @var CappedMemoryCache */
/** @var CappedMemoryCache */
protected $fileCache;
/** @var false|mixed */
protected $forceNtlm;
@ -589,7 +589,7 @@ class Storage extends Common {
// cache children instances
foreach ($contents as $collection) {
foreach ($collection->getData() as $item) {
/** @var File|Folder $item */
/** @var File|Folder $item */
$url = $item->getProperty(self::SP_PROPERTY_URL);
if (is_null($url)) {
// at least on SP13 requesting self::SP_PROPERTY_URL against folders causes an exception

Просмотреть файл

@ -41,7 +41,7 @@ use Psr\Log\LoggerInterface;
use Test\TestCase;
class SharePointClientTest extends TestCase {
/** @var ContextsFactory|\PHPUnit_Framework_MockObject_MockObject */
/** @var ContextsFactory|\PHPUnit_Framework_MockObject_MockObject */
protected $contextsFactory;
protected string $documentLibraryTitle;
@ -174,7 +174,7 @@ class SharePointClientTest extends TestCase {
static $cnt = 0;
$cnt++;
if ($cnt === 1) {
$errorPayload = '{"error":{"code":"-2130575338, Microsoft.SharePoint.SPException","message":{"lang":"en-US","value":"The file ' . $path . ' does not exist."}}}';
$errorPayload = '{"error":{"code":"-2130575338, Microsoft.SharePoint.SPException","message":{"lang":"en-US","value":"The file ' . $path . ' does not exist."}}}';
throw new RequestException($errorPayload, 404);
} elseif ($cnt === 2) {
$errorPayload = '{"error":{"code":"-2147024894, System.IO.FileNotFoundException","message":{"lang":"en-US","value":"File Not Found."}}}';
@ -198,7 +198,7 @@ class SharePointClientTest extends TestCase {
public function testCreateFolderSuccess() {
$dirName = 'New Project Dir';
$parentPath = '/' . $this->documentLibraryTitle . '/Our Directory';
$path = $parentPath . '/'. $dirName;
$path = $parentPath . '/' . $dirName;
$folderCollectionMock = $this->createMock(FolderCollection::class);
$folderCollectionMock->expects($this->once())
@ -233,7 +233,7 @@ class SharePointClientTest extends TestCase {
public function testCreateFolderError() {
$dirName = 'New Project Dir';
$parentPath = '/' . $this->documentLibraryTitle . '/Our Directory';
$path = $parentPath . '/'. $dirName;
$path = $parentPath . '/' . $dirName;
$folderCollectionMock = $this->createMock(FolderCollection::class);
$folderCollectionMock->expects($this->once())

Просмотреть файл

@ -38,19 +38,19 @@ use OCP\Files\FileInfo;
use Test\TestCase;
class StorageTest extends TestCase {
/** @var Storage */
/** @var Storage */
protected $storage;
/** @var ContextsFactory|\PHPUnit_Framework_MockObject_MockObject */
/** @var ContextsFactory|\PHPUnit_Framework_MockObject_MockObject */
protected $factory;
/** @var ClientContext|\PHPUnit_Framework_MockObject_MockObject */
/** @var ClientContext|\PHPUnit_Framework_MockObject_MockObject */
protected $clientContextMock;
/** @var string */
/** @var string */
protected $documentLibraryTitle = 'Fancy Documents';
/** @var SPList|\PHPUnit_Framework_MockObject_MockObject */
/** @var SPList|\PHPUnit_Framework_MockObject_MockObject */
protected $sharePointList;
/** @var string */
@ -62,13 +62,13 @@ class StorageTest extends TestCase {
/** @var string */
protected $examplePwd = 'a123456';
/** @var ClientFactory|\PHPUnit_Framework_MockObject_MockObject */
/** @var ClientFactory|\PHPUnit_Framework_MockObject_MockObject */
protected $clientFactory;
/** @var Client|\PHPUnit_Framework_MockObject_MockObject */
/** @var Client|\PHPUnit_Framework_MockObject_MockObject */
protected $client;
/** @var CappedMemoryCache|\PHPUnit_Framework_MockObject_MockObject */
/** @var CappedMemoryCache|\PHPUnit_Framework_MockObject_MockObject */
protected $fileCache;
protected function setUp(): void {

Просмотреть файл

@ -4,7 +4,7 @@ if (!defined('PHPUNIT_RUN')) {
define('PHPUNIT_RUN', 1);
}
require_once __DIR__.'/../../../lib/base.php';
require_once __DIR__ . '/../../../lib/base.php';
// Fix for "Autoload path not allowed: .../tests/lib/testcase.php"
\OC::$loader->addValidRoot(OC::$SERVERROOT . '/tests');