Skip to content

Commit 615db67

Browse files
authored
Merge pull request #20 from temp/feature/predis-and-cleanup
Feature/predis and cleanup
2 parents 9912e9a + e39059a commit 615db67

File tree

63 files changed

+1821
-958
lines changed

Some content is hidden

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

63 files changed

+1821
-958
lines changed

.github/workflows/test-redis.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: "Test Redis"
2+
3+
on:
4+
push:
5+
pull_request:
6+
schedule:
7+
- cron: '0 03 * * 1' # At 03:00 on Monday.
8+
9+
jobs:
10+
tests:
11+
name: "Tests"
12+
13+
runs-on: ${{ matrix.operating-system }}
14+
15+
strategy:
16+
matrix:
17+
dependencies: ["lowest", "highest"]
18+
php-version:
19+
- "8.2"
20+
operating-system: ["ubuntu-latest"]
21+
22+
steps:
23+
- name: "Checkout"
24+
uses: "actions/checkout@v3"
25+
26+
- name: "Install PHP"
27+
uses: "shivammathur/setup-php@v2"
28+
with:
29+
coverage: "none"
30+
php-version: "${{ matrix.php-version }}"
31+
32+
- name: "Cache dependencies"
33+
uses: "actions/cache@v3"
34+
with:
35+
path: "~/.composer/cache"
36+
key: "php-${{ matrix.php-version }}-composer-${{ hashFiles('**/composer.json') }}"
37+
restore-keys: "php-${{ matrix.php-version }}-composer-"
38+
39+
- name: "Install lowest dependencies"
40+
if: ${{ matrix.dependencies == 'lowest' }}
41+
run: "composer update --prefer-lowest --prefer-dist --no-interaction --no-progress --no-suggest"
42+
43+
- name: "Install highest dependencies"
44+
if: ${{ matrix.dependencies == 'highest' }}
45+
run: "composer update --prefer-dist --no-interaction --no-progress --no-suggest"
46+
47+
- name: "Start Redis"
48+
uses: "supercharge/redis-github-action@1.5.0"
49+
with:
50+
redis-version: "6"
51+
52+
- name: "Unit tests"
53+
run: "REDIS_DSN='redis://127.0.0.1:6379' vendor/bin/phpunit --group redis --fail-on-skipped"

.github/workflows/test.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ jobs:
1616
matrix:
1717
dependencies: ["lowest", "highest"]
1818
php-version:
19-
- "8.1"
2019
- "8.2"
2120
operating-system: ["ubuntu-latest"]
2221

@@ -46,7 +45,7 @@ jobs:
4645
run: "composer update --prefer-dist --no-interaction --no-progress --no-suggest"
4746

4847
- name: "Unit tests"
49-
run: "vendor/bin/phpunit"
48+
run: "vendor/bin/phpunit --exclude-group redis"
5049

5150
- name: "Coding style"
5251
run: "vendor/bin/phpcs --report=summary"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/.idea/
2+
/.phpcs-cache
23
/.phpunit.cache
34
/composer.lock
45
/phpcs.xml

composer.json

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,30 @@
1111
}
1212
],
1313
"require": {
14-
"php": "^8.1"
14+
"php": "^8.2",
15+
"psr/clock": "^1.0"
1516
},
1617
"require-dev": {
18+
"brainbits/phpcs-standard": "^7.0",
19+
"brainbits/phpstan-rules": "^3.0",
20+
"matthiasnoback/symfony-config-test": "^4.3",
21+
"matthiasnoback/symfony-dependency-injection-test": "^4.3",
1722
"mikey179/vfsstream": "^1.6.10",
23+
"phpstan/phpstan": "^1.0",
1824
"phpunit/phpunit": "^10.1",
25+
"predis/predis": "^2.2",
26+
"symfony/clock": "^6.3",
27+
"symfony/config": "^6.0",
28+
"symfony/dependency-injection": "^6.0",
1929
"symfony/http-foundation": "^6.0",
30+
"symfony/http-kernel": "^6.0",
31+
"symfony/routing": "^6.0",
2032
"symfony/security-core": "^6.0",
21-
"brainbits/phpcs-standard": "^7.0",
22-
"phpstan/phpstan": "^1.0",
23-
"brainbits/phpstan-rules": "^3.0"
33+
"phpstan/phpstan-phpunit": "^1.3",
34+
"phpstan/phpstan-symfony": "^1.3"
2435
},
2536
"suggest": {
37+
"predis/predis": "If you want to use the PredisStorage",
2638
"symfony/http-foundation": "If you want to use the SymfonySessionOwnerFactory",
2739
"symfony/security-core": "If you want to use the SymfonyTokenOwnerFactory"
2840
},

phpcs.xml.dist

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,26 @@
11
<?xml version="1.0"?>
22
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="PHP_CodeSniffer" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/squizlabs/PHP_CodeSniffer/master/phpcs.xsd">
3-
<file extension="php">src/</file>
4-
<arg name="basepath" value="." />
5-
<arg name="colors" />
3+
4+
<file>src</file>
5+
<file>tests</file>
6+
7+
<!-- Start here -->
8+
<arg name="basepath" value="."/>
9+
<!-- Only .php -->
10+
<arg name="extensions" value="php"/>
11+
<!-- 80 parallel -->
12+
<arg name="parallel" value="10"/>
13+
<!-- User cache dir -->
14+
<arg name="cache" value=".phpcs-cache"/>
15+
<!-- Show colors -->
16+
<arg name="colors"/>
17+
<!-- Show progress -->
18+
<arg value="p"/>
19+
<!-- Show sniff names -->
20+
<arg value="s"/>
21+
622
<rule ref="Brainbits">
23+
<exclude name="PSR1.Files.SideEffects.FoundWithSymbols" />
724
<exclude name="SlevomatCodingStandard.Classes.SuperfluousExceptionNaming.SuperfluousSuffix" />
825
<exclude name="SlevomatCodingStandard.Classes.SuperfluousInterfaceNaming.SuperfluousSuffix" />
926
</rule>

phpstan.neon.dist

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ parameters:
66
- vendor/autoload.php
77
includes:
88
- vendor/brainbits/phpstan-rules/rules.neon
9+
- vendor/phpstan/phpstan-phpunit/rules.neon
10+
- vendor/phpstan/phpstan-phpunit/extension.neon
11+
- vendor/phpstan/phpstan-symfony/extension.neon

phpunit.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.1/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.2/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
33
<testsuite name="blocking">
44
<directory suffix=".php">tests</directory>
55
</testsuite>

src/Block.php

Lines changed: 8 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -13,52 +13,29 @@
1313

1414
namespace Brainbits\Blocking;
1515

16-
use Brainbits\Blocking\Identity\IdentityInterface;
17-
use Brainbits\Blocking\Owner\OwnerInterface;
18-
use DateTimeImmutable;
16+
use Brainbits\Blocking\Identity\BlockIdentity;
17+
use Brainbits\Blocking\Owner\Owner;
1918

20-
/**
21-
* Standard block.
22-
*/
23-
class Block implements BlockInterface
19+
final class Block
2420
{
25-
private DateTimeImmutable $updatedAt;
26-
2721
public function __construct(
28-
private IdentityInterface $identifier,
29-
private OwnerInterface $owner,
30-
private DateTimeImmutable $createdAt,
22+
private BlockIdentity $identifier,
23+
private Owner $owner,
3124
) {
32-
$this->updatedAt = $createdAt;
3325
}
3426

35-
public function getIdentity(): IdentityInterface
27+
public function getIdentity(): BlockIdentity
3628
{
3729
return $this->identifier;
3830
}
3931

40-
public function getOwner(): OwnerInterface
32+
public function getOwner(): Owner
4133
{
4234
return $this->owner;
4335
}
4436

45-
public function isOwnedBy(OwnerInterface $owner): bool
37+
public function isOwnedBy(Owner $owner): bool
4638
{
4739
return $this->owner->equals($owner);
4840
}
49-
50-
public function getCreatedAt(): DateTimeImmutable
51-
{
52-
return $this->createdAt;
53-
}
54-
55-
public function getUpdatedAt(): DateTimeImmutable
56-
{
57-
return $this->updatedAt;
58-
}
59-
60-
public function touch(DateTimeImmutable $updatedAt): void
61-
{
62-
$this->updatedAt = $updatedAt;
63-
}
6441
}

src/BlockInterface.php

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

src/BlockableInterface.php

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

0 commit comments

Comments
 (0)