Skip to content

Commit 30bdd95

Browse files
authored
Merge pull request #10 from timonf/blocking-upgrade
allow symfony 4 or higher, raise minimum php version to 7.4
2 parents bf801d0 + bf5cc1b commit 30bdd95

46 files changed

Lines changed: 317 additions & 234 deletions

Some content is hidden

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

.github/workflows/test.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: "Test"
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+
- "7.4"
20+
- "8.0"
21+
- "8.1"
22+
operating-system: ["ubuntu-latest"]
23+
24+
steps:
25+
- name: "Checkout"
26+
uses: "actions/checkout@v2"
27+
28+
- name: "Install PHP"
29+
uses: "shivammathur/setup-php@v2"
30+
with:
31+
coverage: "none"
32+
php-version: "${{ matrix.php-version }}"
33+
34+
- name: "Cache dependencies"
35+
uses: "actions/cache@v2"
36+
with:
37+
path: "~/.composer/cache"
38+
key: "php-${{ matrix.php-version }}-composer-${{ hashFiles('**/composer.json') }}"
39+
restore-keys: "php-${{ matrix.php-version }}-composer-"
40+
41+
- name: "Install lowest dependencies"
42+
if: ${{ matrix.dependencies == 'lowest' }}
43+
run: "composer update --prefer-lowest --prefer-dist --no-interaction --no-progress --no-suggest"
44+
45+
- name: "Install highest dependencies"
46+
if: ${{ matrix.dependencies == 'highest' }}
47+
run: "composer update --prefer-dist --no-interaction --no-progress --no-suggest"
48+
49+
- name: "Unit tests"
50+
run: "vendor/bin/phpunit"
51+
52+
- name: "Coding style"
53+
run: "vendor/bin/phpcs --report=summary"
54+
55+
- name: "Static analysis"
56+
run: "vendor/bin/phpstan --no-progress"

.scrutinizer.yml

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

.travis.yml

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

README.md

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,33 @@ Blocking Component
33

44
[![Latest Version](https://img.shields.io/github/release/brainbits/blocking.svg?style=flat-square)](https://github.com/brainbits/blocking/releases)
55
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE)
6-
[![Build Status](https://img.shields.io/travis/brainbits/blocking/master.svg?style=flat-square)](https://travis-ci.org/brainbits/blocking)
7-
[![Coverage Status](https://img.shields.io/scrutinizer/coverage/g/brainbits/blocking.svg?style=flat-square)](https://scrutinizer-ci.com/g/brainbits/blocking/code-structure)
8-
[![Quality Score](https://img.shields.io/scrutinizer/g/brainbits/blocking.svg?style=flat-square)](https://scrutinizer-ci.com/g/brainbits/blocking)
9-
[![Insight](https://img.shields.io/sensiolabs/i/bc35527c-11d8-45a1-a482-18d376cfe382.svg)](https://insight.sensiolabs.com/projects/bc35527c-11d8-45a1-a482-18d376cfe382)
106
[![Total Downloads](https://img.shields.io/packagist/dt/brainbits/blocking.svg?style=flat-square)](https://packagist.org/packages/brainbits/blocking)
7+
[![Tests](https://github.com/brainbits/blocking/actions/workflows/test.yml/badge.svg)](https://github.com/brainbits/blocking/actions)
118

129
The Blocking Component provides methods to manage content based blocking.
1310

14-
<?php
11+
```php
12+
<?php
1513

16-
use Brainbits\Blocking\Blocker;
17-
use Brainbits\Blocking\Identity\Identity;
18-
use Brainbits\Blocking\Owner\SymfonySessionOwnerFactory;
19-
use Brainbits\Blocking\Storage\FilesystemStorage;
20-
use Brainbits\Blocking\Validator\ExpiredValidator;
14+
use Brainbits\Blocking\Blocker;
15+
use Brainbits\Blocking\Identity\Identity;
16+
use Brainbits\Blocking\Owner\SymfonySessionOwnerFactory;
17+
use Brainbits\Blocking\Storage\FilesystemStorage;
18+
use Brainbits\Blocking\Validator\ExpiredValidator;
2119

22-
$storage = new FilesystemStorage('/where/to/store/blocks' /* path to directory on filesystem */);
23-
$ownerFactory = new SymfonySessionOwnerFactory($session /* symfony session */);
24-
$validator = new ExpiredValidator(300 /* block will expire after 300 seconds */);
20+
$storage = new FilesystemStorage('/where/to/store/blocks' /* path to directory on filesystem */);
21+
$ownerFactory = new SymfonySessionOwnerFactory($session /* symfony session */);
22+
$validator = new ExpiredValidator(300 /* block will expire after 300 seconds */);
2523

26-
$blocker = new Blocker($storage, $ownerFactory, $validator);
24+
$blocker = new Blocker($storage, $ownerFactory, $validator);
2725

28-
$identity = new Identity('my_content_123);
26+
$identity = new Identity('my_content_123');
2927

30-
$block = $blocker->block($identity);
31-
$result = $blocker->unblock($identity);
32-
$result = $blocker->isBlocked($identity);
33-
$block = $blocker->getBlock($identity);
28+
$block = $blocker->block($identity);
29+
$result = $blocker->unblock($identity);
30+
$result = $blocker->isBlocked($identity);
31+
$block = $blocker->getBlock($identity);
32+
```
3433

3534
Blocking Storage
3635
----------------

composer.json

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,26 @@
1111
}
1212
],
1313
"require": {
14-
"php": "^7.1"
14+
"php": "^7.4|^8.0"
1515
},
1616
"require-dev": {
17-
"mikey179/vfsstream": "^1.2",
18-
"phpunit/phpunit": "^6.0",
19-
"symfony/http-foundation": "^2.8|^3.0",
20-
"symfony/security-core": "^2.8|^3.0"
17+
"mikey179/vfsstream": "^1.6.10",
18+
"phpunit/phpunit": "^9.5",
19+
"symfony/http-foundation": ">=4.4",
20+
"symfony/security-core": ">=4.4",
21+
"phpspec/prophecy-phpunit": "^2.0.1",
22+
"squizlabs/php_codesniffer": "^3.6",
23+
"brainbits/phpcs-standard": "^5.0",
24+
"phpstan/phpstan": "^0.12.99",
25+
"brainbits/phpstan-rules": "^2.0"
2126
},
2227
"suggest": {
2328
"symfony/http-foundation": "If you want to use the SymfonySessionOwnerFactory",
2429
"symfony/security-core": "If you want to use the SymfonyTokenOwnerFactory"
2530
},
31+
"conflict": {
32+
"phpspec/prophecy": "1.12.*"
33+
},
2634
"autoload": {
2735
"psr-4": { "Brainbits\\Blocking\\": "src/" }
2836
},

phpcs.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0"?>
2+
<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" />
6+
<rule ref="Brainbits">
7+
<exclude name="SlevomatCodingStandard.Classes.SuperfluousExceptionNaming.SuperfluousSuffix" />
8+
<exclude name="SlevomatCodingStandard.Classes.SuperfluousInterfaceNaming.SuperfluousSuffix" />
9+
</rule>
10+
</ruleset>

phpstan.neon

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
parameters:
2+
level: max
3+
paths:
4+
- src
5+
bootstrapFiles:
6+
- vendor/autoload.php
7+
includes:
8+
- vendor/brainbits/phpstan-rules/rules.neon

phpunit.xml.dist

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,8 @@
33
colors="true"
44
convertErrorsToExceptions="true"
55
convertNoticesToExceptions="true"
6-
convertWarningsToExceptions="true"
7-
syntaxCheck="true">
6+
convertWarningsToExceptions="true">
87
<testsuite name="blocking">
9-
<directory>Tests</directory>
8+
<directory suffix=".php">tests</directory>
109
</testsuite>
11-
<filter>
12-
<whitelist>
13-
<directory suffix=".php">src</directory>
14-
</whitelist>
15-
</filter>
1610
</phpunit>

src/Block.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
declare(strict_types = 1);
3+
declare(strict_types=1);
44

55
/*
66
* This file is part of the brainbits blocking package.
@@ -22,10 +22,10 @@
2222
*/
2323
class Block implements BlockInterface
2424
{
25-
private $identifier;
26-
private $owner;
27-
private $createdAt;
28-
private $updatedAt;
25+
private IdentityInterface $identifier;
26+
private OwnerInterface $owner;
27+
private DateTimeImmutable $createdAt;
28+
private DateTimeImmutable $updatedAt;
2929

3030
public function __construct(IdentityInterface $identifier, OwnerInterface $owner, DateTimeImmutable $createdAt)
3131
{

src/BlockInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
declare(strict_types = 1);
3+
declare(strict_types=1);
44

55
/*
66
* This file is part of the brainbits blocking package.

0 commit comments

Comments
 (0)