2022-12-30 21:54:44 +01:00
< ? php
declare ( strict_types = 1 );
2020-01-31 19:29:43 +01:00
2023-01-27 16:47:26 +01:00
if ( defined ( 'MADELINE_POLYFILLED' )) {
return ;
}
define ( 'MADELINE_POLYFILLED' , true );
2023-02-15 10:07:15 +01:00
if ( PHP_VERSION_ID === 80202 || PHP_VERSION_ID === 80115 || PHP_VERSION_ID === 80203 || PHP_VERSION_ID === 80116 ) {
2023-02-18 16:12:51 +01:00
echo ( 'PHP 8.2.2, 8.2.3, 8.1.15, 8.1.16 have a critical garbage collector bug, please switch to PHP 8.1.14 or PHP 8.2.1, see https://t.me/MadelineProto/609 for more info' . PHP_EOL );
2023-02-06 14:48:08 +01:00
die ( 1 );
}
2023-02-04 22:33:52 +01:00
use Amp\Http\Client\Cookie\InMemoryCookieJar ;
use Amp\Http\Client\Cookie\LocalCookieJar ;
use Amp\Socket\EncryptableSocket ;
use Amp\Socket\ResourceSocket ;
2021-12-15 13:51:01 +01:00
$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 .= '}' ;
2021-12-15 13:51:01 +01:00
eval ( $ampFilePolyfill );
unset ( $ampFilePolyfill );
2023-02-04 22:32:04 +01:00
class_alias ( LocalCookieJar :: class , InMemoryCookieJar :: class );
class_alias ( ResourceSocket :: class , EncryptableSocket :: class );