| Server IP : 139.59.63.204 / Your IP : 216.73.217.62 Web Server : Apache/2.4.58 (Ubuntu) System : Linux ubuntu-s-1vcpu-1gb-blr1-01 6.8.0-110-generic #110-Ubuntu SMP PREEMPT_DYNAMIC Thu Mar 19 15:09:20 UTC 2026 x86_64 User : root ( 0) PHP Version : 8.3.6 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/abyogasms.com/vendor/league/csv/src/ |
Upload File : |
<?php
/**
* League.Csv (https://csv.thephpleague.com)
*
* (c) Ignace Nyamagana Butera <nyamsprod@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace League\Csv;
use ErrorException;
use Throwable;
use function in_array;
use function restore_error_handler;
use function set_error_handler;
use const E_USER_WARNING;
use const E_WARNING;
/**
* @internal Utility class to wrap callbacks to control emitted warnings during their execution.
*
* @template TReturn
*/
final class Warning
{
/**
* Converts PHP Warning into ErrorException.
*
* @param mixed ...$arguments the callback arguments if needed
*
* @throws ErrorException If the callback internally emits a Warning
* @throws Throwable on callback execution if the callback throws
*
* @return TReturn The result returned by the callback.
*/
public static function trap(callable $callback, mixed ...$arguments): mixed
{
set_error_handler(
fn (int $errno, string $errstr, string $errfile, int $errline): bool =>
in_array($errno, [E_WARNING, E_USER_WARNING], true)
? throw new ErrorException($errstr, 0, $errno, $errfile, $errline)
: false
);
return self::execute($callback, $arguments);
}
/**
* Hides PHP Warnings.
*
* @param mixed ...$arguments the callback arguments if needed
*
* @throws Throwable on callback execution if the callback throws
*
* @return TReturn The result returned by the callback.
*/
public static function cloak(callable $callback, mixed ...$arguments): mixed
{
set_error_handler(
fn (int $errno, string $errstr, string $errfile, int $errline): bool =>
in_array($errno, [E_WARNING, E_USER_WARNING], true),
);
return self::execute($callback, $arguments);
}
/**
* @param array<mixed> $arguments the callback arguments if needed
*
* @return TReturn The result returned by the callback.
*/
private static function execute(callable $callback, array $arguments)
{
try {
return $callback(...$arguments);
} finally {
restore_error_handler();
}
}
}