Skip to content

Commit

Permalink
Add support for Silverstripe 5 (#70)
Browse files Browse the repository at this point in the history
* Update min requirements. Add support for Silverstripe 5
* Update coding standards from 6 to 8. Add new exclusions. Update linting
  • Loading branch information
chrispenny authored Feb 26, 2023
1 parent 5a379e3 commit 6074668
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 233 deletions.
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ The overall aim of this module is twofold:
* [Queued jobs](#queued-jobs)
* [Case Studies](docs/en/case-studies.md)
* [Fluent support](docs/en/fluent.md)
* [GridField Orderable support](docs/en/gridfield-orderable.md)
* [License](license.md)
* [Maintainers](#maintainers)
* [Development and contribution](#development-and-contribution)
Expand All @@ -41,6 +40,13 @@ The overall aim of this module is twofold:
composer require silverstripe-terraformers/keys-for-cache
```

## Requirements

* PHP `^8.1`
* Silverstripe Framework `^5`

Support for Silverstripe 4 is provided though our `^1` tagged releases.

## Why cache keys are difficult

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

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

## GridField Orderable support

See: [GridField Orderable support](docs/en/gridfield-orderable.md)

## License

Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
}
],
"require": {
"php": "^7.4 || ^8.0",
"silverstripe/framework": "^4.6"
"php": "^8.1",
"silverstripe/framework": "^5"
},
"require-dev": {
"phpunit/phpunit": "^9.5",
"tractorcow/silverstripe-fluent": ">=4.0.0",
"slevomat/coding-standard": "~6.0"
"tractorcow/silverstripe-fluent": "^7",
"slevomat/coding-standard": "~8.8.0"
},
"autoload": {
"psr-4": {
Expand Down
43 changes: 0 additions & 43 deletions docs/en/gridfield-orderable.md

This file was deleted.

25 changes: 25 additions & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
<file>src</file>
<file>tests</file>

<!-- Show progress and output sniff names on violation, and add colours -->
<arg value="p" />
<arg name="colors" />
<arg value="s" />

<rule ref="PSR2">
<!-- Allow non camel cased method names - some base SS method names are PascalCase or snake_case -->
<exclude name="PSR1.Methods.CamelCapsMethodName.NotCamelCaps"/>
Expand Down Expand Up @@ -75,6 +80,26 @@
<exclude name="SlevomatCodingStandard.ControlStructures.DisallowShortTernaryOperator.DisallowedShortTernaryOperator"/>
<!-- You are not making me go \PHP_EOL -->
<exclude name="SlevomatCodingStandard.Namespaces.FullyQualifiedGlobalConstants.NonFullyQualified"/>
<!-- We can't declare classes as abstract/final because that would remove the ability for devs to extend our -->
<!-- classes as they see fit -->
<exclude name="SlevomatCodingStandard.Classes.RequireAbstractOrFinal.ClassNeitherAbstractNorFinal"/>
<!-- We do not require trailing commas on multiline methods. Both rules disabled, as we'll allow folks to -->
<!-- add them if they want them, but we don't enforce either way -->
<exclude name="SlevomatCodingStandard.Functions.RequireTrailingCommaInCall.MissingTrailingComma"/>
<exclude name="SlevomatCodingStandard.Functions.DisallowTrailingCommaInCall.DisallowedTrailingComma"/>
<exclude name="SlevomatCodingStandard.Functions.RequireTrailingCommaInDeclaration.MissingTrailingComma"/>
<exclude name="SlevomatCodingStandard.Functions.DisallowTrailingCommaInDeclaration.DisallowedTrailingComma"/>
<exclude name="SlevomatCodingStandard.Functions.RequireTrailingCommaInClosureUse.MissingTrailingComma"/>
<exclude name="SlevomatCodingStandard.Functions.DisallowTrailingCommaInClosureUse.DisallowedTrailingComma"/>
<!-- Length does not determine complexity. We do not care if methods or files are long -->
<exclude name="SlevomatCodingStandard.Functions.FunctionLength.FunctionLength"/>
<exclude name="SlevomatCodingStandard.Files.FunctionLength.FunctionLength"/>
<exclude name="SlevomatCodingStandard.Files.FileLength.FileTooLong"/>
<exclude name="SlevomatCodingStandard.Classes.ClassLength.ClassTooLong"/>
<!-- We'll decide what is complex -->
<exclude name="SlevomatCodingStandard.Complexity.Cognitive.ComplexityTooHigh"/>
<!-- We require property promotion -->
<exclude name="SlevomatCodingStandard.Classes.DisallowConstructorPropertyPromotion.DisallowedConstructorPropertyPromotion"/>
</rule>

<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses">
Expand Down
11 changes: 7 additions & 4 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="vendor/silverstripe/framework/tests/bootstrap.php" colors="true">
<testsuite name="Default">
<directory>tests/</directory>
</testsuite>
<testsuites>
<testsuite name="Default">
<directory>tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<whitelist addUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src/</directory>
<exclude>
<directory suffix=".php">tests/</directory>
Expand Down
5 changes: 1 addition & 4 deletions src/DataTransferObjects/CacheKeyDto.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@

class CacheKeyDto
{
private ?string $key;

public function __construct(?string $key)
public function __construct(private ?string $key)
{
$this->key = $key;
}

public function getKey(): ?string
Expand Down
6 changes: 1 addition & 5 deletions src/DataTransferObjects/EdgeUpdateDto.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,9 @@

class EdgeUpdateDto
{
private Edge $edge;
private DataObject $instance;

public function __construct(Edge $edge, DataObject $instance)
public function __construct(private readonly Edge $edge, private readonly DataObject $instance)
{
$this->edge = $edge;
$this->instance = $instance;
}

public function getEdge(): Edge
Expand Down
8 changes: 1 addition & 7 deletions src/DataTransferObjects/ProcessedUpdateDto.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,10 @@

class ProcessedUpdateDto
{
private string $className;

private int $id;

private bool $published = false;

public function __construct(string $className, int $id)
public function __construct(private readonly string $className, private readonly int $id)
{
$this->className = $className;
$this->id = $id;
}

public function getClassName(): string
Expand Down
147 changes: 0 additions & 147 deletions src/Extensions/GridFieldOrderableRowsExtension.php

This file was deleted.

17 changes: 6 additions & 11 deletions src/RelationshipGraph/Edge.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,12 @@

class Edge
{
private Node $from;
private Node $to;
private string $relation;
private string $relationType;

public function __construct(Node $from, Node $to, string $relation, string $relationType)
{
$this->from = $from;
$this->to = $to;
$this->relation = $relation;
$this->relationType = $relationType;
public function __construct(
private readonly Node $from,
private readonly Node $to,
private readonly string $relation,
private readonly string $relationType
) {
}

public function getFromClassName(): string
Expand Down
5 changes: 1 addition & 4 deletions src/RelationshipGraph/Node.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@

class Node
{
private string $className;

public function __construct(string $className)
public function __construct(private readonly string $className)
{
$this->className = $className;
}

public function getClassName(): string
Expand Down

0 comments on commit 6074668

Please sign in to comment.