Format the Port component.

@param null|mixed $port
176688
private function formatPort($port = null): ?int
    {
        if (null === $port || '' === $port) {
            return null;
        }

        if (!is_int($port) && !(is_string($port) && 1 === preg_match('/^\d*$/', $port))) {
            throw new SyntaxError(sprintf('The port `%s` is invalid', $port));
        }

        $port = (int) $port;
        if (0 > $port) {
            throw new SyntaxError(sprintf('The port `%s` is invalid', $port));
        }

        $defaultPort = self::SCHEME_DEFAULT_PORT[$this->scheme] ?? null;
        if ($defaultPort === $port) {
            return null;
        }

        return $port;
    }
422079
public function setPort($port)
    {
        if ( ! is_null($port)) $port = (int) $port;

        $this->setAttribute('port', $port);

        return $this;
    }
1014072
public function setFormat($format = null)
    {
        if ( ! is_null($format)) {
            self::checkFormat($format);
            $this->format = $format;
        }

        return $this;
    }
500291
public function validatePort($port = null)
    {
        if ($port === null) {
            $port = $this->_port;
        }

        // If the port is empty, then it is considered valid
        if (strlen($port) === 0) {
            return true;
        }

        // Check the port against the allowed values
        return ctype_digit((string) $port) and 1 <= $port and $port <= 65535;
    }
343655
public static function format($time = null, $format = 'Y-m-d H:i:s') {
		if (!empty($time) && !is_numeric($time)) {
			$format = $time;
			$time = time();
		}
		if (is_null($time)) {
			$time = time();
		}
		return date($format, $time);
	}
941419
protected function filterPort($port)
    {
        if ($port !== null) {
            $port = intval($port);

            if ($port < 1 || $port > 65535) {
                throw new InvalidArgumentException(sprintf('Invalid port "%s".', $port));
            }
        } else {
            $port = null;
        }

        return $port;
    }
445727
protected function formatAddress($address, $port)
    {
        if ($port !== 0) {
            if (strpos($address, ':') !== false) {
                $address = '[' . $address . ']';
            }
            $address .= ':' . $port;
        }
        return $address;
    }
1019165
public function format($sFormat= null)
    {
        if (null === $sFormat) {
            return $this->getFormat();
        }

        return $this->setFormat($sFormat);
    }
190408
public function register($port)
    {
        if (is_string($port)) {
            $port = resolve($port);
        }

        $this->ports->push($port);

        return $port;
    }
350529
protected function getPorts($host = null)
    {
        $ports = $this->ports();
        array_walk($ports, function (&$port) use ($host) {
            $host = isset($host) ? $host : $port;
            $port = "{$host}:{$port}";
        });

        return $ports;
    }
685875
public function setPort(int $port): void
    {
        if ($port < 0 || $port > static::HIGHEST_PORT) {
            throw new \InvalidArgumentException('Port must be an unsigned integer on the range [0-65535]');
        }

        $this->port = $port;
    }
686711
public function withPort(int $port): UrlInterface
    {
        if (!self::myValidatePort($port, $error)) {
            throw new UrlInvalidArgumentException($error);
        }

        return new self($this->myScheme, $this->myHost, $port, $this->myPath, $this->myQueryString, $this->myFragment);
    }
1072065
public function setPort($port) {
        $this->port = $port;
        if ($this->port < 0 || $this->port > 65535) {
            throw new InvalidArgumentException('connection post is out of range');
        }
        return $this;
    }
126040
private function filterPort(?int $port): ?int
    {
        if ($port === null) {
            return null;
        }

        $port = (int) $port;
        if (1 > $port || 0xffff < $port) {
            throw new \InvalidArgumentException(sprintf('Invalid port: %d. Must be between 1 and 65535', $port));
        }

        return
            !isset(self::$schemes[$this->scheme]) ||
            $port !== self::$schemes[$this->scheme]
                ? $port : null;
    }
69132
public function setPort($port)
    {
        if ($this->validatePort($port) === false) {
            include_once 'Zend/Uri/Exception.php';
            throw new Zend_Uri_Exception("Port \"$port\" is not a valid HTTP port.");
        }

        $oldPort     = $this->_port;
        $this->_port = $port;

        return $oldPort;
    }
222768
public function setGearmanPort(int $port) : void
    {
        if ($port < 1 || $port > 65535) {
            throw new ManagerException('Invalid port number.');
        }
        $this->gearmanPort = $port;
    }
839036
final public function format($format)
    {
        if(is_null($this->value)) {
            return null;
        } else {
            return $this->value->format($format);
        }
    }