src/Uri.php
protected function filterPort(?int $port): ?int
    {
        if ((integer) $port >= 0 && (integer) $port <= 65535) {
            return $port;
        }

        throw new InvalidArgumentException('Uri port must be null or an integer between 1 and 65535 (inclusive)');
    }
protected function filterPort(?int $port): ?int
    {
        if ((integer) $port >= 0 && (integer) $port <= 65535) {
            return $port;
        }

        throw new InvalidArgumentException('Uri port must be null or an integer between 1 and 65535 (inclusive)');
    }
Filter allowable port to minimize risk

@access protected
@return integer|null $port
@throws InvalidArgumentException for incorrect port assigned