public function getMethods(?int $filter = null) : array
    {
        if ($filter === null) {
            return array_values($this->getMethodsIndexedByName());
        }

        return array_values(
            array_filter(
                $this->getMethodsIndexedByName(),
                static function (ReflectionMethod $method) use ($filter) : bool {
                    return (bool) ($filter & $method->getModifiers());
                }
            )
        );
    }