diff options
author | Côme Chilliet <91878298+come-nc@users.noreply.github.com> | 2023-01-20 11:43:24 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-20 11:43:24 +0100 |
commit | 37bb33c5799b834dfef3fb73936bd0e5a4773fb8 (patch) | |
tree | 0c7dd249075d8bb435589481b1e671e0a3fdbc54 /lib | |
parent | fce87f8ddb2d523a503051362a66b7453bc2329b (diff) | |
parent | f32d18d4ea371dbf2ec04c254f91abfd0fa3f4b9 (diff) | |
download | nextcloud-server-37bb33c5799b834dfef3fb73936bd0e5a4773fb8.tar.gz nextcloud-server-37bb33c5799b834dfef3fb73936bd0e5a4773fb8.zip |
Merge pull request #34997 from nextcloud/fix/drop-php-7.4
Drop PHP 7.4 on master
Diffstat (limited to 'lib')
-rw-r--r-- | lib/composer/composer/InstalledVersions.php | 14 | ||||
-rw-r--r-- | lib/private/AppFramework/OCS/BaseResponse.php | 21 | ||||
-rw-r--r-- | lib/private/AppFramework/OCS/V1Response.php | 8 | ||||
-rw-r--r-- | lib/private/AppFramework/OCS/V2Response.php | 3 | ||||
-rw-r--r-- | lib/private/legacy/OC_API.php | 2 | ||||
-rw-r--r-- | lib/public/AppFramework/Db/Entity.php | 26 | ||||
-rw-r--r-- | lib/versioncheck.php | 6 |
7 files changed, 41 insertions, 39 deletions
diff --git a/lib/composer/composer/InstalledVersions.php b/lib/composer/composer/InstalledVersions.php index 41bc143c114..c6b54af7ba2 100644 --- a/lib/composer/composer/InstalledVersions.php +++ b/lib/composer/composer/InstalledVersions.php @@ -28,7 +28,7 @@ class InstalledVersions { /** * @var mixed[]|null - * @psalm-var array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}|array{}|null + * @psalm-var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}|array{}|null */ private static $installed; @@ -39,7 +39,7 @@ class InstalledVersions /** * @var array[] - * @psalm-var array<string, array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}> + * @psalm-var array<string, array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}> */ private static $installedByVendor = array(); @@ -243,7 +243,7 @@ class InstalledVersions /** * @return array - * @psalm-return array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string} + * @psalm-return array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool} */ public static function getRootPackage() { @@ -257,7 +257,7 @@ class InstalledVersions * * @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect. * @return array[] - * @psalm-return array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>} + * @psalm-return array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} */ public static function getRawData() { @@ -280,7 +280,7 @@ class InstalledVersions * Returns the raw data of all installed.php which are currently loaded for custom implementations * * @return array[] - * @psalm-return list<array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}> + * @psalm-return list<array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}> */ public static function getAllRawData() { @@ -303,7 +303,7 @@ class InstalledVersions * @param array[] $data A vendor/composer/installed.php data set * @return void * - * @psalm-param array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>} $data + * @psalm-param array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $data */ public static function reload($data) { @@ -313,7 +313,7 @@ class InstalledVersions /** * @return array[] - * @psalm-return list<array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}> + * @psalm-return list<array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}> */ private static function getInstalled() { diff --git a/lib/private/AppFramework/OCS/BaseResponse.php b/lib/private/AppFramework/OCS/BaseResponse.php index dbff1b846c1..d3904065102 100644 --- a/lib/private/AppFramework/OCS/BaseResponse.php +++ b/lib/private/AppFramework/OCS/BaseResponse.php @@ -37,13 +37,13 @@ abstract class BaseResponse extends Response { /** @var string */ protected $format; - /** @var string */ + /** @var ?string */ protected $statusMessage; - /** @var int */ + /** @var ?int */ protected $itemsCount; - /** @var int */ + /** @var ?int */ protected $itemsPerPage; /** @@ -92,7 +92,7 @@ abstract class BaseResponse extends Response { } /** - * @param string[] $meta + * @param array<string,string|int> $meta * @return string */ protected function renderResult(array $meta): string { @@ -125,12 +125,15 @@ abstract class BaseResponse extends Response { return $writer->outputMemory(true); } - /** - * @param array $array - * @param \XMLWriter $writer - */ - protected function toXML(array $array, \XMLWriter $writer) { + protected function toXML(array $array, \XMLWriter $writer): void { foreach ($array as $k => $v) { + if ($k === '@attributes' && is_array($v)) { + foreach ($v as $k2 => $v2) { + $writer->writeAttribute($k2, $v2); + } + continue; + } + if (\is_string($k) && strpos($k, '@') === 0) { $writer->writeAttribute(substr($k, 1), $v); continue; diff --git a/lib/private/AppFramework/OCS/V1Response.php b/lib/private/AppFramework/OCS/V1Response.php index f4f19832fa8..cca3c267ec4 100644 --- a/lib/private/AppFramework/OCS/V1Response.php +++ b/lib/private/AppFramework/OCS/V1Response.php @@ -28,7 +28,6 @@ use OCP\AppFramework\Http; use OCP\AppFramework\OCSController; class V1Response extends BaseResponse { - /** * The V1 endpoint has very limited http status codes basically everything * is status 200 except 401 @@ -69,12 +68,11 @@ class V1Response extends BaseResponse { $meta = [ 'status' => $this->getOCSStatus() === 100 ? 'ok' : 'failure', 'statuscode' => $this->getOCSStatus(), - 'message' => $this->getOCSStatus() === 100 ? 'OK' : $this->statusMessage, + 'message' => $this->getOCSStatus() === 100 ? 'OK' : $this->statusMessage ?? '', + 'totalitems' => (string)($this->itemsCount ?? ''), + 'itemsperpage' => (string)($this->itemsPerPage ?? ''), ]; - $meta['totalitems'] = $this->itemsCount !== null ? (string)$this->itemsCount : ''; - $meta['itemsperpage'] = $this->itemsPerPage !== null ? (string)$this->itemsPerPage: ''; - return $this->renderResult($meta); } } diff --git a/lib/private/AppFramework/OCS/V2Response.php b/lib/private/AppFramework/OCS/V2Response.php index 6c302698bc9..8bf4c37a578 100644 --- a/lib/private/AppFramework/OCS/V2Response.php +++ b/lib/private/AppFramework/OCS/V2Response.php @@ -27,7 +27,6 @@ use OCP\AppFramework\Http; use OCP\AppFramework\OCSController; class V2Response extends BaseResponse { - /** * The V2 endpoint just passes on status codes. * Of course we have to map the OCS specific codes to proper HTTP status codes @@ -61,7 +60,7 @@ class V2Response extends BaseResponse { $meta = [ 'status' => $status >= 200 && $status < 300 ? 'ok' : 'failure', 'statuscode' => $this->getOCSStatus(), - 'message' => $status >= 200 && $status < 300 ? 'OK' : $this->statusMessage, + 'message' => $status >= 200 && $status < 300 ? 'OK' : $this->statusMessage ?? '', ]; if ($this->itemsCount !== null) { diff --git a/lib/private/legacy/OC_API.php b/lib/private/legacy/OC_API.php index 46ee3495572..0da546f3263 100644 --- a/lib/private/legacy/OC_API.php +++ b/lib/private/legacy/OC_API.php @@ -101,7 +101,7 @@ class OC_API { public static function requestedFormat(): string { $formats = ['json', 'xml']; - $format = (isset($_GET['format']) && in_array($_GET['format'], $formats)) ? $_GET['format'] : 'xml'; + $format = (isset($_GET['format']) && is_string($_GET['format']) && in_array($_GET['format'], $formats)) ? $_GET['format'] : 'xml'; return $format; } diff --git a/lib/public/AppFramework/Db/Entity.php b/lib/public/AppFramework/Db/Entity.php index dcd1c77c042..34cd297e57e 100644 --- a/lib/public/AppFramework/Db/Entity.php +++ b/lib/public/AppFramework/Db/Entity.php @@ -29,25 +29,27 @@ use function lcfirst; use function substr; /** - * @method integer getId() - * @method void setId(integer $id) + * @method int getId() + * @method void setId(int $id) * @since 7.0.0 + * @psalm-consistent-constructor */ abstract class Entity { + /** + * @var int + */ public $id; - private $_updatedFields = []; - private $_fieldTypes = ['id' => 'integer']; - + private array $_updatedFields = []; + private array $_fieldTypes = ['id' => 'integer']; /** * Simple alternative constructor for building entities from a request * @param array $params the array which was obtained via $this->params('key') * in the controller - * @return Entity * @since 7.0.0 */ - public static function fromParams(array $params) { + public static function fromParams(array $params): static { $instance = new static(); foreach ($params as $key => $value) { @@ -64,7 +66,7 @@ abstract class Entity { * @param array $row the row to map onto the entity * @since 7.0.0 */ - public static function fromRow(array $row) { + public static function fromRow(array $row): static { $instance = new static(); foreach ($row as $key => $value) { @@ -100,7 +102,7 @@ abstract class Entity { * Generic setter for properties * @since 7.0.0 */ - protected function setter($name, $args) { + protected function setter(string $name, array $args): void { // setters should only work for existing attributes if (property_exists($this, $name)) { if ($this->$name === $args[0]) { @@ -142,7 +144,7 @@ abstract class Entity { * Generic getter for properties * @since 7.0.0 */ - protected function getter($name) { + protected function getter(string $name): mixed { // getters should only work for existing attributes if (property_exists($this, $name)) { return $this->$name; @@ -160,7 +162,7 @@ abstract class Entity { * getter method * @since 7.0.0 */ - public function __call($methodName, $args) { + public function __call(string $methodName, array $args) { if (strpos($methodName, 'set') === 0) { $this->setter(lcfirst(substr($methodName, 3)), $args); } elseif (strpos($methodName, 'get') === 0) { @@ -191,7 +193,7 @@ abstract class Entity { * @param string $attribute the name of the attribute * @since 7.0.0 */ - protected function markFieldUpdated($attribute) { + protected function markFieldUpdated(string $attribute): void { $this->_updatedFields[$attribute] = true; } diff --git a/lib/versioncheck.php b/lib/versioncheck.php index 8477442935a..7c95b333102 100644 --- a/lib/versioncheck.php +++ b/lib/versioncheck.php @@ -25,10 +25,10 @@ declare(strict_types=1); * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ -// Show warning if a PHP version below 7.4 is used, -if (PHP_VERSION_ID < 70400) { +// Show warning if a PHP version below 8.0 is used, +if (PHP_VERSION_ID < 80000) { http_response_code(500); - echo 'This version of Nextcloud requires at least PHP 7.4<br/>'; + echo 'This version of Nextcloud requires at least PHP 8.0<br/>'; echo 'You are currently running ' . PHP_VERSION . '. Please update your PHP version.'; exit(1); } |