updated-packages
This commit is contained in:
@@ -15,6 +15,8 @@ use Symfony\Component\VarDumper\Cloner\Stub;
|
||||
|
||||
/**
|
||||
* @author Jan Schädlich <jan.schaedlich@sensiolabs.de>
|
||||
*
|
||||
* @final since Symfony 4.4
|
||||
*/
|
||||
class MemcachedCaster
|
||||
{
|
||||
@@ -23,22 +25,22 @@ class MemcachedCaster
|
||||
|
||||
public static function castMemcached(\Memcached $c, array $a, Stub $stub, $isNested)
|
||||
{
|
||||
$a += array(
|
||||
$a += [
|
||||
Caster::PREFIX_VIRTUAL.'servers' => $c->getServerList(),
|
||||
Caster::PREFIX_VIRTUAL.'options' => new EnumStub(
|
||||
self::getNonDefaultOptions($c)
|
||||
),
|
||||
);
|
||||
];
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
private static function getNonDefaultOptions(\Memcached $c)
|
||||
private static function getNonDefaultOptions(\Memcached $c): array
|
||||
{
|
||||
self::$defaultOptions = self::$defaultOptions ?? self::discoverDefaultOptions();
|
||||
self::$optionConstants = self::$optionConstants ?? self::getOptionConstants();
|
||||
|
||||
$nonDefaultOptions = array();
|
||||
$nonDefaultOptions = [];
|
||||
foreach (self::$optionConstants as $constantKey => $value) {
|
||||
if (self::$defaultOptions[$constantKey] !== $option = $c->getOption($value)) {
|
||||
$nonDefaultOptions[$constantKey] = $option;
|
||||
@@ -48,12 +50,12 @@ class MemcachedCaster
|
||||
return $nonDefaultOptions;
|
||||
}
|
||||
|
||||
private static function discoverDefaultOptions()
|
||||
private static function discoverDefaultOptions(): array
|
||||
{
|
||||
$defaultMemcached = new \Memcached();
|
||||
$defaultMemcached->addServer('127.0.0.1', 11211);
|
||||
|
||||
$defaultOptions = array();
|
||||
$defaultOptions = [];
|
||||
self::$optionConstants = self::$optionConstants ?? self::getOptionConstants();
|
||||
|
||||
foreach (self::$optionConstants as $constantKey => $value) {
|
||||
@@ -63,13 +65,13 @@ class MemcachedCaster
|
||||
return $defaultOptions;
|
||||
}
|
||||
|
||||
private static function getOptionConstants()
|
||||
private static function getOptionConstants(): array
|
||||
{
|
||||
$reflectedMemcached = new \ReflectionClass(\Memcached::class);
|
||||
|
||||
$optionConstants = array();
|
||||
$optionConstants = [];
|
||||
foreach ($reflectedMemcached->getConstants() as $constantKey => $value) {
|
||||
if (0 === strpos($constantKey, 'OPT_')) {
|
||||
if (str_starts_with($constantKey, 'OPT_')) {
|
||||
$optionConstants[$constantKey] = $value;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user