Skip to content

Commit

Permalink
Merge pull request #238 from laminas/php8.2
Browse files Browse the repository at this point in the history
PHP 8.2 support, drop PHP 7.4 support
  • Loading branch information
Ocramius committed Nov 8, 2022
2 parents eb17d13 + f6e4cd9 commit 3c8cfd0
Show file tree
Hide file tree
Showing 18 changed files with 48 additions and 114 deletions.
2 changes: 1 addition & 1 deletion .laminas-ci.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"ignore_php_platform_requirements": {
"8.1": true
"8.2": true
},
"extensions": [
"apcu"
Expand Down
24 changes: 0 additions & 24 deletions .laminas-ci/install-apcu-extension-from-source.sh

This file was deleted.

14 changes: 14 additions & 0 deletions .laminas-ci/install-apcu-extension-via-pecl.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

PHP_VERSION="$1"

if ! [[ "${PHP_VERSION}" =~ 8\.2 ]]; then
echo "APCu is only installed from pecl for PHP 8.2, ${PHP_VERSION} detected."
exit 0;
fi

set +e

pecl install --configureoptions 'enable-apcu-debug="no"' apcu
echo "extension=apcu.so" > /etc/php/${PHP_VERSION}/mods-available/apcu.ini
phpenmod -v ${PHP} -s cli apcu
2 changes: 1 addition & 1 deletion .laminas-ci/pre-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ if [ ! -z "$GITHUB_BASE_REF" ] && [[ "$GITHUB_BASE_REF" =~ ^[0-9]+\.[0-9] ]]; th
echo "Exported COMPOSER_ROOT_VERISON as ${COMPOSER_ROOT_VERISON}"
fi

${WORKING_DIRECTORY}/.laminas-ci/install-apcu-extension-from-source.sh "${PHP_VERSION}" || exit 1
${WORKING_DIRECTORY}/.laminas-ci/install-apcu-extension-via-pecl.sh "${PHP_VERSION}" || exit 1
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"process-timeout": 600,
"sort-packages": true,
"platform": {
"php": "7.4.99"
"php": "8.0.99"
},
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
Expand All @@ -34,7 +34,7 @@
}
},
"require": {
"php": "~7.4.0 || ~8.0.0 || ~8.1.0",
"php": "~8.0.0 || ~8.1.0 || ~8.2.0",
"laminas/laminas-cache-storage-implementation": "1.0",
"laminas/laminas-eventmanager": "^3.4",
"laminas/laminas-servicemanager": "^3.11.1",
Expand Down
14 changes: 2 additions & 12 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="4.27.0@faf106e717c37b8c81721845dba9de3d8deed8ff">
<files psalm-version="4.29.0@7ec5ffbd5f68ae03782d7fd33fff0c45a69f95b3">
<file src="src/Command/DeprecatedStorageFactoryConfigurationCheckCommand.php">
<MixedArgument occurrences="2">
<code>$cacheConfiguration</code>
Expand Down Expand Up @@ -60,12 +60,6 @@
<code>$perm</code>
<code>$perm</code>
</MixedArgument>
<MixedInferredReturnType occurrences="1">
<code>string</code>
</MixedInferredReturnType>
<MixedReturnStatement occurrences="1">
<code>$_SERVER['REQUEST_URI']</code>
</MixedReturnStatement>
<PossiblyInvalidMethodCall occurrences="1">
<code>isFile</code>
</PossiblyInvalidMethodCall>
Expand Down Expand Up @@ -198,10 +192,9 @@
<code>is_object($ttl)</code>
<code>null === $ttl</code>
</DocblockTypeContradiction>
<MixedArgument occurrences="3">
<MixedArgument occurrences="2">
<code>$key</code>
<code>$key</code>
<code>$ttl</code>
</MixedArgument>
<MixedAssignment occurrences="6">
<code>$key</code>
Expand Down Expand Up @@ -722,9 +715,6 @@
<MixedMethodCall occurrences="1">
<code>setIndexFilename</code>
</MixedMethodCall>
<MixedPropertyTypeCoercion occurrences="1">
<code>$_SERVER</code>
</MixedPropertyTypeCoercion>
<PossiblyNullArrayAccess occurrences="3">
<code>$err['message']</code>
<code>$err['message']</code>
Expand Down
9 changes: 1 addition & 8 deletions src/Pattern/CallbackCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
use function sprintf;
use function strtolower;

use const PHP_MAJOR_VERSION;

class CallbackCache extends AbstractStorageCapablePattern
{
/**
Expand Down Expand Up @@ -50,12 +48,7 @@ public function call($callback, array $args = [])
$cacheOutput = $options->getCacheOutput();
if ($cacheOutput) {
ob_start();
/**
* TODO: remove when PHP 7.4 support is dropped
*
* @psalm-suppress PossiblyFalseArgument
*/
ob_implicit_flush(PHP_MAJOR_VERSION >= 8 ? false : 0);
ob_implicit_flush(false);
}

// TODO: do not cache on errors using [set|restore]_error_handler
Expand Down
8 changes: 1 addition & 7 deletions src/Pattern/CaptureCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

use const DIRECTORY_SEPARATOR;
use const LOCK_EX;
use const PHP_MAJOR_VERSION;

class CaptureCache extends AbstractPattern
{
Expand All @@ -49,12 +48,7 @@ public function start($pageId = null)
return false;
});

/**
* TODO: remove when PHP 7.4 support is dropped
*
* @psalm-suppress PossiblyFalseArgument
*/
ob_implicit_flush(PHP_MAJOR_VERSION >= 8 ? false : 0);
ob_implicit_flush(false);
}

/**
Expand Down
10 changes: 2 additions & 8 deletions src/Pattern/OutputCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
use function ob_implicit_flush;
use function ob_start;

use const PHP_MAJOR_VERSION;

class OutputCache extends AbstractStorageCapablePattern
{
/**
Expand Down Expand Up @@ -43,12 +41,8 @@ public function start($key)
}

ob_start();
/**
* TODO: remove when PHP 7.4 support is dropped
*
* @psalm-suppress PossiblyFalseArgument
*/
ob_implicit_flush(PHP_MAJOR_VERSION >= 8 ? false : 0);
ob_implicit_flush(false);

$this->keyStack[] = $key;
return false;
}
Expand Down
11 changes: 5 additions & 6 deletions src/Psr/CacheItemPool/CacheItemPoolDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
use function array_values;
use function assert;
use function current;
use function get_class;
use function gettype;
use function in_array;
use function is_array;
Expand Down Expand Up @@ -308,15 +307,15 @@ private function validateStorage(StorageInterface $storage)
'The storage adapter "%s" requires a serializer plugin; please see'
. ' https://docs.laminas.dev/laminas-cache/storage/plugin/#quick-start'
. ' for details on how to attach the plugin to your adapter.',
get_class($storage)
$storage::class
));
}

// all current adapters implement this
if (! $storage instanceof FlushableInterface) {
throw new CacheException(sprintf(
'Storage %s does not implement %s',
get_class($storage),
$storage::class,
FlushableInterface::class
));
}
Expand All @@ -326,21 +325,21 @@ private function validateStorage(StorageInterface $storage)
if (! ($capabilities->getStaticTtl() && $capabilities->getMinTtl())) {
throw new CacheException(sprintf(
'Storage %s does not support static TTL',
get_class($storage)
$storage::class
));
}

if ($capabilities->getUseRequestTime()) {
throw new CacheException(sprintf(
'The capability "use-request-time" of storage %s violates PSR-6',
get_class($storage)
$storage::class
));
}

if ($capabilities->getLockOnExpire()) {
throw new CacheException(sprintf(
'The capability "lock-on-expire" of storage %s violates PSR-6',
get_class($storage)
$storage::class
));
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/Psr/MaximumKeyLengthTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Laminas\Cache\Storage\Capabilities;
use Laminas\Cache\Storage\StorageInterface;

use function get_class;
use function min;
use function preg_match;
use function sprintf;
Expand Down Expand Up @@ -54,7 +53,7 @@ private function memoizeMaximumKeyLengthCapability(StorageInterface $storage, Ca
throw new SimpleCacheInvalidArgumentException(sprintf(
'The storage adapter "%s" does not fulfill the minimum requirements for PSR-6/PSR-16:'
. ' The maximum key length capability must allow at least 64 characters.',
get_class($storage)
$storage::class
));
}

Expand Down
9 changes: 4 additions & 5 deletions src/Psr/SimpleCache/SimpleCacheDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
use Traversable;

use function array_keys;
use function get_class;
use function gettype;
use function is_array;
use function is_int;
Expand Down Expand Up @@ -63,7 +62,7 @@ public function __construct(StorageInterface $storage)
'The storage adapter "%s" requires a serializer plugin; please see'
. ' https://docs.laminas.dev/laminas-cache/storage/plugin/#quick-start'
. ' for details on how to attach the plugin to your adapter.',
get_class($storage)
$storage::class
));
}

Expand Down Expand Up @@ -400,7 +399,7 @@ private function convertTtlToInteger($ttl)
// All others are invalid
throw new SimpleCacheInvalidArgumentException(sprintf(
'Invalid TTL "%s" provided; must be null, an integer, or a %s instance',
is_object($ttl) ? get_class($ttl) : var_export($ttl, true),
is_object($ttl) ? $ttl::class : var_export($ttl, true),
DateInterval::class
));
}
Expand All @@ -417,7 +416,7 @@ private function convertIterableKeysToList(iterable $keys): array
if (! is_string($key) && ! is_int($key)) {
throw new SimpleCacheInvalidArgumentException(sprintf(
'Invalid key detected of type "%s"; must be a scalar',
is_object($key) ? get_class($key) : gettype($key)
is_object($key) ? $key::class : gettype($key)
));
}

Expand All @@ -439,7 +438,7 @@ private function convertIterableToKeyValueMap(iterable $values): array
if (! is_string($key) && ! is_int($key)) {
throw new SimpleCacheInvalidArgumentException(sprintf(
'Invalid key detected of type "%s"; must be a scalar',
is_object($key) ? get_class($key) : gettype($key)
is_object($key) ? $key::class : gettype($key)
));
}

Expand Down
3 changes: 1 addition & 2 deletions src/Service/StorageAdapterFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
use Webmozart\Assert\Assert;

use function assert;
use function get_class;
use function is_string;
use function sprintf;

Expand Down Expand Up @@ -56,7 +55,7 @@ public function create(string $storage, array $options = [], array $plugins = []
if (! $adapter instanceof PluginAwareInterface) {
throw new Exception\RuntimeException(sprintf(
"The adapter '%s' doesn't implement '%s' and therefore can't handle plugins",
get_class($adapter),
$adapter::class,
PluginAwareInterface::class
));
}
Expand Down
3 changes: 1 addition & 2 deletions src/Storage/Adapter/AbstractAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
use function array_values;
use function array_walk;
use function func_num_args;
use function get_class;
use function preg_match;
use function sprintf;

Expand Down Expand Up @@ -274,7 +273,7 @@ public function addPlugin(Plugin\PluginInterface $plugin, $priority = 1)
if ($registry->contains($plugin)) {
throw new Exception\LogicException(sprintf(
'Plugin of type "%s" already registered',
get_class($plugin)
$plugin::class
));
}

Expand Down
3 changes: 1 addition & 2 deletions src/Storage/Plugin/PluginOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Laminas\Serializer\Serializer as SerializerFactory;
use Laminas\Stdlib\AbstractOptions;

use function get_class;
use function gettype;
use function is_callable;
use function is_object;
Expand Down Expand Up @@ -203,7 +202,7 @@ public function setSerializer($serializer)
'%s expects either a string serializer name or Laminas\Serializer\Adapter\AdapterInterface instance; '
. 'received "%s"',
__METHOD__,
is_object($serializer) ? get_class($serializer) : gettype($serializer)
is_object($serializer) ? $serializer::class : gettype($serializer)
));
}
$this->serializer = $serializer;
Expand Down
18 changes: 4 additions & 14 deletions test/Pattern/CallbackCacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
use function ob_implicit_flush;
use function ob_start;

use const PHP_MAJOR_VERSION;

/**
* @see \LaminasTest\Cache\Pattern\Foo::bar
*/
Expand Down Expand Up @@ -121,12 +119,8 @@ protected function executeCallbackAndMakeAssertions($callback, array $args): voi
$firstCounter = TestCallbackCache::$fooCounter + 1;

ob_start();
/**
* TODO: remove when PHP 7.4 support is dropped
*
* @psalm-suppress PossiblyFalseArgument
*/
ob_implicit_flush(PHP_MAJOR_VERSION >= 8 ? false : 0);
ob_implicit_flush(false);

$return = $this->pattern->call($callback, $args);
$data = ob_get_clean();

Expand All @@ -135,12 +129,8 @@ protected function executeCallbackAndMakeAssertions($callback, array $args): voi

// second call - cached
ob_start();
/**
* TODO: remove when PHP 7.4 support is dropped
*
* @psalm-suppress PossiblyFalseArgument
*/
ob_implicit_flush(PHP_MAJOR_VERSION >= 8 ? false : 0);
ob_implicit_flush(false);

$return = $this->pattern->call($callback, $args);
$data = ob_get_clean();

Expand Down

0 comments on commit 3c8cfd0

Please sign in to comment.