- md5
- 138802ae7600373de92d14001cf135d6
- sha1
- 35ccb5a265315a374bb0d2ab568cdf198ada1d6c
- sha256
- 43953d9be67f57787190b4acf8d3717eafe98de99e709de746f860026e390aa5
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\VarDumper\Caster;
use Symfony\Component\VarDumper\Cloner\Stub;
/**
* @author Nicolas Grekas <[email protected]>
* @author Alexandre Daubois <[email protected]>
*
* @internal
*/
final class SocketCaster
{
public static function castSocket(\Socket $socket, array $a, Stub $stub, bool $isNested): array
{
socket_getsockname($socket, $addr, $port);
$info = stream_get_meta_data(socket_export_stream($socket));
if (\PHP_VERSION_ID >= 80300) {
$uri = ($info['uri'] ?? '//');
if (str_starts_with($uri, 'unix://')) {
$uri .= $addr;
} else {
$uri .= \sprintf(str_contains($addr, ':') ? '[%s]:%s' : '%s:%s', $addr, $port);
}
$a[Caster::PREFIX_VIRTUAL.'uri'] = $uri;
if (@socket_atmark($socket)) {
$a[Caster::PREFIX_VIRTUAL.'atmark'] = true;
}
}
$a += [
Caster::PREFIX_VIRTUAL.'timed_out' => $info['timed_out'],
Caster::PREFIX_VIRTUAL.'blocked' => $info['blocked'],
];
if (!$lastError = socket_last_error($socket)) {
return $a;
}
static $errors;
if (!$errors) {
$errors = get_defined_constants(true)['sockets'] ?? [];
$errors = array_flip(array_filter($errors, static fn ($k) => str_starts_with($k, 'SOCKET_E'), \ARRAY_FILTER_USE_KEY));
}
$a[Caster::PREFIX_VIRTUAL.'last_error'] = new ConstStub($errors[$lastError], socket_strerror($lastError));
return $a;
}
}
The same content is in 49 releases, Joomla 6.0.0-beta1 to 6.3.0-alpha1. See them all, or every version of this file.