1
0
mirror of https://github.com/danog/MadelineProto.git synced 2025-01-12 00:38:16 +01:00
MadelineProto/src/polyfill.php

42 lines
1.1 KiB
PHP
Raw Normal View History

2022-12-30 21:54:44 +01:00
<?php
declare(strict_types=1);
2020-01-31 19:29:43 +01:00
if (defined('MADELINE_POLYFILLED')) {
return;
}
define('MADELINE_POLYFILLED', true);
$ampFilePolyfill = 'namespace Amp\\File {';
foreach ([
'open' => 'openFile',
'stat' => 'getStatus',
'lstat' => 'getLinkStatus',
'size' => 'getSize',
'isdir' => 'isDirectory',
'mtime' => 'getModificationTime',
'atime' => 'getAccessTime',
'ctime' => 'getCreationTime',
'symlink' => 'createSymlink',
'link' => 'createHardlink',
'readlink' => 'resolveSymlink',
'rename' => 'move',
'unlink' => 'deleteFile',
'rmdir' => 'deleteDirectory',
'scandir' => 'listFiles',
'chmod' => 'changePermissions',
'chown' => 'changeOwner',
'get' => 'read',
'put' => 'write',
'mkdir' => 'createDirectory',
] as $old => $new) {
$ampFilePolyfill .= "function $old(...\$args) { return $new(...\$args); }";
}
2023-01-04 15:13:55 +01:00
$ampFilePolyfill .= '}';
eval($ampFilePolyfill);
unset($ampFilePolyfill);
class_alias(LocalCookieJar::class, InMemoryCookieJar::class);
class_alias(ResourceSocket::class, EncryptableSocket::class);