Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Checks whether a constant with the given name exists
<?php defined(string $constant_name): bool
<?php require __DIR__ . '/../vendor/autoload.php';



if (!defined('STDIN')) {

    echo 'STDIO streams require CLI SAPI' . PHP_EOL;

    exit(1);

}
<?php         if ($this->unix) {



            if (\substr($address, -1) === ':' && \defined('HHVM_VERSION_ID') && \HHVM_VERSION_ID < 31900) {

                $address = (string)\substr($address, 0, -1); // @codeCoverageIgnore

            }
<?php         if (!isset($this->connectors[$scheme])) {

            return \React\Promise\reject(new \RuntimeException(

                'No connector available for URI scheme "' . $scheme . '" (EINVAL)',

                \defined('SOCKET_EINVAL') ? \SOCKET_EINVAL : 22

            ));

        }
<?php         if (!$parts || !isset($parts['host'])) {

            return Promise\reject(new \InvalidArgumentException(

                'Given URI "' . $original . '" is invalid (EINVAL)',

                \defined('SOCKET_EINVAL') ? \SOCKET_EINVAL : 22

            ));

        }
<?php                 if ($resolved === null) {

                    $reject(new \RuntimeException(

                        'Connection to ' . $uri . ' cancelled during DNS lookup (ECONNABORTED)',

                        \defined('SOCKET_ECONNABORTED') ? \SOCKET_ECONNABORTED : 103

                    ));

                }
<?php         if (!\is_int($fd) || $fd < 0 || $fd >= \PHP_INT_MAX) {

            throw new \InvalidArgumentException(

                'Invalid FD number given (EINVAL)',

                \defined('SOCKET_EINVAL') ? \SOCKET_EINVAL : 22

            );

        }
<?php         if (!isset($meta['stream_type']) || $meta['stream_type'] !== 'tcp_socket') {

            \fclose($this->master);



            $errno = \defined('SOCKET_ENOTSOCK') ? \SOCKET_ENOTSOCK : 88;

            $errstr = \function_exists('socket_strerror') ? \socket_strerror($errno) : 'Not a socket';



            throw new \RuntimeException(
<?php         if (\stream_socket_get_name($this->master, true) !== false) {

            \fclose($this->master);



            $errno = \defined('SOCKET_EISCONN') ? \SOCKET_EISCONN : 106;

            $errstr = \function_exists('socket_strerror') ? \socket_strerror($errno) : 'Socket is connected';



            throw new \RuntimeException(
<?php         }, function ($_, $reject) use ($that, &$timer) {

            $reject(new \RuntimeException(

                'Connection to ' . $that->uri . ' cancelled' . (!$that->connectionPromises ? ' during DNS lookup' : '') . ' (ECONNABORTED)',

                \defined('SOCKET_ECONNABORTED') ? \SOCKET_ECONNABORTED : 103

            ));

            $_ = $reject = null;
<?php         if (!$parts || !isset($parts['host'])) {

            return Promise\reject(new \InvalidArgumentException(

                'Given URI "' . $original . '" is invalid (EINVAL)',

                \defined('SOCKET_EINVAL') ? \SOCKET_EINVAL : 22

            ));

        }
<?php         if (!$parts || !isset($parts['scheme']) || $parts['scheme'] !== 'tls') {

            return Promise\reject(new \InvalidArgumentException(

                'Given URI "' . $uri . '" is invalid (EINVAL)',

                \defined('SOCKET_EINVAL') ? \SOCKET_EINVAL : 22

            ));

        }
<?php                 if ($connected) {

                    $reject(new \RuntimeException(

                        'Connection to ' . $uri . ' cancelled during TLS handshake (ECONNABORTED)',

                        \defined('SOCKET_ECONNABORTED') ? \SOCKET_ECONNABORTED : 103

                    ));

                }
<?php             if (preg_match('#^(?:\w+://)?\d+$#', $uri)) {

                throw new \InvalidArgumentException(

                    'Invalid URI given (EINVAL)',

                    \defined('SOCKET_EINVAL') ? \SOCKET_EINVAL : 22

                );

            }
<?php                 $d->reject(new \UnexpectedValueException(

                    'Connection lost during TLS handshake (ECONNRESET)',

                    \defined('SOCKET_ECONNRESET') ? \SOCKET_ECONNRESET : 104

                ));

            } else {
<?php         if (!$parts || !isset($parts['scheme'], $parts['host'], $parts['port']) || $parts['scheme'] !== 'tcp') {

            return Promise\reject(new \InvalidArgumentException(

                'Given URI "' . $uri . '" is invalid (EINVAL)',

                \defined('SOCKET_EINVAL') ? \SOCKET_EINVAL : 22

            ));

        }