File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed
Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change 1010 */
1111class FormatCache
1212{
13+ // do not access the following three arrays directly, use the getter methods instead
14+ // (there is no guarantee that the arrays are initialized)
1315 private static ?array $ formatNames = null ;
16+ private static ?array $ formatNamesHashSet = null ;
1417 private static ?array $ formatToFieldFormatsMap = null ;
1518
1619 /**
@@ -40,9 +43,24 @@ public static function getFormatNames(): array
4043 return self ::$ formatNames ;
4144 }
4245
46+ /**
47+ * @return array Returns a hash set of all defined formats (actually a dictionary with arbitrary values).
48+ */
49+ public static function getFormatNamesHashSet (): array
50+ {
51+ if (self ::$ formatNamesHashSet == null ) {
52+ $ formatNames = self ::getFormatNames ();
53+ self ::$ formatNamesHashSet = [];
54+ foreach ($ formatNames as $ formatName ) {
55+ self ::$ formatNamesHashSet [$ formatName ] = true ;
56+ }
57+ }
58+ return self ::$ formatNamesHashSet ;
59+ }
60+
4361 public static function formatExists (string $ format ): bool
4462 {
45- return in_array ($ format , self ::getFormatNames ());
63+ return array_key_exists ($ format , self ::getFormatNamesHashSet ());
4664 }
4765
4866 /**
You can’t perform that action at this time.
0 commit comments