diff --git a/.editorconfig b/.editorconfig
index dcd93a5..5d10651 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -12,3 +12,6 @@ trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false
+
+[*.yml]
+indent_size = 2
diff --git a/.gitattributes b/.gitattributes
index f40a03c..377c6db 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -7,4 +7,4 @@
/.scrutinizer.yml export-ignore
/phpcs.xml export-ignore
/phpunit.xml.dist export-ignore
-/psalm.xml export-ignore
+/psalm.xml.dist export-ignore
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index ef7a154..7fa0ea1 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -1,15 +1,31 @@
on:
- - pull_request
- - push
+ pull_request:
+ paths-ignore:
+ - 'docs/**'
+ - 'README.md'
+ - 'CHANGELOG.md'
+ - '.gitignore'
+ - '.gitattributes'
+ - 'psalm.xml.dist'
+
+ push:
+ paths-ignore:
+ - 'docs/**'
+ - 'README.md'
+ - 'CHANGELOG.md'
+ - '.gitignore'
+ - '.gitattributes'
+ - 'psalm.xml.dist'
name: build
jobs:
tests:
- name: PHP ${{ matrix.php-version }}-${{ matrix.os }}
+ name: PHP ${{ matrix.php }}-${{ matrix.os }}
+
runs-on: ${{ matrix.os }}
+
env:
- extensions: curl, mbstring, dom
key: cache-v1
strategy:
@@ -18,64 +34,45 @@ jobs:
- ubuntu-latest
- windows-latest
- php-version:
+ php:
- "7.4"
- "8.0"
+ - "8.1"
+ - "8.2"
steps:
- - name: Checkout
- uses: actions/checkout@v2.3.4
+ - name: Checkout.
+ uses: actions/checkout@v3
- - name: Install PHP
+ - name: Install PHP with extensions.
uses: shivammathur/setup-php@v2
with:
- php-version: ${{ matrix.php-version }}
- extensions: ${{ env.extensions }}
+ php-version: ${{ matrix.php }}
ini-values: date.timezone='UTC'
tools: composer:v2
coverage: pcov
- - name: Determine composer cache directory on Linux
+ - name: Determine composer cache directory on Linux.
if: matrix.os == 'ubuntu-latest'
run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV
- - name: Determine composer cache directory on Windows
+ - name: Determine composer cache directory on Windows.
if: matrix.os == 'windows-latest'
run: echo "COMPOSER_CACHE_DIR=~\AppData\Local\Composer" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- - name: Cache dependencies installed with composer
- uses: actions/cache@v1
+ - name: Cache dependencies installed with composer.
+ uses: actions/cache@v3
with:
path: ${{ env.COMPOSER_CACHE_DIR }}
- key: php${{ matrix.php-version }}-composer-${{ hashFiles('**/composer.json') }}
+ key: php${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: |
- php${{ matrix.php-version }}-composer-
+ php${{ matrix.php }}-composer-
- - name: Update composer
+ - name: Update composer.
run: composer self-update
- - name: Install dependencies with composer php 7.4
- if: matrix.php-version == '7.4'
- run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader
-
- - name: Install dependencies with composer php 8.0
- if: matrix.php-version == '8.0'
- run: composer update --ignore-platform-reqs --prefer-dist --no-interaction --no-progress --optimize-autoloader
-
- - name: PHPUnit run with coverage on Linux PHP 7.4
- if: matrix.os == 'ubuntu-latest' && matrix.php-version == '7.4'
- run: vendor/bin/phpunit --coverage-clover=coverage.clover
-
- - name: PHPUnit run without coverage on Linux PHP 8.0
- if: matrix.os == 'ubuntu-latest' && matrix.php-version == '8.0'
- run: vendor/bin/phpunit
-
- - name: PHPUnit run without coverage on Windows
- if: matrix.os == 'windows-latest'
- run: vendor/bin/phpunit
+ - name: Install dependencies with composer.
+ run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
- - name: Code coverage scrutinizer on Linux PHP 7.4
- if: matrix.os == 'ubuntu-latest' && matrix.php-version == '7.4'
- run: |
- wget https://scrutinizer-ci.com/ocular.phar
- php ocular.phar code-coverage:upload --format=php-clover coverage.clover
+ - name: Run tests with phpunit.
+ run: vendor/bin/phpunit --colors=always
diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml
index ce5d581..3e79b31 100644
--- a/.github/workflows/static.yml
+++ b/.github/workflows/static.yml
@@ -1,12 +1,27 @@
on:
- - pull_request
- - push
+ pull_request:
+ paths-ignore:
+ - 'docs/**'
+ - 'README.md'
+ - 'CHANGELOG.md'
+ - '.gitignore'
+ - '.gitattributes'
+ - 'phpunit.xml.dist'
+
+ push:
+ paths-ignore:
+ - 'docs/**'
+ - 'README.md'
+ - 'CHANGELOG.md'
+ - '.gitignore'
+ - '.gitattributes'
+ - 'phpunit.xml.dist'
name: static
jobs:
static:
- name: PHP ${{ matrix.php-version }}-${{ matrix.os }}
+ name: PHP ${{ matrix.php }}-${{ matrix.os }}
runs-on: ${{ matrix.os }}
@@ -15,39 +30,42 @@ jobs:
os:
- ubuntu-latest
- php-version:
+ php:
- "7.4"
+ - "8.0"
+ - "8.1"
+ - "8.2"
steps:
- - name: Checkout
- uses: actions/checkout@v2.3.4
+ - name: Checkout.
+ uses: actions/checkout@v3
- - name: Install PHP
+ - name: Install PHP with extensions.
uses: shivammathur/setup-php@v2
with:
- php-version: ${{ matrix.php-version }}
+ php-version: ${{ matrix.php }}
ini-values: memory_limit=-1
tools: composer:v2
- - name: Determine composer cache directory
+ - name: Determine composer cache directory.
run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV
- - name: Cache dependencies installed with composer
- uses: actions/cache@v2
+ - name: Cache dependencies installed with composer.
+ uses: actions/cache@v3
with:
path: ${{ env.COMPOSER_CACHE_DIR }}
- key: php${{ matrix.php-version }}-composer-${{ hashFiles('**/composer.json') }}
+ key: php${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: |
- php${{ matrix.php-version }}-composer-
+ php${{ matrix.php }}-composer-
- - name: Update composer
+ - name: Update composer.
run: composer self-update
- - name: Install dependencies with composer
- run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader
+ - name: Install dependencies with composer.
+ run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
- - name: PHPCS check
+ - name: PHPCS check.
run: vendor/bin/phpcs
- - name: Psalm static analysis
+ - name: Psalm static analysis.
run: vendor/bin/psalm --no-progress
diff --git a/.gitignore b/.gitignore
index e1c36a4..e78652c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,5 @@
+.phpunit.result.cache
composer.lock
phpunit.xml
-vendor
\ No newline at end of file
+psalm.xml
+vendor
diff --git a/.scrutinizer.yml b/.scrutinizer.yml
index c7b177a..eca0599 100644
--- a/.scrutinizer.yml
+++ b/.scrutinizer.yml
@@ -1,18 +1,33 @@
-build:
- environment:
- php: "7.4"
- nodes:
- analysis:
- tests:
- override:
- - php-scrutinizer-run
-filter:
- paths:
- - "src/*"
checks:
- php: true
-tools:
- php_code_coverage:
- enabled: true
- external_code_coverage:
- timeout: 600
+ php: true
+
+filter:
+ paths:
+ - "src/*"
+
+build:
+ nodes:
+ analysis:
+ environment:
+ php: 7.4.12
+
+ tests:
+ override:
+ - php-scrutinizer-run
+
+ tests-and-coverage:
+ environment:
+ php: 7.4.12
+
+ dependencies:
+ override:
+ - composer self-update
+ - composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
+
+ tests:
+ override:
+ - command: "./vendor/bin/phpunit --coverage-clover ./coverage.xml"
+ on_node: 1
+ coverage:
+ file: coverage.xml
+ format: php-clover
diff --git a/composer.json b/composer.json
index ce3a47a..09ab645 100644
--- a/composer.json
+++ b/composer.json
@@ -23,7 +23,7 @@
"require-dev": {
"phpunit/phpunit": "^9.5",
"squizlabs/php_codesniffer": "^3.7",
- "vimeo/psalm": "^5.3"
+ "vimeo/psalm": "^4.9|^5.2"
},
"provide": {
"psr/container-implementation": "1.0"
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index 213da8f..6a7e54a 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -1,16 +1,17 @@
@@ -24,9 +25,9 @@
-
-
- ./src/
-
-
+
+
+ ./src
+
+
diff --git a/psalm.xml b/psalm.xml.dist
similarity index 71%
rename from psalm.xml
rename to psalm.xml.dist
index 75bbb1e..4dead6a 100644
--- a/psalm.xml
+++ b/psalm.xml.dist
@@ -1,15 +1,15 @@
-
+
-
+
diff --git a/src/Container.php b/src/Container.php
index fac459a..b55846b 100644
--- a/src/Container.php
+++ b/src/Container.php
@@ -191,6 +191,7 @@ private function createObject(string $className): object
foreach ($constructor->getParameters() as $parameter) {
if ($type = $parameter->getType()) {
+ /** @var string $typeName */
$typeName = $type->getName();
if (!$type->isBuiltin() && ($this->has($typeName) || $this->isClassName($typeName))) {
@@ -198,7 +199,7 @@ private function createObject(string $className): object
continue;
}
- if ($type->isBuiltin() && $typeName === 'array' && !$parameter->isDefaultValueAvailable()) {
+ if ($typeName === 'array' && $type->isBuiltin() && !$parameter->isDefaultValueAvailable()) {
$arguments[] = [];
continue;
}