Skip to content

Commit

Permalink
Support PHP 8.1, bump minimum to 7.3 (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
francislavoie authored Nov 26, 2021
1 parent 0bf7ae2 commit e1e5c3a
Show file tree
Hide file tree
Showing 16 changed files with 490 additions and 57 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Test

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
test:
name: PHP ${{ matrix.php-versions }} on ${{ matrix.operating-system }}
runs-on: ${{ matrix.operating-system }}
strategy:
fail-fast: false
matrix:
operating-system: [ubuntu-latest]
php-versions: ['7.3', '7.4', '8.0', '8.1']

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
with:
php-version: ${{ matrix.php-versions }}
coverage: pcov
tools: composer:v2
env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Get composer cache directory
id: composercache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Setup problem matchers
run: |
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- name: Cache composer dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composercache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install Composer dependencies
run: composer install --prefer-dist

- name: Test with phpunit
run: composer test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ composer.lock
composer.phar
coverage/
vendor/
.phpunit.result.cache
7 changes: 0 additions & 7 deletions .scrutinizer.yml

This file was deleted.

23 changes: 0 additions & 23 deletions .travis.yml

This file was deleted.

14 changes: 9 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,18 @@
"source": "https://github.com/Vectorface/auth"
},
"require": {
"php": "^7.1",
"php": ">=7.3",
"psr/log": "^1.0"
},
"require-dev": {
"phpunit/phpunit": "^7.0",
"phpunit/phpunit": "^9.5.10",
"squizlabs/php_codesniffer": "^3.0",
"monolog/monolog": "^1.0",
"codeclimate/php-test-reporter": "dev-master",
"vectorface/cache": "^0.2.0"
"monolog/monolog": "^1.0"
},
"scripts": {
"test": [
"@test-unit"
],
"test-unit": "phpunit --color=always"
}
}
20 changes: 12 additions & 8 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="tests/bootstrap.php">
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="tests/bootstrap.php">
<coverage/>
<testsuites>
<testsuite name="Vectorface Auth Test Suite">
<directory>tests</directory>
<testsuite name="Main suite">
<directory>tests/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>src</directory>
</whitelist>
</filter>
<php>
<ini name="register_argc_argv" value="On"/>
</php>
</phpunit>
10 changes: 8 additions & 2 deletions src/Auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Vectorface\Auth;

use ArrayAccess;
use Psr\Log\LoggerAwareTrait;
use Psr\Log\LoggerInterface;
use Vectorface\Auth\Plugin\AuthPluginInterface;
Expand All @@ -14,7 +15,7 @@
*
* Plugin classes can share data using the Auth class itself as a shared source of data.
*/
class Auth implements \ArrayAccess
class Auth implements ArrayAccess
{
/**
* Provides setLogger method, and protected logger property.
Expand Down Expand Up @@ -211,7 +212,8 @@ public function __call($method, $args = [])
} catch (AuthException $e) {
throw $e;
} catch (Exception $e) {
return $this->logException($e, "Exception caught calling %s->%s", get_class($plugin), $method);
$this->logException($e, "Exception caught calling %s->%s", get_class($plugin), $method);
return null;
}
}
}
Expand All @@ -228,6 +230,7 @@ public function __call($method, $args = [])
* @link http://php.net/manual/en/arrayaccess.offsetexists.php
* @inheritDoc
*/
#[\ReturnTypeWillChange]
public function offsetExists($offset)
{
return isset($this->shared[$offset]);
Expand All @@ -239,6 +242,7 @@ public function offsetExists($offset)
* @link http://php.net/manual/en/arrayaccess.offsetget.php
* @inheritDoc
*/
#[\ReturnTypeWillChange]
public function offsetGet($offset)
{
return $this->shared[$offset] ?? null;
Expand All @@ -250,6 +254,7 @@ public function offsetGet($offset)
* @link http://php.net/manual/en/arrayaccess.offsetset.php
* @inheritDoc
*/
#[\ReturnTypeWillChange]
public function offsetSet($offset, $value)
{
$this->shared[$offset] = $value;
Expand All @@ -261,6 +266,7 @@ public function offsetSet($offset, $value)
* @link http://php.net/manual/en/arrayaccess.offsetunset.php
* @inheritDoc
*/
#[\ReturnTypeWillChange]
public function offsetUnset($offset)
{
unset($this->shared[$offset]);
Expand Down
2 changes: 1 addition & 1 deletion tests/AuthTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class AuthTest extends TestCase
*/
private $auth;

protected function setUp()
protected function setUp() : void
{
$logger = new Logger('auth');
$logger->pushHandler(new NullHandler());
Expand Down
2 changes: 1 addition & 1 deletion tests/CookieLoginLimitPluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class CookieLoginLimitPluginTest extends LoginLimitPluginTest
{
public static function setUpBeforeClass()
public static function setUpBeforeClass() : void
{
// Define a functions to override headers_sent and setcookie with empty stubs.
eval('namespace Vectorface\Auth\Plugin\Limit { function headers_sent() {} function setcookie() {} }');
Expand Down
10 changes: 10 additions & 0 deletions tests/Helpers/FakeMemcache.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
/** @noinspection PhpComposerExtensionStubsInspection */

namespace Vectorface\Tests\Auth\Helpers;

if (version_compare(phpversion(), '8.0.0', '>=') && class_exists("MemcachePool")) {
class FakeMemcache extends FakeMemcachePHP80 {}
} else {
class FakeMemcache extends FakeMemcachePHP73 {}
}
Loading

0 comments on commit e1e5c3a

Please sign in to comment.