18
18
*/
19
19
class MemcachedCaster
20
20
{
21
+ public static $ optionConstants ;
22
+ public static $ defaultOptions ;
23
+
21
24
public static function castMemcached (\Memcached $ c , array $ a , Stub $ stub , $ isNested )
22
25
{
23
26
$ a += array (
@@ -32,12 +35,12 @@ public static function castMemcached(\Memcached $c, array $a, Stub $stub, $isNes
32
35
33
36
public static function getMemcachedNonDefaultValueOptions (\Memcached $ c )
34
37
{
35
- $ defaultOptions = self ::discoverDefaultMemcachedOptions ();
36
- $ optionConstants = self ::getMemcachedOptionConstants ();
38
+ self :: $ defaultOptions = self :: $ defaultOptions ?? self ::discoverDefaultMemcachedOptions ();
39
+ self :: $ optionConstants = self :: $ optionConstants ?? self ::getMemcachedOptionConstants ();
37
40
38
41
$ nonDefaultOptions = array ();
39
- foreach ($ optionConstants as $ constantKey => $ value ) {
40
- if ($ defaultOptions [$ constantKey ] !== $ option = $ c ->getOption ($ value )) {
42
+ foreach (self :: $ optionConstants as $ constantKey => $ value ) {
43
+ if (self :: $ defaultOptions [$ constantKey ] !== $ option = $ c ->getOption ($ value )) {
41
44
$ nonDefaultOptions [$ constantKey ] = $ option ;
42
45
}
43
46
}
@@ -66,7 +69,7 @@ public static function getMemcachedOptionConstants()
66
69
67
70
$ optionConstants = array ();
68
71
foreach ($ reflectedMemcached ->getConstants () as $ constantKey => $ value ) {
69
- if (' OPT_ ' === substr ($ constantKey , 0 , 4 )) {
72
+ if (0 === strpos ($ constantKey , ' OPT_ ' )) {
70
73
$ optionConstants [$ constantKey ] = $ value ;
71
74
}
72
75
}
0 commit comments