Returns true if and only if the TCP port string passes validation. If no port is passed,
then the port contained in the instance variable is used.

@param  string $port The HTTP port
@return boolean
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;
    }
1345809
private static function isStandardPort($port, $scheme = null, $host = null)
    {
        if ($host === null || $scheme === null) {
            return false;
        }

        return array_key_exists($scheme, static::$schemes) && $port === static::$schemes[$scheme];
    }
302692
public function setPort( $port ) : PgSQL
   {

      if ( null === $port )
      {
         $this->_attributes[ 'port' ] = $port;
         return $this;
      }

      $port = false;
      if ( \is_string( $port ) )
      {
         $port = (int) $port;
      }
      else if ( TypeTool::IsInteger( $port ) )
      {
         $port = (int) $port;
      }
      else if ( TypeTool::IsStringConvertible( $port, $portStr ) )
      {
         $port = (int) $portStr;
      }

      if ( ! \is_int( $port ) || ! $this->_supportedAttributes->get( 'port' )->validateValue( $port ) )
      {
         throw new ArgumentException( 'port', $port, 'Invalid port!' );
      }

      $this->_attributes[ 'port' ] = $port;

      return $this;

   }
723714
protected function checkConnection($host, $port)
    {
        $host = ($port == 443) ? 'ssl://' . $host : 'tcp://' . $host;

        // If the connection could not be established, fsockopen sadly does not
        // only return false (as documented), but also always issues a warning.
        if (($this->connection === null) &&
            (($this->connection = @stream_socket_client($host . ':' . $port, $errno, $errstr)) === false)) {
            // This is a bit hackisch...
            $this->connection = null;
            throw new \RuntimeException('fail');
        }
    }
190552
private function isAddressValid(string $address): bool
    {
        $position = \strrpos($address, ':');
        if ($position === false) {
            return ($address[0] ?? '') === "\0"; // udg socket address.
        }

        $ip = \trim(\substr($address, 0, $position), '[]');
        $port = (int) \substr($address, $position + 1);

        return \inet_pton($ip) !== false && $port > 0 && $port < 65536;
    }
23000
public static function validate($viaPort) {
    if (preg_match('/^(?!\-)(?:[a-zA-Z\d\-]{0,62}[a-zA-Z\d]\.){1,126}(?!\d+)[a-zA-Z\d]{1,63}:\d+$/', $viaPort)) {
      return TRUE;
    }
    if (preg_match('/([0-9a-fA-F\.:]+):\d+/', $viaPort, $matches)) {
      return filter_var($matches[1], FILTER_VALIDATE_IP) !== FALSE;
    }
    return FALSE;
  }
782696
private function isDefaultPort(string $scheme, int $port): bool
    {
        return isset(self::$knownPorts[$scheme]) && self::$knownPorts[$scheme] == $port;
    }
824464
public function setPort($port = null)
    {
        if (null !== $port) {
            $this->port = (int) $port;
        }

        return $this;
    }
910721
public function isDefaultPort(int $port = null)
	{
		$port = $port ?: $this->port;
		return $port === null || $port === (self::$allowedSchemes[$this->_scheme] ?? null);
	}
735234
public static function filterPort($port = null)
    {
        if (null === $port || (\is_int($port) && ($port >= 1 && $port <= 65535))) {
            return $port;
        }

        throw new \InvalidArgumentException('Uri port must be null or an integer between 1 and 65535');
    }
338863
public static function isIPFormat($endpoint)
    {
        $ip_array = explode(":", $endpoint);
        $hostname = $ip_array[0];
        $ret = filter_var($hostname, FILTER_VALIDATE_IP);
        if (!$ret) {
            return false;
        } else {
            return true;
        }
    }
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;
    }
1135730
public function setPort($port = null)
    {
        if (is_null($port)) {
            $port = ($this->_protocol == 'ssl') ? 465 : 25;
        }

        $this->_port = $port;
    }
519801
protected function _hasServer($host, $port)
    {
        $servers = $this->getServerList();
        foreach ($servers as $server) {
            if ($server['host'] === $host && $server['port'] === $port) {
                return true;
            }
        }

        return false;
    }
946279
protected function filterPort(int $port = null): int
    {
        $port = (int) $port; // Cast null to 0.

        if (0 > $port || 0xffff < $port) {
            throw new InvalidValueException(
                sprintf('Invalid port: %d. Must be 0 or an integer between 1 and 65535.', $port)
            );
        }

        return $port;
    }
32694
public static function isValid($status)
    {
        switch (strtolower($status)) {
        case strtolower(self::SUSPENDED):
        case strtolower(self::RUNNING):
        return true;

        default:
        return false;
        }
    }
1120792
private function validateParameter(string $parameter): bool
    {
        $properties = explode('=', $parameter);

        return 2 != count($properties) || strtolower($properties[0]) === static::BINARY_PARAMETER;
    }