Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 104 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: Continuous Integration

on:
- push
- pull_request

jobs:
tests:
strategy:
matrix:
include:
- operating-system: 'ubuntu-latest'
php-version: '7.1'
composer-require-checker-version: '2.1.0'

- operating-system: 'ubuntu-latest'
php-version: '7.2'
composer-require-checker-version: '2.1.0'

- operating-system: 'ubuntu-latest'
php-version: '7.3'
composer-require-checker-version: '2.1.0'

- operating-system: 'ubuntu-latest'
php-version: '7.4'
composer-require-checker-version: '3.6.0'

- operating-system: 'ubuntu-latest'
php-version: '8.0'
composer-require-checker-version: '3.6.0'

- operating-system: 'ubuntu-latest'
php-version: '8.1'
composer-require-checker-version: '3.6.0'

- operating-system: 'ubuntu-latest'
php-version: '8.2'
composer-require-checker-version: '3.6.0'

- operating-system: 'ubuntu-latest'
php-version: '8.3'
composer-require-checker-version: '3.6.0'

- operating-system: 'ubuntu-latest'
php-version: '8.4'
composer-require-checker-version: '3.6.0'

name: PHP ${{ matrix.php-version }} ${{ matrix.job-description }}

runs-on: ${{ matrix.operating-system }}

steps:
- name: Set git to use LF
run: |
git config --global core.autocrlf false
git config --global core.eol lf

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

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}

- name: Get Composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-dir)" >> $GITHUB_OUTPUT
shell: bash

- name: Cache dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('**/composer.*') }}-${{ matrix.composer-flags }}
restore-keys: |
${{ runner.os }}-composer-

- name: Install dependencies
uses: nick-invision/retry@v2
with:
timeout_minutes: 5
max_attempts: 5
retry_wait_seconds: 30
command: |
composer update --optimize-autoloader --no-interaction --no-progress ${{ matrix.composer-flags }}
composer info -D

- name: Run tests
run: vendor/bin/phpunit ${{ matrix.phpunit-flags }}

- name: Run style fixer
env:
PHP_CS_FIXER_IGNORE_ENV: 1
run: vendor/bin/php-cs-fixer --diff --dry-run -v fix
if: runner.os != 'Windows'

- name: Install composer-require-checker
run: php -r 'file_put_contents("composer-require-checker.phar", file_get_contents("https://github.com/maglnet/ComposerRequireChecker/releases/download/{{ matrix.composer-require-checker-version }}/composer-require-checker.phar"));'
if: runner.os != 'Windows' && matrix.composer-require-checker-version != 'none'

- name: Run composer-require-checker
run: php composer-require-checker.phar check composer.json --config-file $PWD/composer-require-check.json
if: runner.os != 'Windows' && matrix.composer-require-checker-version != 'none'
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
vendor/
composer.lock
.idea
.phpunit.result.cache
8 changes: 8 additions & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

return (new \PhpCsFixer\Config())
->setFinder(
(new \PhpCsFixer\Finder())
->in(__DIR__ . "/lib")
->in(__DIR__ . "/test")
);
15 changes: 0 additions & 15 deletions .php_cs

This file was deleted.

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

This file was deleted.

12 changes: 12 additions & 0 deletions composer-require-check.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"symbol-whitelist" : [
"apc_fetch",
"apc_store",
"array",
"false",
"null",
"parent",
"self",
"true"
]
}
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
}
],
"require": {
"php": ">=5.3.0"
"php": ">=7.1"
},
"require-dev": {
"phpunit/phpunit": "^4.8",
"fabpot/php-cs-fixer": "~1.9",
"phpunit/phpunit": "^7 || ^8",
"friendsofphp/php-cs-fixer": "^2",
"athletic/athletic": "~0.1"
},
"autoload": {
Expand All @@ -39,7 +39,7 @@
},
"autoload-dev": {
"psr-4": {
"Auryn\\Test\\": "test/"
"Auryn\\": "test/"
},
"files": ["test/fixtures.php"]
}
Expand Down
16 changes: 8 additions & 8 deletions lib/CachingReflector.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@

class CachingReflector implements Reflector
{
const CACHE_KEY_CLASSES = 'auryn.refls.classes.';
const CACHE_KEY_CTORS = 'auryn.refls.ctors.';
const CACHE_KEY_CTOR_PARAMS = 'auryn.refls.ctor-params.';
const CACHE_KEY_FUNCS = 'auryn.refls.funcs.';
const CACHE_KEY_METHODS = 'auryn.refls.methods.';
public const CACHE_KEY_CLASSES = 'auryn.refls.classes.';
public const CACHE_KEY_CTORS = 'auryn.refls.ctors.';
public const CACHE_KEY_CTOR_PARAMS = 'auryn.refls.ctor-params.';
public const CACHE_KEY_FUNCS = 'auryn.refls.funcs.';
public const CACHE_KEY_METHODS = 'auryn.refls.methods.';

private $reflector;
private $cache;

public function __construct(Reflector $reflector = null, ReflectionCache $cache = null)
public function __construct(?Reflector $reflector = null, ?ReflectionCache $cache = null)
{
$this->reflector = $reflector ?: new StandardReflector;
$this->cache = $cache ?: new ReflectionCacheArray;
$this->reflector = $reflector ?: new StandardReflector();
$this->cache = $cache ?: new ReflectionCacheArray();
}

public function getClass($class)
Expand Down
14 changes: 7 additions & 7 deletions lib/InjectionException.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
class InjectionException extends InjectorException
{
public $dependencyChain;
public function __construct(array $inProgressMakes, $message = "", $code = 0, \Exception $previous = null)

public function __construct(array $inProgressMakes, $message = "", $code = 0, ?\Exception $previous = null)
{
$this->dependencyChain = array_flip($inProgressMakes);
ksort($this->dependencyChain);

parent::__construct($message, $code, $previous);
}

Expand All @@ -20,18 +20,18 @@ public function __construct(array $inProgressMakes, $message = "", $code = 0, \E
public static function fromInvalidCallable(
array $inProgressMakes,
$callableOrMethodStr,
\Exception $previous = null
?\Exception $previous = null
) {
$callableString = null;

if (is_string($callableOrMethodStr)) {
$callableString .= $callableOrMethodStr;
} else if (is_array($callableOrMethodStr) &&
} elseif (is_array($callableOrMethodStr) &&
array_key_exists(0, $callableOrMethodStr) &&
array_key_exists(0, $callableOrMethodStr)) {
if (is_string($callableOrMethodStr[0]) && is_string($callableOrMethodStr[1])) {
$callableString .= $callableOrMethodStr[0].'::'.$callableOrMethodStr[1];
} else if (is_object($callableOrMethodStr[0]) && is_string($callableOrMethodStr[1])) {
} elseif (is_object($callableOrMethodStr[0]) && is_string($callableOrMethodStr[1])) {
$callableString .= sprintf(
"[object(%s), '%s']",
get_class($callableOrMethodStr[0]),
Expand All @@ -41,7 +41,7 @@ public static function fromInvalidCallable(
}

if ($callableString) {
// Prevent accidental usage of long strings from filling logs.
// Prevent accidental usage of long strings from filling logs.
$callableString = substr($callableString, 0, 250);
$message = sprintf(
"%s. Invalid callable was '%s'",
Expand Down
Loading