diff --git a/Bridge/Laminas/Storage/TableGatewayStorage.php b/Bridge/Laminas/Storage/TableGatewayStorage.php index 215e420..5d070a7 100644 --- a/Bridge/Laminas/Storage/TableGatewayStorage.php +++ b/Bridge/Laminas/Storage/TableGatewayStorage.php @@ -67,10 +67,10 @@ public function __construct($tableGateway, $modelClass, $idField = 'id') if ($tableGateway instanceof LaminasTableGateway) { $this->tableGateway = $tableGateway; } else if ($tableGateway instanceof ZendTableGateway) { - @trigger_error(sprintf('Passing an instance of %s as the first argument to %s is deprecated and won\'t be supported in 2.0. Please using Laminas instead.', ZendTableGateway::class, __CLASS__)); + @trigger_error(sprintf('Passing an instance of %s as the first argument to %s is deprecated and won\'t be supported in 2.0. Please using Laminas instead.', ZendTableGateway::class, self::class)); $this->tableGateway = $tableGateway; } else { - throw new \InvalidArgumentException(sprintf('Argument $tableGateway of %s must be an instance of %s or %s, %s given.', __CLASS__, LaminasTableGateway::class, ZendTableGateway::class, (is_object($tableGateway) ? get_class($tableGateway) : gettype($tableGateway)))); + throw new \InvalidArgumentException(sprintf('Argument $tableGateway of %s must be an instance of %s or %s, %s given.', self::class, LaminasTableGateway::class, ZendTableGateway::class, (is_object($tableGateway) ? get_class($tableGateway) : gettype($tableGateway)))); } $this->idField = $idField; diff --git a/Bridge/PlainPhp/Action/GetHttpRequestAction.php b/Bridge/PlainPhp/Action/GetHttpRequestAction.php index 4930049..b31a251 100644 --- a/Bridge/PlainPhp/Action/GetHttpRequestAction.php +++ b/Bridge/PlainPhp/Action/GetHttpRequestAction.php @@ -16,12 +16,12 @@ public function execute($request) { RequestNotSupportedException::assertSupports($this, $request); - $request->method = isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : 'GET'; + $request->method = $_SERVER['REQUEST_METHOD'] ?? 'GET'; $request->query = $_GET; $request->request = $_REQUEST; - $request->clientIp = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : ''; - $request->uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : ''; - $request->userAgent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''; + $request->clientIp = $_SERVER['REMOTE_ADDR'] ?? ''; + $request->uri = $_SERVER['REQUEST_URI'] ?? ''; + $request->userAgent = $_SERVER['HTTP_USER_AGENT'] ?? ''; $request->content = file_get_contents('php://input'); } diff --git a/Bridge/Spl/ArrayObject.php b/Bridge/Spl/ArrayObject.php index 9df1093..43dd2cd 100644 --- a/Bridge/Spl/ArrayObject.php +++ b/Bridge/Spl/ArrayObject.php @@ -35,7 +35,7 @@ public function __construct($input = array(), $flags = 0, $iterator_class = "Arr */ public function get($key, $default = null) { - return isset($this[$key]) ? $this[$key] : $default; + return $this[$key] ?? $default; } /** @@ -58,7 +58,7 @@ public function getArray($key, $default = []) */ public function replace($input) { - if (false == (is_array($input) || $input instanceof \Traversable)) { + if (false == (is_iterable($input))) { throw new InvalidArgumentException('Invalid input given. Should be an array or instance of \Traversable'); } @@ -76,7 +76,7 @@ public function replace($input) */ public function defaults($input) { - if (false == (is_array($input) || $input instanceof \Traversable)) { + if (false == (is_iterable($input))) { throw new InvalidArgumentException('Invalid input given. Should be an array or instance of \Traversable'); } diff --git a/Bridge/Symfony/Validator/Constraints/CreditCardDate.php b/Bridge/Symfony/Validator/Constraints/CreditCardDate.php index 7d402a8..42952de 100644 --- a/Bridge/Symfony/Validator/Constraints/CreditCardDate.php +++ b/Bridge/Symfony/Validator/Constraints/CreditCardDate.php @@ -21,7 +21,7 @@ public function __construct($options = null) parent::__construct($options); if (null === $this->min) { - throw new MissingOptionsException('Either option "min" must be given for constraint ' . __CLASS__, array('min')); + throw new MissingOptionsException('Either option "min" must be given for constraint ' . self::class, array('min')); } if (null !== $this->min) { diff --git a/Model/Identity.php b/Model/Identity.php index d800b01..fa00657 100644 --- a/Model/Identity.php +++ b/Model/Identity.php @@ -54,7 +54,7 @@ public function serialize() */ public function unserialize($serialized) { - list($this->id, $this->class) = unserialize($serialized); + [$this->id, $this->class] = unserialize($serialized); } public function __serialize(): array @@ -64,7 +64,7 @@ public function __serialize(): array public function __unserialize(array $data) { - list($this->id, $this->class) = $data; + [$this->id, $this->class] = $data; } /** diff --git a/PayumBuilder.php b/PayumBuilder.php index 5d3c5fa..81764b4 100644 --- a/PayumBuilder.php +++ b/PayumBuilder.php @@ -161,7 +161,7 @@ public function addGateway($name, $gateway) if ($gateway instanceof GatewayInterface) { $this->gateways[$name] = $gateway; } elseif (is_array($gateway)) { - $currentConfig = isset($this->gatewayConfigs[$name]) ? $this->gatewayConfigs[$name] : []; + $currentConfig = $this->gatewayConfigs[$name] ?? []; $currentConfig = array_replace_recursive($currentConfig, $gateway); if (empty($currentConfig['factory'])) { throw new InvalidArgumentException('Gateway config must have factory set in it and it must not be empty.'); @@ -202,7 +202,7 @@ public function addGatewayFactory($name, $gatewayFactory) */ public function addGatewayFactoryConfig($name, array $config) { - $currentConfig = isset($this->gatewayFactoryConfigs[$name]) ? $this->gatewayFactoryConfigs[$name] : []; + $currentConfig = $this->gatewayFactoryConfigs[$name] ?? []; $this->gatewayFactoryConfigs[$name] = array_replace_recursive($currentConfig, $config); return $this; @@ -569,7 +569,7 @@ protected function buildGatewayFactories(GatewayFactoryInterface $coreGatewayFac foreach ($map as $name => $factoryClass) { if (class_exists($factoryClass)) { $gatewayFactories[$name] = new $factoryClass( - isset($this->gatewayFactoryConfigs[$name]) ? $this->gatewayFactoryConfigs[$name] : [], + $this->gatewayFactoryConfigs[$name] ?? [], $coreGatewayFactory ); } @@ -588,7 +588,7 @@ protected function buildAddedGatewayFactories(GatewayFactoryInterface $coreGatew $gatewayFactories = []; foreach ($this->gatewayFactories as $name => $factory) { if (is_callable($factory)) { - $config = isset($this->gatewayFactoryConfigs[$name]) ? $this->gatewayFactoryConfigs[$name] : []; + $config = $this->gatewayFactoryConfigs[$name] ?? []; $factory = call_user_func($factory, $config, $coreGatewayFactory); } diff --git a/Tests/Debug/HumanifyTest.php b/Tests/Debug/HumanifyTest.php index 0c137f4..8d3c246 100644 --- a/Tests/Debug/HumanifyTest.php +++ b/Tests/Debug/HumanifyTest.php @@ -49,7 +49,7 @@ public function shouldReturnObjectShortClassOnValueIfObjectPassedAndShortClassFl */ public function shouldReturnObjectClassOnValueIfObjectPassedAndShortClassFlagSetFalse() { - $this->assertEquals(__CLASS__, Humanify::value($this, false)); + $this->assertEquals(self::class, Humanify::value($this, false)); } /**