Skip to content

Commit 5cb2cd7

Browse files
committed
(upgrade): PHP 8.0
1 parent 0bd6055 commit 5cb2cd7

File tree

464 files changed

+4323
-12951
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

464 files changed

+4323
-12951
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
/settings.php
33
/multi.settings.php
44
!.gitlab-ci.yml
5+
!.php-cs-fixer.php
56
bin
67

78
/.htaccess

.gitlab-ci.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
image: minds/php:7.3
1+
image: minds/php:8.0
22

33
stages:
44
- build
@@ -23,16 +23,24 @@ build:
2323

2424
test:
2525
stage: test
26-
image: minds/php:7.3
26+
image: minds/php:8.0
2727
script:
2828
- php -n -c Spec/php-test.ini bin/phpspec run
2929

3030
lint:
3131
stage: test
32-
image: minds/php:7.3
32+
image: minds/php:8.0
3333
script:
3434
- bin/php-cs-fixer fix --allow-risky=yes --verbose --dry-run
3535

36+
static-analysis:
37+
stage: test
38+
image: minds/php:8.0
39+
script:
40+
- mv settings.example.php settings.php
41+
- bin/phpstan analyse --memory-limit=1G
42+
allow_failure: true
43+
3644
prepare:fpm:
3745
stage: prepare
3846
image: minds/ci:latest
@@ -184,7 +192,7 @@ staging:fpm:
184192
only:
185193
refs:
186194
- master
187-
- feat/1732-block-refactor
195+
- feat/php8
188196
- production
189197
- test/gitlab-ci
190198

.php_cs renamed to .php-cs-fixer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
->exclude(['vendor','lib','classes'])
55
->in(__DIR__);
66

7-
return PhpCsFixer\Config::create()
7+
return (new PhpCsFixer\Config())
88
->setRules([
99
'@PSR2' => true,
1010
'strict_param' => true,

Api/Exportable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,6 @@ public function jsonSerialize()
168168
*/
169169
public static function _($items = [])
170170
{
171-
return new static($items);
171+
return new self($items);
172172
}
173173
}

Api/Factory.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,9 @@ public static function exportable($entities, $exceptions = [], $exportContext =
223223
}
224224

225225
$entities[$k] = $entity->export();
226-
$entities[$k]['guid'] = (string) $entities[$k]['guid']; //javascript doesn't like long numbers..
226+
if (isset($entities[$k]['guid'])) {
227+
$entities[$k]['guid'] = (string) $entities[$k]['guid']; //javascript doesn't like long numbers..
228+
}
227229
if (isset($entities[$k]['ownerObj']['guid'])) {
228230
$entities[$k]['ownerObj']['guid'] = (string) $entity->ownerObj['guid'];
229231
}

Common/Jwt.php

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,30 @@
88

99
use DateTimeImmutable;
1010
use Exception;
11-
use Lcobucci\JWT\Builder;
11+
use Lcobucci\JWT\Configuration;
1212
use Lcobucci\JWT\Claim;
13-
use Lcobucci\JWT\Parser;
1413
use Lcobucci\JWT\Signer\Hmac\Sha256;
1514
use Lcobucci\JWT\Signer\Key\InMemory;
15+
use Lcobucci\JWT\Validation\Constraint\SignedWith;
1616

1717
class Jwt
1818
{
1919
/** @var string */
2020
protected $key;
2121

22+
/** @var Configuration */
23+
protected $jwtConfig;
24+
2225
/**
2326
* @param string $key
2427
* @return Jwt
2528
*/
2629
public function setKey(string $key): Jwt
2730
{
2831
$this->key = $key;
32+
33+
$this->jwtConfig = Configuration::forSymmetricSigner(new Sha256(), InMemory::plainText($key));
34+
2935
return $this;
3036
}
3137

@@ -42,21 +48,21 @@ public function encode($payload, $exp = null, $nbf = null): string
4248
throw new Exception('Invalid JWT key');
4349
}
4450

45-
$builder = new Builder();
51+
$builder = $this->jwtConfig->builder();
4652

4753
foreach ($payload as $key => $value) {
48-
$builder->set($key, $value);
54+
$builder->withClaim($key, $value);
4955
}
5056

5157
if ($exp !== null) {
52-
$builder->setExpiration((new DateTimeImmutable())->setTimestamp($exp));
58+
$builder->expiresAt((new DateTimeImmutable())->setTimestamp($exp));
5359
}
5460

5561
if ($nbf !== null) {
56-
$builder->setNotBefore((new DateTimeImmutable())->setTimestamp($nbf));
62+
$builder->canOnlyBeUsedAfter((new DateTimeImmutable())->setTimestamp($nbf));
5763
}
5864

59-
return (string) $builder->getToken(new Sha256(), new InMemory($this->key));
65+
return (string) $builder->getToken($this->jwtConfig->signer(), $this->jwtConfig->signingKey())->toString();
6066
}
6167

6268
/**
@@ -70,15 +76,13 @@ public function decode($jwt): array
7076
throw new Exception('Invalid JWT key');
7177
}
7278

73-
$token = (new Parser())->parse($jwt);
79+
$token = $this->jwtConfig->parser()->parse($jwt);
7480

75-
if (!$token->verify(new Sha256(), new InMemory($this->key))) {
81+
if (!$this->jwtConfig->validator()->validate($token, new SignedWith($this->jwtConfig->signer(), $this->jwtConfig->signingKey()))) {
7682
throw new Exception('Invalid JWT');
7783
}
7884

79-
return array_map(function (Claim $claim) {
80-
return $claim->getValue();
81-
}, $token->getClaims());
85+
return $token->claims()->all();
8286
}
8387

8488
/**

Common/Regex.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class Regex
1717
const CASH_TAG = '/([^&]|\b|^)\$([A-Za-z]+)/uim';
1818

1919
// #tags | $tags
20-
const HASH_CASH_TAG = '/([^&]|\b|^)#([\wÀ-ÿ\u0E00-\u0E7F\u2460-\u9FBB]+)|([^&]|\b|^)\$([A-Za-z]+)/uim';
20+
const HASH_CASH_TAG = '/([^&]|\b|^)#([\wÀ-ÿ\x0E00\x0E7F\x2460-\x9FBB]+)|([^&]|\b|^)\$([A-Za-z]+)/uim';
2121

2222
/**
2323
* Wrapper around preg_match_all for testing.

Common/Repository/Response.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ public function jsonSerialize()
296296
*/
297297
public function reverse($preserveKeys = false)
298298
{
299-
return new static(array_reverse($this->data, $preserveKeys), $this->pagingToken);
299+
return new self(array_reverse($this->data, $preserveKeys), $this->pagingToken);
300300
}
301301

302302
/**
@@ -315,7 +315,7 @@ public function filter($callback, $preserveKeys = false)
315315
$filtered = array_values($filtered);
316316
}
317317

318-
return new static($filtered, $this->pagingToken);
318+
return new self($filtered, $this->pagingToken);
319319
}
320320

321321
/**
@@ -325,7 +325,7 @@ public function filter($callback, $preserveKeys = false)
325325
*/
326326
public function map($callback)
327327
{
328-
return new static(array_map($callback, $this->data), $this->pagingToken);
328+
return new self(array_map($callback, $this->data), $this->pagingToken);
329329
}
330330

331331
/**
@@ -348,7 +348,7 @@ public function sort(callable $callback): Response
348348
$data = $this->data;
349349
usort($data, $callback);
350350

351-
return new static($data, $this->pagingToken);
351+
return new self($data, $this->pagingToken);
352352
}
353353

354354
/**

Common/Urn.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ class Urn implements \JsonSerializable
1818
/** @var string */
1919
protected $nss;
2020

21+
/** @var string[] */
22+
protected $components = [];
23+
2124
/**
2225
* Urn constructor.
2326
* @param string $urn
@@ -133,6 +136,6 @@ public function jsonSerialize()
133136
*/
134137
public static function _($urn)
135138
{
136-
return new static($urn);
139+
return new self($urn);
137140
}
138141
}

Controllers/Cli/Contributions.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,7 @@ public function test()
169169
$totals_by_time = [];
170170
foreach ($results as $result) {
171171
$totals += $result->getAmount();
172-
$totals_by_type[$result->getMetric()] += $result->getAmount();
173172
}
174173
var_dump($totals);
175-
var_dump($totals_by_type);
176174
}
177175
}

Controllers/Cli/CustomerSync.php

Lines changed: 0 additions & 59 deletions
This file was deleted.

Controllers/Cli/Email.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
use Minds\Core\Suggestions\Manager;
2727
use Minds\Core\Analytics\Timestamps;
2828
use Minds\Core\Di\Di;
29+
use Minds\Core\Email\Campaigns\WirePromotions as CampaignsWirePromotions;
30+
use Minds\Exceptions\CliException;
2931

3032
class Email extends Cli\Controller implements Interfaces\CliControllerInterface
3133
{
@@ -261,7 +263,7 @@ public function testWirePromotion()
261263
exit;
262264
}
263265

264-
$campaign = (new WirePromotion())
266+
$campaign = (new CampaignsWirePromotions())
265267
->setUser($user);
266268

267269
$message = $campaign->build();
@@ -347,6 +349,7 @@ public function testWire()
347349
$campaign = (new WireReceived());
348350
} else {
349351
$this->out('--variant must be sent or received');
352+
return;
350353
}
351354

352355
$campaign

Controllers/Cli/Install.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public function exec()
7272
$provisioner->reloadStorage();
7373
$this->out('OK');
7474
}
75-
} catch (Exception $ex) {
75+
} catch (\Exception $ex) {
7676
$this->out('Something BAD happened while provisioning Cassandra' . $ex->getMessage());
7777
}
7878

Controllers/Cli/Matrix.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function syncUser()
6262
$this->manager->syncAccount($user);
6363

6464
$this->blockListSync->sync($user);
65-
} catch (\Excepton $e) {
65+
} catch (\Exception $e) {
6666
}
6767

6868
$this->out("{$user->getGuid()}");

0 commit comments

Comments
 (0)