Skip to content

Commit 6074668

Browse files
authored
Add support for Silverstripe 5 (#70)
* Update min requirements. Add support for Silverstripe 5 * Update coding standards from 6 to 8. Add new exclusions. Update linting
1 parent 5a379e3 commit 6074668

File tree

11 files changed

+53
-233
lines changed

11 files changed

+53
-233
lines changed

README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ The overall aim of this module is twofold:
3030
* [Queued jobs](#queued-jobs)
3131
* [Case Studies](docs/en/case-studies.md)
3232
* [Fluent support](docs/en/fluent.md)
33-
* [GridField Orderable support](docs/en/gridfield-orderable.md)
3433
* [License](license.md)
3534
* [Maintainers](#maintainers)
3635
* [Development and contribution](#development-and-contribution)
@@ -41,6 +40,13 @@ The overall aim of this module is twofold:
4140
composer require silverstripe-terraformers/keys-for-cache
4241
```
4342

43+
## Requirements
44+
45+
* PHP `^8.1`
46+
* Silverstripe Framework `^5`
47+
48+
Support for Silverstripe 4 is provided though our `^1` tagged releases.
49+
4450
## Why cache keys are difficult
4551

4652
The goal of any cache key is to have as low a cost as possible to calculate (as this must happen with every request),
@@ -289,9 +295,6 @@ See: [Case studies](docs/en/case-studies.md)
289295

290296
See: [Fluent support](docs/en/fluent.md)
291297

292-
## GridField Orderable support
293-
294-
See: [GridField Orderable support](docs/en/gridfield-orderable.md)
295298

296299
## License
297300

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@
1919
}
2020
],
2121
"require": {
22-
"php": "^7.4 || ^8.0",
23-
"silverstripe/framework": "^4.6"
22+
"php": "^8.1",
23+
"silverstripe/framework": "^5"
2424
},
2525
"require-dev": {
2626
"phpunit/phpunit": "^9.5",
27-
"tractorcow/silverstripe-fluent": ">=4.0.0",
28-
"slevomat/coding-standard": "~6.0"
27+
"tractorcow/silverstripe-fluent": "^7",
28+
"slevomat/coding-standard": "~8.8.0"
2929
},
3030
"autoload": {
3131
"psr-4": {

docs/en/gridfield-orderable.md

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

phpcs.xml.dist

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
<file>src</file>
66
<file>tests</file>
77

8+
<!-- Show progress and output sniff names on violation, and add colours -->
9+
<arg value="p" />
10+
<arg name="colors" />
11+
<arg value="s" />
12+
813
<rule ref="PSR2">
914
<!-- Allow non camel cased method names - some base SS method names are PascalCase or snake_case -->
1015
<exclude name="PSR1.Methods.CamelCapsMethodName.NotCamelCaps"/>
@@ -75,6 +80,26 @@
7580
<exclude name="SlevomatCodingStandard.ControlStructures.DisallowShortTernaryOperator.DisallowedShortTernaryOperator"/>
7681
<!-- You are not making me go \PHP_EOL -->
7782
<exclude name="SlevomatCodingStandard.Namespaces.FullyQualifiedGlobalConstants.NonFullyQualified"/>
83+
<!-- We can't declare classes as abstract/final because that would remove the ability for devs to extend our -->
84+
<!-- classes as they see fit -->
85+
<exclude name="SlevomatCodingStandard.Classes.RequireAbstractOrFinal.ClassNeitherAbstractNorFinal"/>
86+
<!-- We do not require trailing commas on multiline methods. Both rules disabled, as we'll allow folks to -->
87+
<!-- add them if they want them, but we don't enforce either way -->
88+
<exclude name="SlevomatCodingStandard.Functions.RequireTrailingCommaInCall.MissingTrailingComma"/>
89+
<exclude name="SlevomatCodingStandard.Functions.DisallowTrailingCommaInCall.DisallowedTrailingComma"/>
90+
<exclude name="SlevomatCodingStandard.Functions.RequireTrailingCommaInDeclaration.MissingTrailingComma"/>
91+
<exclude name="SlevomatCodingStandard.Functions.DisallowTrailingCommaInDeclaration.DisallowedTrailingComma"/>
92+
<exclude name="SlevomatCodingStandard.Functions.RequireTrailingCommaInClosureUse.MissingTrailingComma"/>
93+
<exclude name="SlevomatCodingStandard.Functions.DisallowTrailingCommaInClosureUse.DisallowedTrailingComma"/>
94+
<!-- Length does not determine complexity. We do not care if methods or files are long -->
95+
<exclude name="SlevomatCodingStandard.Functions.FunctionLength.FunctionLength"/>
96+
<exclude name="SlevomatCodingStandard.Files.FunctionLength.FunctionLength"/>
97+
<exclude name="SlevomatCodingStandard.Files.FileLength.FileTooLong"/>
98+
<exclude name="SlevomatCodingStandard.Classes.ClassLength.ClassTooLong"/>
99+
<!-- We'll decide what is complex -->
100+
<exclude name="SlevomatCodingStandard.Complexity.Cognitive.ComplexityTooHigh"/>
101+
<!-- We require property promotion -->
102+
<exclude name="SlevomatCodingStandard.Classes.DisallowConstructorPropertyPromotion.DisallowedConstructorPropertyPromotion"/>
78103
</rule>
79104

80105
<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses">

phpunit.xml.dist

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
12
<phpunit bootstrap="vendor/silverstripe/framework/tests/bootstrap.php" colors="true">
2-
<testsuite name="Default">
3-
<directory>tests/</directory>
4-
</testsuite>
3+
<testsuites>
4+
<testsuite name="Default">
5+
<directory>tests</directory>
6+
</testsuite>
7+
</testsuites>
58
<filter>
6-
<whitelist processUncoveredFilesFromWhitelist="true">
9+
<whitelist addUncoveredFilesFromWhitelist="true">
710
<directory suffix=".php">src/</directory>
811
<exclude>
912
<directory suffix=".php">tests/</directory>

src/DataTransferObjects/CacheKeyDto.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,8 @@
44

55
class CacheKeyDto
66
{
7-
private ?string $key;
8-
9-
public function __construct(?string $key)
7+
public function __construct(private ?string $key)
108
{
11-
$this->key = $key;
129
}
1310

1411
public function getKey(): ?string

src/DataTransferObjects/EdgeUpdateDto.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,9 @@
77

88
class EdgeUpdateDto
99
{
10-
private Edge $edge;
11-
private DataObject $instance;
1210

13-
public function __construct(Edge $edge, DataObject $instance)
11+
public function __construct(private readonly Edge $edge, private readonly DataObject $instance)
1412
{
15-
$this->edge = $edge;
16-
$this->instance = $instance;
1713
}
1814

1915
public function getEdge(): Edge

src/DataTransferObjects/ProcessedUpdateDto.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,10 @@
44

55
class ProcessedUpdateDto
66
{
7-
private string $className;
8-
9-
private int $id;
10-
117
private bool $published = false;
128

13-
public function __construct(string $className, int $id)
9+
public function __construct(private readonly string $className, private readonly int $id)
1410
{
15-
$this->className = $className;
16-
$this->id = $id;
1711
}
1812

1913
public function getClassName(): string

src/Extensions/GridFieldOrderableRowsExtension.php

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

src/RelationshipGraph/Edge.php

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,12 @@
44

55
class Edge
66
{
7-
private Node $from;
8-
private Node $to;
9-
private string $relation;
10-
private string $relationType;
11-
12-
public function __construct(Node $from, Node $to, string $relation, string $relationType)
13-
{
14-
$this->from = $from;
15-
$this->to = $to;
16-
$this->relation = $relation;
17-
$this->relationType = $relationType;
7+
public function __construct(
8+
private readonly Node $from,
9+
private readonly Node $to,
10+
private readonly string $relation,
11+
private readonly string $relationType
12+
) {
1813
}
1914

2015
public function getFromClassName(): string

0 commit comments

Comments
 (0)