Skip to content

Commit 3dd1c05

Browse files
Merge branch '4.4' into 5.1
* 4.4: Changed private static array-properties to const
2 parents 193070b + a0ddfaf commit 3dd1c05

10 files changed

+47
-47
lines changed

Caster/AmqpCaster.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*/
2323
class AmqpCaster
2424
{
25-
private static $flags = [
25+
private const FLAGS = [
2626
\AMQP_DURABLE => 'AMQP_DURABLE',
2727
\AMQP_PASSIVE => 'AMQP_PASSIVE',
2828
\AMQP_EXCLUSIVE => 'AMQP_EXCLUSIVE',
@@ -39,7 +39,7 @@ class AmqpCaster
3939
\AMQP_REQUEUE => 'AMQP_REQUEUE',
4040
];
4141

42-
private static $exchangeTypes = [
42+
private const EXCHANGE_TYPES = [
4343
\AMQP_EX_TYPE_DIRECT => 'AMQP_EX_TYPE_DIRECT',
4444
\AMQP_EX_TYPE_FANOUT => 'AMQP_EX_TYPE_FANOUT',
4545
\AMQP_EX_TYPE_TOPIC => 'AMQP_EX_TYPE_TOPIC',
@@ -133,7 +133,7 @@ public static function castExchange(\AMQPExchange $c, array $a, Stub $stub, bool
133133
$prefix.'flags' => self::extractFlags($c->getFlags()),
134134
];
135135

136-
$type = isset(self::$exchangeTypes[$c->getType()]) ? new ConstStub(self::$exchangeTypes[$c->getType()], $c->getType()) : $c->getType();
136+
$type = isset(self::EXCHANGE_TYPES[$c->getType()]) ? new ConstStub(self::EXCHANGE_TYPES[$c->getType()], $c->getType()) : $c->getType();
137137

138138
// Recent version of the extension already expose private properties
139139
if (isset($a["\x00AMQPExchange\x00name"])) {
@@ -197,7 +197,7 @@ private static function extractFlags(int $flags): ConstStub
197197
{
198198
$flagsArray = [];
199199

200-
foreach (self::$flags as $value => $name) {
200+
foreach (self::FLAGS as $value => $name) {
201201
if ($flags & $value) {
202202
$flagsArray[] = $name;
203203
}

Caster/DOMCaster.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*/
2323
class DOMCaster
2424
{
25-
private static $errorCodes = [
25+
private const ERROR_CODES = [
2626
\DOM_PHP_ERR => 'DOM_PHP_ERR',
2727
\DOM_INDEX_SIZE_ERR => 'DOM_INDEX_SIZE_ERR',
2828
\DOMSTRING_SIZE_ERR => 'DOMSTRING_SIZE_ERR',
@@ -42,7 +42,7 @@ class DOMCaster
4242
\DOM_VALIDATION_ERR => 'DOM_VALIDATION_ERR',
4343
];
4444

45-
private static $nodeTypes = [
45+
private const NODE_TYPES = [
4646
\XML_ELEMENT_NODE => 'XML_ELEMENT_NODE',
4747
\XML_ATTRIBUTE_NODE => 'XML_ATTRIBUTE_NODE',
4848
\XML_TEXT_NODE => 'XML_TEXT_NODE',
@@ -66,8 +66,8 @@ class DOMCaster
6666
public static function castException(\DOMException $e, array $a, Stub $stub, bool $isNested)
6767
{
6868
$k = Caster::PREFIX_PROTECTED.'code';
69-
if (isset($a[$k], self::$errorCodes[$a[$k]])) {
70-
$a[$k] = new ConstStub(self::$errorCodes[$a[$k]], $a[$k]);
69+
if (isset($a[$k], self::ERROR_CODES[$a[$k]])) {
70+
$a[$k] = new ConstStub(self::ERROR_CODES[$a[$k]], $a[$k]);
7171
}
7272

7373
return $a;
@@ -97,7 +97,7 @@ public static function castNode(\DOMNode $dom, array $a, Stub $stub, bool $isNes
9797
$a += [
9898
'nodeName' => $dom->nodeName,
9999
'nodeValue' => new CutStub($dom->nodeValue),
100-
'nodeType' => new ConstStub(self::$nodeTypes[$dom->nodeType], $dom->nodeType),
100+
'nodeType' => new ConstStub(self::NODE_TYPES[$dom->nodeType], $dom->nodeType),
101101
'parentNode' => new CutStub($dom->parentNode),
102102
'childNodes' => $dom->childNodes,
103103
'firstChild' => new CutStub($dom->firstChild),
@@ -121,7 +121,7 @@ public static function castNameSpaceNode(\DOMNameSpaceNode $dom, array $a, Stub
121121
$a += [
122122
'nodeName' => $dom->nodeName,
123123
'nodeValue' => new CutStub($dom->nodeValue),
124-
'nodeType' => new ConstStub(self::$nodeTypes[$dom->nodeType], $dom->nodeType),
124+
'nodeType' => new ConstStub(self::NODE_TYPES[$dom->nodeType], $dom->nodeType),
125125
'prefix' => $dom->prefix,
126126
'localName' => $dom->localName,
127127
'namespaceURI' => $dom->namespaceURI,

Caster/PdoCaster.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*/
2323
class PdoCaster
2424
{
25-
private static $pdoAttributes = [
25+
private const PDO_ATTRIBUTES = [
2626
'CASE' => [
2727
\PDO::CASE_LOWER => 'LOWER',
2828
\PDO::CASE_NATURAL => 'NATURAL',
@@ -65,7 +65,7 @@ public static function castPdo(\PDO $c, array $a, Stub $stub, bool $isNested)
6565
$errmode = $c->getAttribute(\PDO::ATTR_ERRMODE);
6666
$c->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
6767

68-
foreach (self::$pdoAttributes as $k => $v) {
68+
foreach (self::PDO_ATTRIBUTES as $k => $v) {
6969
if (!isset($k[0])) {
7070
$k = $v;
7171
$v = [];

Caster/PgSqlCaster.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*/
2323
class PgSqlCaster
2424
{
25-
private static $paramCodes = [
25+
private const PARAM_CODES = [
2626
'server_encoding',
2727
'client_encoding',
2828
'is_superuser',
@@ -35,15 +35,15 @@ class PgSqlCaster
3535
'standard_conforming_strings',
3636
];
3737

38-
private static $transactionStatus = [
38+
private const TRANSACTION_STATUS = [
3939
\PGSQL_TRANSACTION_IDLE => 'PGSQL_TRANSACTION_IDLE',
4040
\PGSQL_TRANSACTION_ACTIVE => 'PGSQL_TRANSACTION_ACTIVE',
4141
\PGSQL_TRANSACTION_INTRANS => 'PGSQL_TRANSACTION_INTRANS',
4242
\PGSQL_TRANSACTION_INERROR => 'PGSQL_TRANSACTION_INERROR',
4343
\PGSQL_TRANSACTION_UNKNOWN => 'PGSQL_TRANSACTION_UNKNOWN',
4444
];
4545

46-
private static $resultStatus = [
46+
private const RESULT_STATUS = [
4747
\PGSQL_EMPTY_QUERY => 'PGSQL_EMPTY_QUERY',
4848
\PGSQL_COMMAND_OK => 'PGSQL_COMMAND_OK',
4949
\PGSQL_TUPLES_OK => 'PGSQL_TUPLES_OK',
@@ -54,7 +54,7 @@ class PgSqlCaster
5454
\PGSQL_FATAL_ERROR => 'PGSQL_FATAL_ERROR',
5555
];
5656

57-
private static $diagCodes = [
57+
private const DIAG_CODES = [
5858
'severity' => \PGSQL_DIAG_SEVERITY,
5959
'sqlstate' => \PGSQL_DIAG_SQLSTATE,
6060
'message' => \PGSQL_DIAG_MESSAGE_PRIMARY,
@@ -83,8 +83,8 @@ public static function castLink($link, array $a, Stub $stub, bool $isNested)
8383
$a['busy'] = pg_connection_busy($link);
8484

8585
$a['transaction'] = pg_transaction_status($link);
86-
if (isset(self::$transactionStatus[$a['transaction']])) {
87-
$a['transaction'] = new ConstStub(self::$transactionStatus[$a['transaction']], $a['transaction']);
86+
if (isset(self::TRANSACTION_STATUS[$a['transaction']])) {
87+
$a['transaction'] = new ConstStub(self::TRANSACTION_STATUS[$a['transaction']], $a['transaction']);
8888
}
8989

9090
$a['pid'] = pg_get_pid($link);
@@ -96,7 +96,7 @@ public static function castLink($link, array $a, Stub $stub, bool $isNested)
9696
$a['options'] = pg_options($link);
9797
$a['version'] = pg_version($link);
9898

99-
foreach (self::$paramCodes as $v) {
99+
foreach (self::PARAM_CODES as $v) {
100100
if (false !== $s = pg_parameter_status($link, $v)) {
101101
$a['param'][$v] = $s;
102102
}
@@ -112,13 +112,13 @@ public static function castResult($result, array $a, Stub $stub, bool $isNested)
112112
{
113113
$a['num rows'] = pg_num_rows($result);
114114
$a['status'] = pg_result_status($result);
115-
if (isset(self::$resultStatus[$a['status']])) {
116-
$a['status'] = new ConstStub(self::$resultStatus[$a['status']], $a['status']);
115+
if (isset(self::RESULT_STATUS[$a['status']])) {
116+
$a['status'] = new ConstStub(self::RESULT_STATUS[$a['status']], $a['status']);
117117
}
118118
$a['command-completion tag'] = pg_result_status($result, \PGSQL_STATUS_STRING);
119119

120120
if (-1 === $a['num rows']) {
121-
foreach (self::$diagCodes as $k => $v) {
121+
foreach (self::DIAG_CODES as $k => $v) {
122122
$a['error'][$k] = pg_result_error_field($result, $v);
123123
}
124124
}

Caster/RedisCaster.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,24 @@
2222
*/
2323
class RedisCaster
2424
{
25-
private static $serializer = [
25+
private const SERIALIZERS = [
2626
\Redis::SERIALIZER_NONE => 'NONE',
2727
\Redis::SERIALIZER_PHP => 'PHP',
2828
2 => 'IGBINARY', // Optional Redis::SERIALIZER_IGBINARY
2929
];
3030

31-
private static $mode = [
31+
private const MODES = [
3232
\Redis::ATOMIC => 'ATOMIC',
3333
\Redis::MULTI => 'MULTI',
3434
\Redis::PIPELINE => 'PIPELINE',
3535
];
3636

37-
private static $compression = [
37+
private const COMPRESSION_MODES = [
3838
0 => 'NONE', // Redis::COMPRESSION_NONE
3939
1 => 'LZF', // Redis::COMPRESSION_LZF
4040
];
4141

42-
private static $failover = [
42+
private const FAILOVER_OPTIONS = [
4343
\RedisCluster::FAILOVER_NONE => 'NONE',
4444
\RedisCluster::FAILOVER_ERROR => 'ERROR',
4545
\RedisCluster::FAILOVER_DISTRIBUTE => 'DISTRIBUTE',
@@ -63,7 +63,7 @@ public static function castRedis(\Redis $c, array $a, Stub $stub, bool $isNested
6363
$prefix.'host' => $c->getHost(),
6464
$prefix.'port' => $c->getPort(),
6565
$prefix.'auth' => $c->getAuth(),
66-
$prefix.'mode' => isset(self::$mode[$mode]) ? new ConstStub(self::$mode[$mode], $mode) : $mode,
66+
$prefix.'mode' => isset(self::MODES[$mode]) ? new ConstStub(self::MODES[$mode], $mode) : $mode,
6767
$prefix.'dbNum' => $c->getDbNum(),
6868
$prefix.'timeout' => $c->getTimeout(),
6969
$prefix.'lastError' => $c->getLastError(),
@@ -95,7 +95,7 @@ public static function castRedisCluster(\RedisCluster $c, array $a, Stub $stub,
9595
$prefix.'mode' => new ConstStub($c->getMode() ? 'MULTI' : 'ATOMIC', $c->getMode()),
9696
$prefix.'lastError' => $c->getLastError(),
9797
$prefix.'options' => self::getRedisOptions($c, [
98-
'SLAVE_FAILOVER' => isset(self::$failover[$failover]) ? new ConstStub(self::$failover[$failover], $failover) : $failover,
98+
'SLAVE_FAILOVER' => isset(self::FAILOVER_OPTIONS[$failover]) ? new ConstStub(self::FAILOVER_OPTIONS[$failover], $failover) : $failover,
9999
]),
100100
];
101101

@@ -110,23 +110,23 @@ private static function getRedisOptions($redis, array $options = []): EnumStub
110110
$serializer = $redis->getOption(\Redis::OPT_SERIALIZER);
111111
if (\is_array($serializer)) {
112112
foreach ($serializer as &$v) {
113-
if (isset(self::$serializer[$v])) {
114-
$v = new ConstStub(self::$serializer[$v], $v);
113+
if (isset(self::SERIALIZERS[$v])) {
114+
$v = new ConstStub(self::SERIALIZERS[$v], $v);
115115
}
116116
}
117-
} elseif (isset(self::$serializer[$serializer])) {
118-
$serializer = new ConstStub(self::$serializer[$serializer], $serializer);
117+
} elseif (isset(self::SERIALIZERS[$serializer])) {
118+
$serializer = new ConstStub(self::SERIALIZERS[$serializer], $serializer);
119119
}
120120

121121
$compression = \defined('Redis::OPT_COMPRESSION') ? $redis->getOption(\Redis::OPT_COMPRESSION) : 0;
122122
if (\is_array($compression)) {
123123
foreach ($compression as &$v) {
124-
if (isset(self::$compression[$v])) {
125-
$v = new ConstStub(self::$compression[$v], $v);
124+
if (isset(self::COMPRESSION_MODES[$v])) {
125+
$v = new ConstStub(self::COMPRESSION_MODES[$v], $v);
126126
}
127127
}
128-
} elseif (isset(self::$compression[$compression])) {
129-
$compression = new ConstStub(self::$compression[$compression], $compression);
128+
} elseif (isset(self::COMPRESSION_MODES[$compression])) {
129+
$compression = new ConstStub(self::COMPRESSION_MODES[$compression], $compression);
130130
}
131131

132132
$retry = \defined('Redis::OPT_SCAN') ? $redis->getOption(\Redis::OPT_SCAN) : 0;

Caster/ReflectionCaster.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class ReflectionCaster
2424
{
2525
public const UNSET_CLOSURE_FILE_INFO = ['Closure' => __CLASS__.'::unsetClosureFileInfo'];
2626

27-
private static $extraMap = [
27+
private const EXTRA_MAP = [
2828
'docComment' => 'getDocComment',
2929
'extension' => 'getExtensionName',
3030
'isDisabled' => 'isDisabled',
@@ -370,7 +370,7 @@ private static function addExtra(array &$a, \Reflector $c)
370370
$x['line'] = $c->getStartLine().' to '.$c->getEndLine();
371371
}
372372

373-
self::addMap($x, $c, self::$extraMap, '');
373+
self::addMap($x, $c, self::EXTRA_MAP, '');
374374

375375
if ($x) {
376376
$a[Caster::PREFIX_VIRTUAL.'extra'] = new EnumStub($x);

Caster/SplCaster.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*/
2323
class SplCaster
2424
{
25-
private static $splFileObjectFlags = [
25+
private const SPL_FILE_OBJECT_FLAGS = [
2626
\SplFileObject::DROP_NEW_LINE => 'DROP_NEW_LINE',
2727
\SplFileObject::READ_AHEAD => 'READ_AHEAD',
2828
\SplFileObject::SKIP_EMPTY => 'SKIP_EMPTY',
@@ -169,7 +169,7 @@ public static function castFileObject(\SplFileObject $c, array $a, Stub $stub, b
169169

170170
if (isset($a[$prefix.'flags'])) {
171171
$flagsArray = [];
172-
foreach (self::$splFileObjectFlags as $value => $name) {
172+
foreach (self::SPL_FILE_OBJECT_FLAGS as $value => $name) {
173173
if ($a[$prefix.'flags'] & $value) {
174174
$flagsArray[] = $name;
175175
}

Caster/SymfonyCaster.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
*/
2020
class SymfonyCaster
2121
{
22-
private static $requestGetters = [
22+
private const REQUEST_GETTERS = [
2323
'pathInfo' => 'getPathInfo',
2424
'requestUri' => 'getRequestUri',
2525
'baseUrl' => 'getBaseUrl',
@@ -32,7 +32,7 @@ public static function castRequest(Request $request, array $a, Stub $stub, bool
3232
{
3333
$clone = null;
3434

35-
foreach (self::$requestGetters as $prop => $getter) {
35+
foreach (self::REQUEST_GETTERS as $prop => $getter) {
3636
$key = Caster::PREFIX_PROTECTED.$prop;
3737
if (\array_key_exists($key, $a) && null === $a[$key]) {
3838
if (null === $clone) {

Caster/XmlReaderCaster.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
*/
2222
class XmlReaderCaster
2323
{
24-
private static $nodeTypes = [
24+
private const NODE_TYPES = [
2525
\XMLReader::NONE => 'NONE',
2626
\XMLReader::ELEMENT => 'ELEMENT',
2727
\XMLReader::ATTRIBUTE => 'ATTRIBUTE',
@@ -48,7 +48,7 @@ public static function castXmlReader(\XMLReader $reader, array $a, Stub $stub, b
4848
$info = [
4949
'localName' => $reader->localName,
5050
'prefix' => $reader->prefix,
51-
'nodeType' => new ConstStub(self::$nodeTypes[$reader->nodeType], $reader->nodeType),
51+
'nodeType' => new ConstStub(self::NODE_TYPES[$reader->nodeType], $reader->nodeType),
5252
'depth' => $reader->depth,
5353
'isDefault' => $reader->isDefault,
5454
'isEmptyElement' => \XMLReader::NONE === $reader->nodeType ? null : $reader->isEmptyElement,

Caster/XmlResourceCaster.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*/
2323
class XmlResourceCaster
2424
{
25-
private static $xmlErrors = [
25+
private const XML_ERRORS = [
2626
\XML_ERROR_NONE => 'XML_ERROR_NONE',
2727
\XML_ERROR_NO_MEMORY => 'XML_ERROR_NO_MEMORY',
2828
\XML_ERROR_SYNTAX => 'XML_ERROR_SYNTAX',
@@ -54,8 +54,8 @@ public static function castXml($h, array $a, Stub $stub, bool $isNested)
5454
$a['current_line_number'] = xml_get_current_line_number($h);
5555
$a['error_code'] = xml_get_error_code($h);
5656

57-
if (isset(self::$xmlErrors[$a['error_code']])) {
58-
$a['error_code'] = new ConstStub(self::$xmlErrors[$a['error_code']], $a['error_code']);
57+
if (isset(self::XML_ERRORS[$a['error_code']])) {
58+
$a['error_code'] = new ConstStub(self::XML_ERRORS[$a['error_code']], $a['error_code']);
5959
}
6060

6161
return $a;

0 commit comments

Comments
 (0)