format given address by splitting it into returned address and port set by reference

@param string $address
@param int $port
@return string address with port removed
324638
protected function unformatAddress($address, &$port)
    {
        // [::1]:2 => ::1 2
        // test:2 => test 2
        // ::1 => ::1
        // test => test

        $colon = strrpos($address, ':');

        // there is a colon and this is the only colon or there's a closing IPv6 bracket right before it
        if ($colon !== false && (strpos($address, ':') === $colon || strpos($address, ']') === ($colon - 1))) {
            $port = (int)substr($address, $colon + 1);
            $address = substr($address, 0, $colon);

            // remove IPv6 square brackets
            if (substr($address, 0, 1) === '[') {
                $address = substr($address, 1, -1);
            }
        }
        return $address;
    }
503633
public static function isIP($address)
    {

        //Split the IP address of the form  into parts
        $parts = explode('.', $address);
        //=4 parts
        if (sizeof($parts) != 4) {
            return false;
        }
        foreach ($parts as $part):
            if (empty($part) || !static::number($part) || $part > 255) {
                return false;
            }
        endforeach;

        return true;
    }
289234
protected static function getHostAndPortFromHeader(&$host, &$port, $headerHost)
    {
        if (is_array($headerHost)) {
            $headerHost = implode(', ', $headerHost);
        }

        $host = $headerHost;

        if (preg_match('|\:(\d+)$|', $host, $matches)) {
            $host = substr($host, 0, -1 * (strlen($matches[1]) + 1));
            $port = (int) $matches[1];
        }
    }
24686
private function scanAddress($address)
    {
        /*
         * today's timestamp used as report time (today 00:00) to prevent a lot of duplicates on the
         * same day. Using the same time will aggregate and deduplicate events into 1 per day.
         */


        if (!filter_var($address, FILTER_VALIDATE_IP) === false) {
            $addressReverse = implode('.', array_reverse(preg_split('/\./', $address)));

            foreach ($this->feeds as $feedName => $feedData) {
                $this->feedName = $feedName;

                if ($this->isKnownFeed() && $this->isEnabledFeed()) {
                    $lookup = $addressReverse . '.' . $feedData['zone'] . '.';

                    if ($result = gethostbyname($lookup)) {
                        if ($result != $lookup) {
                            // If config is empty, we fall back to this
                            $reason = 'SPAM Sending host';

                            // Set the config default reason if available
                            if (array_key_exists('default', $feedData['codes'])) {
                                $reason = $feedData['codes']['default'];
                            }

                            // Set the config specific reason if available
                            if (array_key_exists($result, $feedData['codes'])) {
                                $reason = $feedData['codes'][$result];
                            }

                            $incident = new Incident();
                            $incident->source      = $feedName;
                            $incident->source_id   = false;
                            $incident->ip          = $address;
                            $incident->domain      = false;
                            $incident->class       = $feedData['class'];
                            $incident->type        = $feedData['type'];

                            /*
                             * today's timestamp used as report time (today 00:00) to prevent a lot of duplicates on the
                             * same day. Using the same time will aggregate and deduplicate events into 1 per day.
                             */
                            $incident->timestamp   = Carbon::today()->timestamp;

                            $incident->information = json_encode(
                                array_merge(
                                    $feedData['information'],
                                    [
                                        'reason' => $reason
                                    ]
                                )
                            );

                            $this->incidents[] = $incident;
                        }
                    }
                }
            }
        } else {
            $this->warningCount++;
        }

        return true;
    }
1295561
public static function serializeIPv6($address)
    {
        $output = inet_ntop(call_user_func_array('pack', array_merge(['n*'], $address)));
        return strpos($output, '.') !== false
            ? '::ffff:' . strtolower(dechex($address[6]) . ':' . dechex($address[7]))
            : $output;
    }
1026683
public function withPort(int $port): UriInterface
    {
        $instance = clone $this;
        $instance->port = $this->marshalPort($port);

        return $instance;
    }
743787
protected function filterPort($port)
    {
        if (empty($port)) {
            return null;
        }

        if (!self::validePort($port)) {
            throw new \InvalidArgumentException('The port is not in the TCP/UDP port.');
        }

        return $this->scheme !== '' && !$this->validPortStandard($port)
            ? (int) $port
            : null;
    }
1042947
public static function addPort(string $url, int $port)
    {
        $url    = explode('/', $url);
        $url[0] .= ':' . $port;

        return join('/', $url);
    }
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;
    }
157050
public function anonymize($address) {
        $packedAddress = inet_pton($address);

        if (strlen($packedAddress) == 4) {
            return $this->anonymizeIPv4($address);
        } elseif (strlen($packedAddress) == 16) {
            return $this->anonymizeIPv6($address);
        } else {
            return "";
        }
    }
788372
public function getPathForAddress($address) {
        $decoded = $this->addressReader->fromString($address);
        if ($decoded instanceof CashAddress) {
            $address = $decoded->getLegacyAddress();
        }

        return $this->sdk->getPathForAddress($this->identifier, $address);
    }
807146
public function cleanAddress($address)
    {
        $response = $this->query($this->prepareUri('clean/address'), [$address]);
        $result = $this->populate(new Address, $response);
        if (!$result instanceof Address) {
            throw new RuntimeException('Unexpected populate result: ' . get_class($result). '. Expected: ' . Address::class);
        }

        return $result;
    }
549987
private function setAddress($address) {

        if(!$this->formatter) {
            $this->formatter = new StringFormatter();
        }

        $this->address = trim($this->formatter->format($address, '%S %n %z %L %C'));

        return $this;
    }
764753
public function address($address) {
        $response = $this->dataClient->get($this->converter->getUrlForAddress($address));
        return $this->converter->convertAddress($response->body());
    }
1137980
public function setAddress(Address $address)
    {
        $address->setContext(Moip::SUBSCRIPTION);
        $this->data->address = $address->getData();

        return $this;
    }
877639
public function formatBillingAddress(ClientBillingAddress $address, $lineSeparator = self::LINES_SEPARATOR)
    {
        $lines   = [];
        $lines[] = sprintf('%s %s', $address->getFirstName(), $address->getLastName());
        if ('' !== $address->getCompanyName()) {
            $lines[] = $address->getCompanyName();
        }
        $lines[] = $address->getLine1();
        $lines[] = $address->getLine2();
        $lines[] = sprintf('%s, %s %s', $address->getCountry(), $address->getPostalCode(), $address->getCity());
        
        return implode($lineSeparator, $lines);
    }
583564
def format_address(address):
    """"""
    if address.kind == ArgumentKind.regular:
        return address.name

    return "{0}[{1}]".format(address.name, address.key)