Fix and update Composer autoload

This commit is contained in:
Frédéric Guillot
2021-12-16 13:44:31 -08:00
committed by Frédéric Guillot
parent 3e139ab6f4
commit 4cfdb88813
78 changed files with 1854 additions and 1893 deletions

View File

@@ -0,0 +1,47 @@
name: "Tests"
on:
- pull_request
- push
jobs:
test:
name: PHP ${{ matrix.php }} - ${{ matrix.dependencies }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php:
- "7.2"
- "7.3"
- "7.4"
- "8.0"
- "8.1"
dependencies:
- "psr/container:^1.1"
- "psr/container:^2.0"
steps:
- name: Checkout Code
uses: actions/checkout@v2
- name: Setup PHP ${{ matrix.php }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
ini-values: display_errors=off, log_errors=on
extensions: :xdebug
env:
# https://github.com/shivammathur/setup-php/issues/407#issuecomment-773675741
fail-fast: true
- name: Validate composer.json
run: composer validate --strict --no-check-lock
- name: Install dependencies +${{ matrix.dependencies }}
run: |
composer require --no-update ${{ matrix.dependencies }}
composer update --prefer-dist --no-progress
- name: Run PHPUnit tests
run: vendor/bin/simple-phpunit --verbose

View File

@@ -1,3 +1,4 @@
phpunit.xml
.phpunit.result.cache
composer.lock
/vendor/

View File

@@ -1,18 +0,0 @@
language: php
env:
global:
- REPORT_EXIT_STATUS=1
php:
- 7.2
- 7.3
- 7.4
- nightly
before_script:
- composer self-update
- COMPOSER_ROOT_VERSION=dev-master composer install
script:
- ./vendor/bin/simple-phpunit

View File

@@ -1,3 +1,11 @@
* 3.4.0 (2021-03-06)
* Implement version 1.1 of PSR-11
* 3.3.1 (2020-11-24)
* Add support for PHP 8
* 3.3.0 (2020-03-03)
* Drop PHP extension

View File

@@ -5,7 +5,7 @@ Pimple
Pimple is now closed for changes. No new features will be added and no
cosmetic changes will be accepted either. The only accepted changes are
compatiblity with newer PHP versions and security issue fixes.
compatibility with newer PHP versions and security issue fixes.
.. caution::
@@ -308,7 +308,7 @@ when iterated over:
public function canAccess($resource)
{
foreach ($this->voters as $voter) {
if (true === $voter->canAccess($resource) {
if (true === $voter->canAccess($resource)) {
return true;
}
}

View File

@@ -13,17 +13,17 @@
],
"require": {
"php": ">=7.2.5",
"psr/container": "^1.0"
"psr/container": "^1.1 || ^2.0"
},
"require-dev": {
"symfony/phpunit-bridge": "^5.0"
"symfony/phpunit-bridge": "^5.4@dev"
},
"autoload": {
"psr-0": { "Pimple": "src/" }
},
"extra": {
"branch-alias": {
"dev-master": "3.3.x-dev"
"dev-master": "3.4.x-dev"
}
}
}

View File

@@ -74,8 +74,11 @@ class Container implements \ArrayAccess
* @param string $id The unique identifier for the parameter or object
* @param mixed $value The value of the parameter or a closure to define an object
*
* @return void
*
* @throws FrozenServiceException Prevent override of a frozen service
*/
#[\ReturnTypeWillChange]
public function offsetSet($id, $value)
{
if (isset($this->frozen[$id])) {
@@ -95,6 +98,7 @@ class Container implements \ArrayAccess
*
* @throws UnknownIdentifierException If the identifier is not defined
*/
#[\ReturnTypeWillChange]
public function offsetGet($id)
{
if (!isset($this->keys[$id])) {
@@ -130,6 +134,7 @@ class Container implements \ArrayAccess
*
* @return bool
*/
#[\ReturnTypeWillChange]
public function offsetExists($id)
{
return isset($this->keys[$id]);
@@ -139,7 +144,10 @@ class Container implements \ArrayAccess
* Unsets a parameter or an object.
*
* @param string $id The unique identifier for the parameter or object
*
* @return void
*/
#[\ReturnTypeWillChange]
public function offsetUnset($id)
{
if (isset($this->keys[$id])) {
@@ -280,8 +288,7 @@ class Container implements \ArrayAccess
/**
* Registers a service provider.
*
* @param ServiceProviderInterface $provider A ServiceProviderInterface instance
* @param array $values An array of values that customizes the provider
* @param array $values An array of values that customizes the provider
*
* @return static
*/

View File

@@ -43,12 +43,12 @@ final class Container implements ContainerInterface
$this->pimple = $pimple;
}
public function get($id)
public function get(string $id)
{
return $this->pimple[$id];
}
public function has($id)
public function has(string $id): bool
{
return isset($this->pimple[$id]);
}

View File

@@ -56,7 +56,7 @@ class ServiceLocator implements ContainerInterface
/**
* {@inheritdoc}
*/
public function get($id)
public function get(string $id)
{
if (!isset($this->aliases[$id])) {
throw new UnknownIdentifierException($id);
@@ -68,7 +68,7 @@ class ServiceLocator implements ContainerInterface
/**
* {@inheritdoc}
*/
public function has($id)
public function has(string $id): bool
{
return isset($this->aliases[$id]) && isset($this->container[$this->aliases[$id]]);
}

View File

@@ -42,26 +42,46 @@ final class ServiceIterator implements \Iterator
$this->ids = $ids;
}
/**
* @return void
*/
#[\ReturnTypeWillChange]
public function rewind()
{
\reset($this->ids);
}
/**
* @return mixed
*/
#[\ReturnTypeWillChange]
public function current()
{
return $this->container[\current($this->ids)];
}
/**
* @return mixed
*/
#[\ReturnTypeWillChange]
public function key()
{
return \current($this->ids);
}
/**
* @return void
*/
#[\ReturnTypeWillChange]
public function next()
{
\next($this->ids);
}
/**
* @return bool
*/
#[\ReturnTypeWillChange]
public function valid()
{
return null !== \key($this->ids);

View File

@@ -39,8 +39,6 @@ interface ServiceProviderInterface
*
* This method should only be used to configure services and parameters.
* It should not get services.
*
* @param Container $pimple A container instance
*/
public function register(Container $pimple);
}

View File

@@ -36,8 +36,6 @@ class PimpleServiceProvider implements ServiceProviderInterface
*
* This method should only be used to configure services and parameters.
* It should not get services.
*
* @param Container $pimple An Container instance
*/
public function register(Container $pimple)
{