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

Support PHP 8.1 - First batch #29432

Merged
merged 17 commits into from
Nov 23, 2021
Merged
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
2 changes: 1 addition & 1 deletion apps/dav/lib/Connector/Sabre/AnonymousOptionsPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function isRequestInRoot($path) {
* @return bool
*/
public function handleAnonymousOptions(RequestInterface $request, ResponseInterface $response) {
$isOffice = preg_match('/Microsoft Office/i', $request->getHeader('User-Agent'));
$isOffice = preg_match('/Microsoft Office/i', $request->getHeader('User-Agent') ?? '');
$emptyAuth = $request->getHeader('Authorization') === null
|| $request->getHeader('Authorization') === ''
|| trim($request->getHeader('Authorization')) === 'Bearer';
Expand Down
2 changes: 1 addition & 1 deletion apps/dav/lib/Connector/Sabre/Auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ private function auth(RequestInterface $request, ResponseInterface $response) {
}
}

if (!$this->userSession->isLoggedIn() && in_array('XMLHttpRequest', explode(',', $request->getHeader('X-Requested-With')))) {
if (!$this->userSession->isLoggedIn() && in_array('XMLHttpRequest', explode(',', $request->getHeader('X-Requested-With') ?? ''))) {
// do not re-authenticate over ajax, use dummy auth name to prevent browser popup
$response->addHeader('WWW-Authenticate','DummyBasic realm="' . $this->realm . '"');
$response->setStatus(401);
Expand Down
2 changes: 1 addition & 1 deletion apps/dav/lib/Connector/Sabre/FilesReportPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ public function onReport($reportName, $report, $uri) {
*
* @return string files base uri
*/
private function getFilesBaseUri($uri, $subPath) {
private function getFilesBaseUri(string $uri, string $subPath): string {
$uri = trim($uri, '/');
$subPath = trim($subPath, '/');
if (empty($subPath)) {
Expand Down
2 changes: 1 addition & 1 deletion apps/dav/lib/Upload/AssemblyStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ public static function wrap(array $nodes) {
]);
stream_wrapper_register('assembly', self::class);
try {
$wrapped = fopen('assembly://', 'r', null, $context);
$wrapped = fopen('assembly://', 'r', false, $context);
} catch (\BadMethodCallException $e) {
stream_wrapper_unregister('assembly');
throw $e;
Expand Down
3 changes: 3 additions & 0 deletions apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,9 @@ public function testOnReport() {
$reportTargetNode = $this->getMockBuilder(Directory::class)
->disableOriginalConstructor()
->getMock();
$reportTargetNode->expects($this->any())
->method('getPath')
->willReturn('');

$response = $this->getMockBuilder(ResponseInterface::class)
->disableOriginalConstructor()
Expand Down
4 changes: 3 additions & 1 deletion apps/files/tests/Controller/ApiControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public function testGetThumbnailInvalidSize() {
$this->assertEquals($expected, $this->apiController->getThumbnail(0, 0, ''));
}

public function testGetThumbnailInvaidImage() {
public function testGetThumbnailInvalidImage() {
$file = $this->createMock(File::class);
$this->userFolder->method('get')
->with($this->equalTo('unknown.jpg'))
Expand All @@ -184,6 +184,8 @@ public function testGetThumbnail() {
->with($this->equalTo('known.jpg'))
->willReturn($file);
$preview = $this->createMock(ISimpleFile::class);
$preview->method('getName')->willReturn('my name');
$preview->method('getMTime')->willReturn(42);
$this->preview->expects($this->once())
->method('getPreview')
->with($this->equalTo($file), 10, 10, true)
Expand Down
4 changes: 1 addition & 3 deletions apps/files_external/lib/Lib/Auth/AuthMechanism.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,8 @@ public function setScheme($scheme) {

/**
* Serialize into JSON for client-side JS
*
* @return array
*/
public function jsonSerialize() {
public function jsonSerialize(): array {
$data = $this->jsonSerializeDefinition();
$data += $this->jsonSerializeIdentifier();

Expand Down
4 changes: 1 addition & 3 deletions apps/files_external/lib/Lib/Backend/Backend.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,8 @@ public function setLegacyAuthMechanismCallback(callable $callback) {

/**
* Serialize into JSON for client-side JS
*
* @return array
*/
public function jsonSerialize() {
public function jsonSerialize(): array {
$data = $this->jsonSerializeDefinition();
$data += $this->jsonSerializeIdentifier();

Expand Down
4 changes: 1 addition & 3 deletions apps/files_external/lib/Lib/DefinitionParameter.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,8 @@ public function setTooltip(string $tooltip) {

/**
* Serialize into JSON for client-side JS
*
* @return string
*/
public function jsonSerialize() {
public function jsonSerialize(): array {
return [
'value' => $this->getText(),
'flags' => $this->getFlags(),
Expand Down
4 changes: 1 addition & 3 deletions apps/files_external/lib/Lib/StorageConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -396,10 +396,8 @@ public function setType($type) {

/**
* Serialize config to JSON
*
* @return array
*/
public function jsonSerialize() {
public function jsonSerialize(): array {
$result = [];
if (!is_null($this->id)) {
$result['id'] = $this->id;
Expand Down
2 changes: 1 addition & 1 deletion apps/theming/lib/Service/JSDataService.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function __construct(
$this->appConfig = $appConfig;
}

public function jsonSerialize() {
public function jsonSerialize(): array {
return [
'name' => $this->themingDefaults->getName(),
'url' => $this->themingDefaults->getBaseUrl(),
Expand Down
2 changes: 1 addition & 1 deletion apps/user_status/lib/Service/JSDataService.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function __construct(IUserSession $userSession,
$this->statusService = $statusService;
}

public function jsonSerialize() {
public function jsonSerialize(): array {
$user = $this->userSession->getUser();

if ($user === null) {
Expand Down
2 changes: 1 addition & 1 deletion core/Command/Broadcast/Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function getUids(): array {
];
}

public function jsonSerialize() {
public function jsonSerialize(): array {
return [
'description' => 'this is a test event',
];
Expand Down
5 changes: 3 additions & 2 deletions core/Controller/AvatarController.php
Original file line number Diff line number Diff line change
Expand Up @@ -283,11 +283,12 @@ public function getTmpAvatar() {
$image = new \OC_Image();
$image->loadFromData($tmpAvatar);

$resp = new DataDisplayResponse($image->data(),
$resp = new DataDisplayResponse(
$image->data() ?? '',
Http::STATUS_OK,
['Content-Type' => $image->mimeType()]);

$resp->setETag((string)crc32($image->data()));
$resp->setETag((string)crc32($image->data() ?? ''));
$resp->cacheFor(0);
$resp->setLastModified(new \DateTime('now', new \DateTimeZone('GMT')));
return $resp;
Expand Down
3 changes: 2 additions & 1 deletion lib/private/Accounts/Account.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ public function getFilteredProperties(string $scope = null, string $verified = n
return $result;
}

public function jsonSerialize() {
/** @return IAccountPropertyCollection[]|IAccountProperty[] */
public function jsonSerialize(): array {
return $this->properties;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/private/Accounts/AccountProperty.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function __construct(string $name, string $value, string $scope, string $
$this->verificationData = $verificationData;
}

public function jsonSerialize() {
public function jsonSerialize(): array {
return [
'name' => $this->getName(),
'value' => $this->getValue(),
Expand Down
2 changes: 1 addition & 1 deletion lib/private/Accounts/AccountPropertyCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public function removePropertyByValue(string $value): IAccountPropertyCollection
return $this;
}

public function jsonSerialize() {
public function jsonSerialize(): array {
return [$this->collectionName => $this->properties];
}

Expand Down
5 changes: 3 additions & 2 deletions lib/private/AppFramework/Http/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ public function offsetExists($offset): bool {
* @param string $offset
* @return mixed
*/
#[\ReturnTypeWillChange]
public function offsetGet($offset) {
return isset($this->items['parameters'][$offset])
? $this->items['parameters'][$offset]
Expand All @@ -210,15 +211,15 @@ public function offsetGet($offset) {
* @param string $offset
* @param mixed $value
*/
public function offsetSet($offset, $value) {
public function offsetSet($offset, $value): void {
throw new \RuntimeException('You cannot change the contents of the request object');
}

/**
* @see offsetExists
* @param string $offset
*/
public function offsetUnset($offset) {
public function offsetUnset($offset): void {
throw new \RuntimeException('You cannot change the contents of the request object');
}

Expand Down
8 changes: 5 additions & 3 deletions lib/private/AppFramework/Utility/SimpleContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,28 +197,30 @@ protected function sanitizeName($name) {
/**
* @deprecated 20.0.0 use \Psr\Container\ContainerInterface::has
*/
public function offsetExists($id) {
public function offsetExists($id): bool {
return $this->container->offsetExists($id);
}

/**
* @deprecated 20.0.0 use \Psr\Container\ContainerInterface::get
* @return mixed
*/
#[\ReturnTypeWillChange]
public function offsetGet($id) {
return $this->container->offsetGet($id);
}

/**
* @deprecated 20.0.0 use \OCP\IContainer::registerService
*/
public function offsetSet($id, $service) {
public function offsetSet($id, $service): void {
$this->container->offsetSet($id, $service);
}

/**
* @deprecated 20.0.0
*/
public function offsetUnset($offset) {
public function offsetUnset($offset): void {
$this->container->offsetUnset($offset);
}
}
2 changes: 1 addition & 1 deletion lib/private/Authentication/Token/DefaultToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public function getPassword() {
return parent::getPassword();
}

public function jsonSerialize() {
public function jsonSerialize(): array {
return [
'id' => $this->id,
'name' => $this->name,
Expand Down
2 changes: 1 addition & 1 deletion lib/private/Authentication/Token/PublicKeyToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public function getPassword() {
return parent::getPassword();
}

public function jsonSerialize() {
public function jsonSerialize(): array {
return [
'id' => $this->id,
'name' => $this->name,
Expand Down
10 changes: 7 additions & 3 deletions lib/private/Cache/CappedMemoryCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,23 @@ public function clear($prefix = '') {
return true;
}

public function offsetExists($offset) {
public function offsetExists($offset): bool {
return $this->hasKey($offset);
}

/**
* @return mixed
*/
#[\ReturnTypeWillChange]
public function &offsetGet($offset) {
return $this->cache[$offset];
}

public function offsetSet($offset, $value) {
public function offsetSet($offset, $value): void {
$this->set($offset, $value);
}

public function offsetUnset($offset) {
public function offsetUnset($offset): void {
$this->remove($offset);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/private/Collaboration/Collaborators/UserPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public function search($search, $limit, $offset, ISearchResult $searchResult) {
$this->shareeEnumerationFullMatch &&
$lowerSearch !== '' && (strtolower($uid) === $lowerSearch ||
strtolower($userDisplayName) === $lowerSearch ||
strtolower($userEmail) === $lowerSearch)
strtolower($userEmail ?? '') === $lowerSearch)
) {
if (strtolower($uid) === $lowerSearch) {
$foundUserById = true;
Expand Down
5 changes: 1 addition & 4 deletions lib/private/Contacts/ContactsMenu/Actions/LinkAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,7 @@ public function getAppId(): string {
return $this->appId;
}

/**
* @return array
*/
public function jsonSerialize() {
public function jsonSerialize(): array {
return [
'title' => $this->name,
'icon' => $this->icon,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,11 +414,11 @@ public function bitwiseOr($x, int $y): IQueryFunction {
* Quotes a given input parameter.
*
* @param mixed $input The parameter to be quoted.
* @param mixed|null $type One of the IQueryBuilder::PARAM_* constants
* @param int $type One of the IQueryBuilder::PARAM_* constants
*
* @return ILiteral
*/
public function literal($input, $type = null): ILiteral {
public function literal($input, $type = IQueryBuilder::PARAM_STR): ILiteral {
return new Literal($this->expressionBuilder->literal($input, $type));
}

Expand Down
14 changes: 9 additions & 5 deletions lib/private/EventDispatcher/GenericEventWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,19 +100,23 @@ public function hasArgument($key) {
return $this->event->hasArgument($key);
}

/**
* @return mixed
*/
#[\ReturnTypeWillChange]
public function offsetGet($key) {
return $this->event->offsetGet($key);
}

public function offsetSet($key, $value) {
return $this->event->offsetSet($key, $value);
public function offsetSet($key, $value): void {
$this->event->offsetSet($key, $value);
}

public function offsetUnset($key) {
return $this->event->offsetUnset($key);
public function offsetUnset($key): void {
$this->event->offsetUnset($key);
}

public function offsetExists($key) {
public function offsetExists($key): bool {
return $this->event->offsetExists($key);
}

Expand Down
10 changes: 7 additions & 3 deletions lib/private/Files/Cache/CacheEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,22 @@ public function __construct(array $data) {
$this->data = $data;
}

public function offsetSet($offset, $value) {
public function offsetSet($offset, $value): void {
$this->data[$offset] = $value;
}

public function offsetExists($offset) {
public function offsetExists($offset): bool {
return isset($this->data[$offset]);
}

public function offsetUnset($offset) {
public function offsetUnset($offset): void {
unset($this->data[$offset]);
}

/**
* @return mixed
*/
#[\ReturnTypeWillChange]
public function offsetGet($offset) {
if (isset($this->data[$offset])) {
return $this->data[$offset];
Expand Down
Loading