function format_flags(int $kind, int $flags) : string { list($exclusive, $combinable) = get_flag_info(); if (isset($exclusive[$kind])) { $flagInfo = $exclusive[$kind]; if (isset($flagInfo[$flags])) { return "{$flagInfo[$flags]} ({$flags})"; } } else { if (isset($combinable[$kind])) { $flagInfo = $combinable[$kind]; $names = []; foreach ($flagInfo as $flag => $name) { if ($flags & $flag) { $names[] = $name; } } if (!empty($names)) { return implode(" | ", $names) . " ({$flags})"; } } } return (string) $flags; }
private function csv_format_flags(int $kind, int $flags) : string { list($exclusive, $combinable) = get_flag_info(); if (isset($exclusive[$kind])) { $flagInfo = $exclusive[$kind]; if (isset($flagInfo[$flags])) { return $flagInfo[$flags]; } } else { if (isset($combinable[$kind])) { $flagInfo = $combinable[$kind]; $names = []; foreach ($flagInfo as $flag => $name) { if ($flags & $flag) { $names[] = $name; } } if (!empty($names)) { return implode($this->array_delim, $names); } } } // If the given $kind does not use either exclusive or combinable // flags, or if it does, but the given $flags did not yield any // flags for the given $kind, we arrive here. In principle $flags // should always be 0 at this point. // TODO: for ast\AST_ARRAY_ELEM (kind=525) and ast\AST_CLOSURE_VAR // (kind=2049), the flag might be 1, meaning "by-reference", but // this cannot be properly formated since no appropriate names are // declared in util.php. Ask Niki about that. Maybe submit patch. if ($flags === 0) { return ""; } else { return "\"[WARNING] Unexpected flags for kind: kind={$kind} and flags={$flags}\""; } }