Skip to content

Commit

Permalink
Drop support php 7, add php 8.2 support
Browse files Browse the repository at this point in the history
Signed-off-by: Stéphane Demonchaux <[email protected]>
  • Loading branch information
fezfez committed Oct 16, 2022
1 parent fd01b73 commit 1109c6b
Show file tree
Hide file tree
Showing 60 changed files with 1,025 additions and 1,135 deletions.
17 changes: 10 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,23 @@
"forum": "https://discourse.laminas.dev"
},
"config": {
"sort-packages": true
"sort-packages": true,
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
},
"require": {
"php": "^7.3 || ~8.0.0 || ~8.1.0",
"php": "~8.0.0 || ~8.1.0 || ~8.2.0",
"ext-json": "*",
"laminas/laminas-stdlib": "^3.6",
"psr/container": "^1.0"
},
"require-dev": {
"laminas/laminas-coding-standard": "~1.0.0",
"laminas/laminas-filter": "^2.7.2",
"laminas/laminas-i18n": "^2.10.3",
"laminas/laminas-servicemanager": "^3.7",
"phpunit/phpunit": "^9.5.5"
"laminas/laminas-coding-standard": "~2.4.0",
"laminas/laminas-filter": "~2.23.0",
"laminas/laminas-i18n": "~2.19.0",
"laminas/laminas-servicemanager": "~3.19.0",
"phpunit/phpunit": "~9.5.25"
},
"conflict": {
"container-interop/container-interop": "<1.2.0",
Expand Down
1,008 changes: 384 additions & 624 deletions composer.lock

Large diffs are not rendered by default.

24 changes: 22 additions & 2 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,29 @@
<?xml version="1.0"?>
<ruleset name="Laminas coding standard">
<rule ref="./vendor/laminas/laminas-coding-standard/ruleset.xml"/>
<ruleset
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="./vendor/squizlabs/php_codesniffer/phpcs.xsd">

<arg name="basepath" value="."/>
<arg name="cache" value=".phpcs-cache"/>
<arg name="colors"/>
<arg name="extensions" value="php"/>
<arg name="parallel" value="80"/>

<!-- Show progress -->
<arg value="p"/>

<!-- Paths to check -->
<file>src</file>
<file>test</file>

<!-- Include all rules from Laminas Coding Standard -->
<rule ref="LaminasCodingStandard"/>
<exclude-pattern>*/_files/*</exclude-pattern>

<rule ref="SlevomatCodingStandard.TypeHints.DeclareStrictTypes.DeclareStrictTypesMissing">
<exclude-pattern>src/</exclude-pattern>
</rule>
<rule ref="WebimpressCodingStandard.PHP.CorrectClassNameCase.Invalid">
<exclude-pattern>src/AbstractConfigFactory.php</exclude-pattern>
</rule>
</ruleset>
38 changes: 13 additions & 25 deletions src/AbstractConfigFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

namespace Laminas\Config;

use Interop\Container\ContainerInterface;
use Interop\Container\Containerinterface;
use InvalidArgumentException;
use Laminas\ServiceManager\AbstractFactoryInterface;
use Laminas\ServiceManager\ServiceLocatorInterface;
use Traversable;
Expand All @@ -13,35 +14,25 @@
use function iterator_to_array;
use function preg_match;

/**
* Class AbstractConfigFactory
*/
class AbstractConfigFactory implements AbstractFactoryInterface
{
/**
* @var array
*/
/** @var array */
protected $configs = [];

/**
* @var string[]
*/
/** @var string[] */
protected $defaultPatterns = [
'#config[\._-](.*)$#i',
'#^(.*)[\\\\\._-]config$#i'
'#^(.*)[\\\\\._-]config$#i',
];

/**
* @var string[]
*/
/** @var string[] */
protected $patterns;

/**
* Determine if we can create a service with name (SM v2)
*
* @param ServiceLocatorInterface $serviceLocator
* @param $name
* @param $requestedName
* @param string $name
* @param string $requestedName
* @return bool
*/
public function canCreateServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
Expand All @@ -52,11 +43,10 @@ public function canCreateServiceWithName(ServiceLocatorInterface $serviceLocator
/**
* Determine if we can create a service (SM v3)
*
* @param ContainerInterface $container
* @param string $requestedName
* @return bool
*/
public function canCreate(ContainerInterface $container, $requestedName)
public function canCreate(Containerinterface $container, $requestedName)
{
if (isset($this->configs[$requestedName])) {
return true;
Expand All @@ -78,7 +68,6 @@ public function canCreate(ContainerInterface $container, $requestedName)
/**
* Create service with name (SM v2)
*
* @param ServiceLocatorInterface $serviceLocator
* @param string $name
* @param string $requestedName
* @return string|mixed|array
Expand All @@ -91,12 +80,11 @@ public function createServiceWithName(ServiceLocatorInterface $serviceLocator, $
/**
* Create service with name (SM v3)
*
* @param ContainerInterface $container
* @param string $requestedName
* @param array $options
* @return string|mixed|array
*/
public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
public function __invoke(Containerinterface $container, $requestedName, ?array $options = null)
{
if (isset($this->configs[$requestedName])) {
return $this->configs[$requestedName];
Expand All @@ -108,7 +96,7 @@ public function __invoke(ContainerInterface $container, $requestedName, array $o
return $this->configs[$key];
}

$config = $container->get('config');
$config = $container->get('config');
$this->configs[$requestedName] = $this->configs[$key] = $config[$key];
return $config[$key];
}
Expand Down Expand Up @@ -155,7 +143,7 @@ public function addPatterns($patterns)
/**
* @param array|Traversable $patterns
* @return self
* @throws \InvalidArgumentException
* @throws InvalidArgumentException
*/
public function setPatterns($patterns)
{
Expand All @@ -164,7 +152,7 @@ public function setPatterns($patterns)
}

if (! is_array($patterns)) {
throw new \InvalidArgumentException("patterns must be array or Traversable");
throw new InvalidArgumentException("patterns must be array or Traversable");
}

$this->patterns = $patterns;
Expand Down
15 changes: 11 additions & 4 deletions src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ class Config implements Countable, Iterator, ArrayAccess
protected $skipNextIteration;

/**
* Constructor.
*
* Data is read-only unless $allowModifications is set to true
* on construction.
*
Expand Down Expand Up @@ -201,6 +199,7 @@ public function __unset($name)
* count(): defined by Countable interface.
*
* @see Countable::count()
*
* @return int
*/
#[ReturnTypeWillChange]
Expand All @@ -213,6 +212,7 @@ public function count()
* current(): defined by Iterator interface.
*
* @see Iterator::current()
*
* @return mixed
*/
#[ReturnTypeWillChange]
Expand All @@ -226,6 +226,7 @@ public function current()
* key(): defined by Iterator interface.
*
* @see Iterator::key()
*
* @return mixed
*/
#[ReturnTypeWillChange]
Expand All @@ -238,6 +239,7 @@ public function key()
* next(): defined by Iterator interface.
*
* @see Iterator::next()
*
* @return void
*/
#[ReturnTypeWillChange]
Expand All @@ -255,6 +257,7 @@ public function next()
* rewind(): defined by Iterator interface.
*
* @see Iterator::rewind()
*
* @return void
*/
#[ReturnTypeWillChange]
Expand All @@ -268,18 +271,20 @@ public function rewind()
* valid(): defined by Iterator interface.
*
* @see Iterator::valid()
*
* @return bool
*/
#[ReturnTypeWillChange]
public function valid()
{
return ($this->key() !== null);
return $this->key() !== null;
}

/**
* offsetExists(): defined by ArrayAccess interface.
*
* @see ArrayAccess::offsetExists()
*
* @param mixed $offset
* @return bool
*/
Expand All @@ -293,6 +298,7 @@ public function offsetExists($offset)
* offsetGet(): defined by ArrayAccess interface.
*
* @see ArrayAccess::offsetGet()
*
* @param mixed $offset
* @return mixed
*/
Expand All @@ -306,6 +312,7 @@ public function offsetGet($offset)
* offsetSet(): defined by ArrayAccess interface.
*
* @see ArrayAccess::offsetSet()
*
* @param mixed $offset
* @param mixed $value
* @return void
Expand All @@ -320,6 +327,7 @@ public function offsetSet($offset, $value)
* offsetUnset(): defined by ArrayAccess interface.
*
* @see ArrayAccess::offsetUnset()
*
* @param mixed $offset
* @return void
*/
Expand All @@ -337,7 +345,6 @@ public function offsetUnset($offset)
* - Items in $merge with INTEGER keys will be appended.
* - Items in $merge with STRING keys will overwrite current values.
*
* @param Config $merge
* @return self
*/
public function merge(Config $merge)
Expand Down
Loading

0 comments on commit 1109c6b

Please sign in to comment.