Merge pull request #3601 from nextcloud/enh/php8.1

Add support for PHP 8.1
This commit is contained in:
Julius Härtl
2022-04-08 17:05:47 +02:00
committed by GitHub
16 changed files with 48 additions and 64 deletions

View File

@@ -11,19 +11,6 @@ updates:
open-pull-requests-limit: 10 open-pull-requests-limit: 10
reviewers: reviewers:
- juliushaertl - juliushaertl
- jakobroehrl
#- package-ecosystem: npm
# directory: "/"
# target-branch: "stable1.1"
# schedule:
# interval: weekly
# day: saturday
# time: "03:00"
# timezone: Europe/Paris
# open-pull-requests-limit: 10
# reviewers:
# - juliushaertl
# - jakobroehrl
- package-ecosystem: composer - package-ecosystem: composer
directory: "/" directory: "/"
schedule: schedule:
@@ -34,11 +21,16 @@ updates:
open-pull-requests-limit: 10 open-pull-requests-limit: 10
reviewers: reviewers:
- juliushaertl - juliushaertl
ignore: - package-ecosystem: composer
- dependency-name: christophwurst/nextcloud directory: "/tests/integration"
versions: schedule:
- "< 16" interval: weekly
- ">= 15.a" day: saturday
time: "03:00"
timezone: Europe/Paris
open-pull-requests-limit: 10
reviewers:
- juliushaertl
- package-ecosystem: github-actions - package-ecosystem: github-actions
directory: "/" directory: "/"
schedule: schedule:

View File

@@ -54,6 +54,7 @@ jobs:
auth_header="$(git config --local --get http.https://github.com/.extraheader)" auth_header="$(git config --local --get http.https://github.com/.extraheader)"
git submodule sync --recursive git submodule sync --recursive
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1 git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1
cd build/integration && composer require --dev phpunit/phpunit:~8
- name: Checkout app - name: Checkout app
uses: actions/checkout@v3 uses: actions/checkout@v3

View File

@@ -13,7 +13,7 @@ jobs:
strategy: strategy:
matrix: matrix:
php-versions: ['7.4', '8.0', "8.1"] php-versions: ['7.4', '8.0', '8.1']
name: php${{ matrix.php-versions }} lint name: php${{ matrix.php-versions }} lint
steps: steps:

View File

@@ -18,7 +18,7 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
php-versions: ['7.4', '8.0', "8.1"] php-versions: ['7.4', '8.0', '8.1']
databases: ['sqlite', 'mysql', 'pgsql'] databases: ['sqlite', 'mysql', 'pgsql']
server-versions: ['master'] server-versions: ['master']

View File

@@ -69,15 +69,7 @@ class ChangeSet implements \JsonSerializable {
return $this->after; return $this->after;
} }
/** public function jsonSerialize(): array {
* Specify data which should be serialized to JSON
*
* @link http://php.net/manual/en/jsonserializable.jsonserialize.php
* @return mixed data which can be serialized by <b>json_encode</b>,
* which is a value of any type other than a resource.
* @since 5.4.0
*/
public function jsonSerialize() {
return [ return [
'before' => $this->getBefore(), 'before' => $this->getBefore(),
'after' => $this->getAfter(), 'after' => $this->getAfter(),

View File

@@ -58,7 +58,7 @@ class Board extends RelationalEntity {
$this->shared = -1; $this->shared = -1;
} }
public function jsonSerialize() { public function jsonSerialize(): array {
$json = parent::jsonSerialize(); $json = parent::jsonSerialize();
if ($this->shared === -1) { if ($this->shared === -1) {
unset($json['shared']); unset($json['shared']);

View File

@@ -98,11 +98,11 @@ class Card extends RelationalEntity {
return $dt->format('c'); return $dt->format('c');
} }
public function jsonSerialize() { public function jsonSerialize(): array {
$json = parent::jsonSerialize(); $json = parent::jsonSerialize();
$json['overdue'] = self::DUEDATE_FUTURE; $json['overdue'] = self::DUEDATE_FUTURE;
$due = strtotime($this->duedate); $due = $this->duedate ? strtotime($this->duedate) : false;
if ($due !== false) {
$today = new DateTime(); $today = new DateTime();
$today->setTime(0, 0); $today->setTime(0, 0);
@@ -113,7 +113,6 @@ class Card extends RelationalEntity {
$diff = $today->diff($match_date); $diff = $today->diff($match_date);
$diffDays = (integer) $diff->format('%R%a'); // Extract days count in interval $diffDays = (integer) $diff->format('%R%a'); // Extract days count in interval
if ($due !== false) {
if ($diffDays === 1) { if ($diffDays === 1) {
$json['overdue'] = self::DUEDATE_NEXT; $json['overdue'] = self::DUEDATE_NEXT;
} }

View File

@@ -551,7 +551,7 @@ class CardMapper extends QBMapper implements IPermissionMapper {
public function isOwner($userId, $cardId): bool { public function isOwner($userId, $cardId): bool {
$sql = 'SELECT owner FROM `*PREFIX*deck_boards` WHERE `id` IN (SELECT board_id FROM `*PREFIX*deck_stacks` WHERE id IN (SELECT stack_id FROM `*PREFIX*deck_cards` WHERE id = ?))'; $sql = 'SELECT owner FROM `*PREFIX*deck_boards` WHERE `id` IN (SELECT board_id FROM `*PREFIX*deck_stacks` WHERE id IN (SELECT stack_id FROM `*PREFIX*deck_cards` WHERE id = ?))';
$stmt = $this->db->prepare($sql); $stmt = $this->db->prepare($sql);
$stmt->bindParam(1, $cardId, \PDO::PARAM_INT); $stmt->bindParam(1, $cardId, \PDO::PARAM_INT, 0);
$stmt->execute(); $stmt->execute();
$row = $stmt->fetch(); $row = $stmt->fetch();
return ($row['owner'] === $userId); return ($row['owner'] === $userId);

View File

@@ -83,14 +83,14 @@ class LabelMapper extends DeckMapper implements IPermissionMapper {
public function deleteLabelAssignments($labelId) { public function deleteLabelAssignments($labelId) {
$sql = 'DELETE FROM `*PREFIX*deck_assigned_labels` WHERE label_id = ?'; $sql = 'DELETE FROM `*PREFIX*deck_assigned_labels` WHERE label_id = ?';
$stmt = $this->db->prepare($sql); $stmt = $this->db->prepare($sql);
$stmt->bindParam(1, $labelId, \PDO::PARAM_INT); $stmt->bindParam(1, $labelId, \PDO::PARAM_INT, 0);
$stmt->execute(); $stmt->execute();
} }
public function deleteLabelAssignmentsForCard($cardId) { public function deleteLabelAssignmentsForCard($cardId) {
$sql = 'DELETE FROM `*PREFIX*deck_assigned_labels` WHERE card_id = ?'; $sql = 'DELETE FROM `*PREFIX*deck_assigned_labels` WHERE card_id = ?';
$stmt = $this->db->prepare($sql); $stmt = $this->db->prepare($sql);
$stmt->bindParam(1, $cardId, \PDO::PARAM_INT); $stmt->bindParam(1, $cardId, \PDO::PARAM_INT, 0);
$stmt->execute(); $stmt->execute();
} }

View File

@@ -63,7 +63,7 @@ class RelationalEntity extends Entity implements \JsonSerializable {
* @return array serialized data * @return array serialized data
* @throws \ReflectionException * @throws \ReflectionException
*/ */
public function jsonSerialize() { public function jsonSerialize(): array {
$properties = get_object_vars($this); $properties = get_object_vars($this);
$reflection = new \ReflectionClass($this); $reflection = new \ReflectionClass($this);
$json = []; $json = [];

View File

@@ -23,7 +23,9 @@
namespace OCA\Deck\Db; namespace OCA\Deck\Db;
class RelationalObject implements \JsonSerializable { use JsonSerializable;
class RelationalObject implements JsonSerializable {
protected $primaryKey; protected $primaryKey;
protected $object; protected $object;
@@ -38,7 +40,7 @@ class RelationalObject implements \JsonSerializable {
$this->object = $object; $this->object = $object;
} }
public function jsonSerialize() { public function jsonSerialize(): array {
return array_merge( return array_merge(
['primaryKey' => $this->primaryKey], ['primaryKey' => $this->primaryKey],
$this->getObjectSerialization() $this->getObjectSerialization()
@@ -51,8 +53,8 @@ class RelationalObject implements \JsonSerializable {
* @throws \Exception * @throws \Exception
*/ */
public function getObjectSerialization() { public function getObjectSerialization() {
if ($this->object instanceof \JsonSerializable) { if ($this->object instanceof JsonSerializable) {
$this->object->jsonSerialize(); return $this->object->jsonSerialize();
} else { } else {
throw new \Exception('jsonSerialize is not implemented on ' . get_class($this)); throw new \Exception('jsonSerialize is not implemented on ' . get_class($this));
} }

View File

@@ -45,7 +45,7 @@ class Stack extends RelationalEntity {
$this->cards = $cards; $this->cards = $cards;
} }
public function jsonSerialize() { public function jsonSerialize(): array {
$json = parent::jsonSerialize(); $json = parent::jsonSerialize();
if (empty($this->cards)) { if (empty($this->cards)) {
unset($json['cards']); unset($json['cards']);

View File

@@ -338,7 +338,7 @@ class CardService {
$resetDuedateNotification = false; $resetDuedateNotification = false;
if ( if (
$card->getDuedate() === null || $card->getDuedate() === null ||
(new \DateTime($card->getDuedate())) != (new \DateTime($changes->getBefore()->getDuedate())) (new \DateTime($card->getDuedate())) != (new \DateTime($changes->getBefore()->getDuedate() ?? ''))
) { ) {
$card->setNotified(false); $card->setNotified(false);
$resetDuedateNotification = true; $resetDuedateNotification = true;

View File

@@ -31,7 +31,7 @@ namespace OCA\Deck;
*/ */
class StatusException extends \Exception { class StatusException extends \Exception {
public function __construct($message) { public function __construct($message) {
parent::__construct($message); parent::__construct($message ?? '');
} }
public function getStatus() { public function getStatus() {

View File

@@ -1,6 +1,6 @@
{ {
"require-dev": { "require-dev": {
"phpunit/phpunit": "~6.5", "phpunit/phpunit": "~9",
"behat/behat": "~3.8.0", "behat/behat": "~3.8.0",
"guzzlehttp/guzzle": "6.5.2", "guzzlehttp/guzzle": "6.5.2",
"jarnaiz/behat-junit-formatter": "^1.3", "jarnaiz/behat-junit-formatter": "^1.3",

View File

@@ -103,15 +103,13 @@ class ActivityManagerTest extends TestCase {
if ($format !== '') { if ($format !== '') {
$this->assertStringContainsString('{user}', $format); $this->assertStringContainsString('{user}', $format);
} else { } else {
/** @noinspection ForgottenDebugOutputInspection */ self::addWarning('No activity string found for '. $constant);
print_r('No activity string found for '. $constant . PHP_EOL);
} }
$format = $this->activityManager->getActivityFormat('cz', $value, [], true); $format = $this->activityManager->getActivityFormat('cz', $value, [], true);
if ($format !== '') { if ($format !== '') {
$this->assertStringStartsWith('You', $format); $this->assertStringStartsWith('You', $format);
} else { } else {
/** @noinspection ForgottenDebugOutputInspection */ self::addWarning('No own activity string found for '. $constant);
print_r('No own activity string found for '. $constant . PHP_EOL);
} }
} }
} }