Validates a given port. A port is valid if it is either null or an integer between 1 and 65535 inclusive.

@param mixed $port   The port to be validated
@return bool         Returns true if the given port is valid
Returns false otherwise
162582
public static function isValid($port)
    {
        $port_valid = false;

        if (is_int($port)) {
            $port_valid = self::portIsInValidRange($port);
        } elseif (is_null($port)) {
            $port_valid = true;
        }

        return $port_valid;
    }
418996
protected function validPortStandard($port)
    {
        return in_array($port, $this->ports) &&
            $this->scheme === array_keys($this->ports, $port)[ 0 ];
    }
939078
function isLegalPort(port: number) : boolean {
  if (typeof port === 'string' && port.trim() === '') {
    return false;
  }
  return +port === (port >>> 0) && port >= 0 && port <= 0xFFFF;
}
362998
protected function marshalPort($port): ? int
    {
        if ( null === $port ) {
            return null;
        }

        $port = (int) $port;

        if ( 0 > $port || 65535 < $port ) {
            throw new UriException(
                sprintf('Invalid port: %s, value must be between 0 and 65535', $port)
            );
        }

        return $port;
    }
1167903
public function validate(&$error = null)
    {
        if (!$this->isCountryCodeValid()) {
            $error = 'IBAN country code not valid or not supported';
        } elseif (!$this->isLengthValid()) {
            $error = 'IBAN length is invalid';
        } elseif (!$this->isFormatValid()) {
            $error = 'IBAN format is invalid';
        } elseif (!$this->isChecksumValid()) {
            $error = 'IBAN checksum is invalid';
        } else {
            $error = '';
            return true;
        }

        return false;
    }
50805
def _validate_single_port_string(port):
    
    if ' ' not in port or len(port.split(' ')) != 2:
        raise ValueError(
            "Port '{}' should have exactly one space in it".format(port)
        )
    (external, internal) = port.split(' ')
    try:
        external = int(external)
    except ValueError:
        raise ValueError(
            "Port '{}' external port isn't an int".format(port)
        )
    if ':' not in internal:
        raise ValueError(
            "Port '{}' local address should be 'IP:port'".format(port)
        )
    if not internal.startswith('unix:'):
        ip, localport = internal.split(':')
        if ip != 'localhost' and not _is_non_public_numeric_address(ip):
            raise ValueError(
                "Port '{}' internal IP '{}' should be a local "
                "address".format(port, ip)
            )
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;
    }
631701
public function setPort($port)
    {
        if ($port != $this->_port) {
            $this->_port = (int)$port;
            $this->_hostInfo = null;
        }
        return $this;
    }
489701
protected function setPort($port)
    {
        if ((string)$port !== '' && !$this->isValidPort($port)) {
            throw new \InvalidArgumentException("Invalid port '$port'");
        }
        
        $this->port = $port ? (int)$port : null;
    }
1118906
public function setPort($port)
    {
        if (!empty($port)) {
            $this->port = intval($port);
        }
        else {
            $this->port = null;
        }

        return $this;
    }
450176
public function validate($input): bool
    {
        if (!$length = $this->extractLength($input)) {
            return false;
        }

        return (null === $this->minValue || $this->less($this->minValue, $length))
            && (null === $this->maxValue || $this->less($length, $this->maxValue));
    }
1105818
private static function myValidatePort(int $port, ?string &$error): bool
    {
        // Port below 0 is invalid.
        if ($port < 0) {
            $error = 'Port ' . $port . ' is out of range: Minimum port number is 0.';

            return false;
        }

        // Port above 65535 is invalid.
        if ($port > 65535) {
            $error = 'Port ' . $port . ' is out of range: Maximum port number is 65535.';

            return false;
        }

        return true;
    }
503155
public function setPort($port)
    {
        if (!ctype_digit($port)) {
            trigger_error('Port must be a positive integer: ' . var_export($port, true), E_USER_ERROR);
        }
        $this->port = $port;
    }
689128
public function validateIp($ip)
    {
        $ipnums = explode(".", $ip);
        if (count($ipnums) != 4) {
            return false;
        }
        foreach($ipnums as $ipnum) {
            if (!is_numeric($ipnum) || ($ipnum > 255)) {
                return false;
            }
        }
        return $ip;
    }
620227
private function verify_port(int $port=null, string $proto) {
		if (!$port)
			return $port;
		if ($port < 0 || $port > pow(2, 16))
			return null;
		if ($port == 80 && $proto == 'http')
			return null;
		if ($port == 443 && $proto == 'https')
			return null;
		return $port;
	}
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;
    }
1024068
public function validateStatus($status)
    {
        if ($status === null) {
            $this->addError('status', 'Status cannot be null');
            return false;
        }

        $valid = [Application::STATUS_ENABLED, Application::STATUS_DISABLED];

        if (!in_array($status, $valid, true)) {
            $this->addError('status', 'Status must be equal to 1 or 2');
            return false;
        }

        return true;
    }