diff --git a/.gitignore b/.gitignore index 57872d0..cb5fef1 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,152 @@ -/vendor/ +MadelineProtoPhar +JSON.sh +halloween +*.raw +magnabroadcast.php +broadcast.php + +docs/.jekyll-metadata +songs.php +_site + +# JetBrains IDE +.idea/ +*.iml + +# Eclipse +.buildpath +.project +.settings + +# VI +*.swp + +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +lib64/ +parts/ +sdist/ +var/ +*.egg-info/ +.installed.cfg +*.egg + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.cache +nosetests.xml +coverage.xml + +# Translations +*.mo +*.pot + +# Django stuff: +*.log + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# emacs auto-saving files +\#*# +.#*# +vendor +*bak +token.php +*~uploading* +enc.tar.xz +a +web_data.php +web_API.log +db_connect.php + +sessions +docs_md +session.mad +*.madeline +*.madeline.* +madeline.phar +madeline.phar.version +madeline.php + +.env +composer.lock +b.php +telegram-cli* +src/Fuzzer.php +fuzzer.php +tests/500mb +*.save +*.save.1 +*.save.* +phar7 +phar5 +big +*.phar +.phpunit.result.cache +.vscode/* +.vscode +custom.md +.php_cs.cache +coverage +tempConv + +ponyScripts + +*.madeline.* + +uwu +madeline*phar +madeline*phar.version +madeline*phar.lock +e.php + +.phpdoc_cache + +tests/db-local.php +a.php +aa.php +aaa.php +aaaa.php +b.php +c.php +d.php +t.php +app_test.json +app.json +config.json + +/Dockerfile + +/docker-compose.yml +/Caddyfile +/tt.php +/changelog diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php new file mode 100644 index 0000000..371ad2d --- /dev/null +++ b/.php-cs-fixer.dist.php @@ -0,0 +1,24 @@ + true, + 'array_indentation' => true, + 'ternary_to_null_coalescing' => true, + 'assign_null_coalescing_to_coalesce_equal' => true, + ]); + } +}; + +$config->getFinder() + ->in(__DIR__ . '/src') + ->in(__DIR__ . '/tests') + ->in(__DIR__ . '/examples'); + +$cacheDir = getenv('TRAVIS') ? getenv('HOME') . '/.php-cs-fixer' : __DIR__; + +$config->setCacheFile($cacheDir . '/.php_cs.cache'); + +return $config; diff --git a/composer.json b/composer.json index 7bf7821..36aef66 100644 --- a/composer.json +++ b/composer.json @@ -7,6 +7,9 @@ "amphp/socket": "^2.2", "webmozart/assert": "^1.11" }, + "require-dev": { + "amphp/php-cs-fixer-config": "v2.x-dev" + }, "license": "AGPLv3", "autoload": { "psr-4": { @@ -18,5 +21,8 @@ "name": "Daniil Gentili", "email": "daniil@daniil.it" } - ] + ], + "scripts": { + "cs-fix": "PHP_CS_FIXER_IGNORE_ENV=1 php -d pcre.jit=0 vendor/bin/php-cs-fixer fix -v" + } } diff --git a/composer.lock b/composer.lock deleted file mode 100644 index 05da33f..0000000 --- a/composer.lock +++ /dev/null @@ -1,1310 +0,0 @@ -{ - "_readme": [ - "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", - "This file is @generated automatically" - ], - "content-hash": "3294a5c3f4a5da5aeb327f12d87fbc11", - "packages": [ - { - "name": "amphp/amp", - "version": "v3.0.0", - "source": { - "type": "git", - "url": "https://github.com/amphp/amp.git", - "reference": "aaf0ec1d5a2c20b523258995a10e80c1fb765871" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/amphp/amp/zipball/aaf0ec1d5a2c20b523258995a10e80c1fb765871", - "reference": "aaf0ec1d5a2c20b523258995a10e80c1fb765871", - "shasum": "" - }, - "require": { - "php": ">=8.1", - "revolt/event-loop": "^1 || ^0.2" - }, - "require-dev": { - "amphp/php-cs-fixer-config": "^2", - "phpunit/phpunit": "^9", - "psalm/phar": "^4.13" - }, - "type": "library", - "autoload": { - "files": [ - "src/functions.php", - "src/Future/functions.php", - "src/Internal/functions.php" - ], - "psr-4": { - "Amp\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Aaron Piotrowski", - "email": "aaron@trowski.com" - }, - { - "name": "Bob Weinand", - "email": "bobwei9@hotmail.com" - }, - { - "name": "Niklas Keller", - "email": "me@kelunik.com" - }, - { - "name": "Daniel Lowrey", - "email": "rdlowrey@php.net" - } - ], - "description": "A non-blocking concurrency framework for PHP applications.", - "homepage": "https://amphp.org/amp", - "keywords": [ - "async", - "asynchronous", - "awaitable", - "concurrency", - "event", - "event-loop", - "future", - "non-blocking", - "promise" - ], - "support": { - "issues": "https://github.com/amphp/amp/issues", - "source": "https://github.com/amphp/amp/tree/v3.0.0" - }, - "funding": [ - { - "url": "https://github.com/amphp", - "type": "github" - } - ], - "time": "2022-12-18T16:52:44+00:00" - }, - { - "name": "amphp/byte-stream", - "version": "v2.0.2", - "source": { - "type": "git", - "url": "https://github.com/amphp/byte-stream.git", - "reference": "408a3b4fc4f4c7604575dc8704f18c1bd91c3ceb" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/amphp/byte-stream/zipball/408a3b4fc4f4c7604575dc8704f18c1bd91c3ceb", - "reference": "408a3b4fc4f4c7604575dc8704f18c1bd91c3ceb", - "shasum": "" - }, - "require": { - "amphp/amp": "^3", - "amphp/parser": "^1.1", - "amphp/pipeline": "^1", - "amphp/serialization": "^1", - "amphp/sync": "^2", - "php": ">=8.1", - "revolt/event-loop": "^1 || ^0.2.3" - }, - "require-dev": { - "amphp/php-cs-fixer-config": "^2", - "amphp/phpunit-util": "^3", - "phpunit/phpunit": "^9", - "psalm/phar": "^5.4" - }, - "type": "library", - "autoload": { - "files": [ - "src/functions.php", - "src/Internal/functions.php" - ], - "psr-4": { - "Amp\\ByteStream\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Aaron Piotrowski", - "email": "aaron@trowski.com" - }, - { - "name": "Niklas Keller", - "email": "me@kelunik.com" - } - ], - "description": "A stream abstraction to make working with non-blocking I/O simple.", - "homepage": "https://amphp.org/byte-stream", - "keywords": [ - "amp", - "amphp", - "async", - "io", - "non-blocking", - "stream" - ], - "support": { - "issues": "https://github.com/amphp/byte-stream/issues", - "source": "https://github.com/amphp/byte-stream/tree/v2.0.2" - }, - "funding": [ - { - "url": "https://github.com/amphp", - "type": "github" - } - ], - "time": "2023-09-01T04:41:26+00:00" - }, - { - "name": "amphp/cache", - "version": "v2.0.0", - "source": { - "type": "git", - "url": "https://github.com/amphp/cache.git", - "reference": "218bb3888d380eb9dd926cd06f803573c84391d3" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/amphp/cache/zipball/218bb3888d380eb9dd926cd06f803573c84391d3", - "reference": "218bb3888d380eb9dd926cd06f803573c84391d3", - "shasum": "" - }, - "require": { - "amphp/amp": "^3", - "amphp/serialization": "^1", - "amphp/sync": "^2", - "php": ">=8.1", - "revolt/event-loop": "^1 || ^0.2" - }, - "require-dev": { - "amphp/php-cs-fixer-config": "^2", - "amphp/phpunit-util": "^3", - "phpunit/phpunit": "^9", - "psalm/phar": "^5.4" - }, - "type": "library", - "autoload": { - "psr-4": { - "Amp\\Cache\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Niklas Keller", - "email": "me@kelunik.com" - }, - { - "name": "Aaron Piotrowski", - "email": "aaron@trowski.com" - }, - { - "name": "Daniel Lowrey", - "email": "rdlowrey@php.net" - } - ], - "description": "A fiber-aware cache API based on Amp and Revolt.", - "homepage": "https://amphp.org/cache", - "support": { - "issues": "https://github.com/amphp/cache/issues", - "source": "https://github.com/amphp/cache/tree/v2.0.0" - }, - "funding": [ - { - "url": "https://github.com/amphp", - "type": "github" - } - ], - "time": "2023-01-09T21:04:12+00:00" - }, - { - "name": "amphp/dns", - "version": "v2.0.1", - "source": { - "type": "git", - "url": "https://github.com/amphp/dns.git", - "reference": "e42876aa8306c754abd1b3e71a44e13066909fd1" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/amphp/dns/zipball/e42876aa8306c754abd1b3e71a44e13066909fd1", - "reference": "e42876aa8306c754abd1b3e71a44e13066909fd1", - "shasum": "" - }, - "require": { - "amphp/amp": "^3", - "amphp/byte-stream": "^2", - "amphp/cache": "^2", - "amphp/parser": "^1", - "amphp/windows-registry": "^1", - "daverandom/libdns": "^2.0.2", - "ext-filter": "*", - "php": ">=8.1", - "revolt/event-loop": "^1 || ^0.2" - }, - "require-dev": { - "amphp/php-cs-fixer-config": "^2", - "amphp/phpunit-util": "^3", - "phpunit/phpunit": "^9", - "psalm/phar": "^5.4" - }, - "type": "library", - "autoload": { - "files": [ - "src/functions.php" - ], - "psr-4": { - "Amp\\Dns\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Chris Wright", - "email": "addr@daverandom.com" - }, - { - "name": "Daniel Lowrey", - "email": "rdlowrey@php.net" - }, - { - "name": "Bob Weinand", - "email": "bobwei9@hotmail.com" - }, - { - "name": "Niklas Keller", - "email": "me@kelunik.com" - }, - { - "name": "Aaron Piotrowski", - "email": "aaron@trowski.com" - } - ], - "description": "Async DNS resolution for Amp.", - "homepage": "https://github.com/amphp/dns", - "keywords": [ - "amp", - "amphp", - "async", - "client", - "dns", - "resolve" - ], - "support": { - "issues": "https://github.com/amphp/dns/issues", - "source": "https://github.com/amphp/dns/tree/v2.0.1" - }, - "funding": [ - { - "url": "https://github.com/amphp", - "type": "github" - } - ], - "time": "2023-01-21T16:00:09+00:00" - }, - { - "name": "amphp/parser", - "version": "v1.1.0", - "source": { - "type": "git", - "url": "https://github.com/amphp/parser.git", - "reference": "ff1de4144726c5dad5fab97f66692ebe8de3e151" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/amphp/parser/zipball/ff1de4144726c5dad5fab97f66692ebe8de3e151", - "reference": "ff1de4144726c5dad5fab97f66692ebe8de3e151", - "shasum": "" - }, - "require": { - "php": ">=7.4" - }, - "require-dev": { - "amphp/php-cs-fixer-config": "^2", - "phpunit/phpunit": "^9", - "psalm/phar": "^5.4" - }, - "type": "library", - "autoload": { - "psr-4": { - "Amp\\Parser\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Aaron Piotrowski", - "email": "aaron@trowski.com" - }, - { - "name": "Niklas Keller", - "email": "me@kelunik.com" - } - ], - "description": "A generator parser to make streaming parsers simple.", - "homepage": "https://github.com/amphp/parser", - "keywords": [ - "async", - "non-blocking", - "parser", - "stream" - ], - "support": { - "issues": "https://github.com/amphp/parser/issues", - "source": "https://github.com/amphp/parser/tree/v1.1.0" - }, - "funding": [ - { - "url": "https://github.com/amphp", - "type": "github" - } - ], - "time": "2022-12-30T18:08:47+00:00" - }, - { - "name": "amphp/pipeline", - "version": "v1.0.0", - "source": { - "type": "git", - "url": "https://github.com/amphp/pipeline.git", - "reference": "810dee498d2fd7d2c9247b32d95f38c92c13169e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/amphp/pipeline/zipball/810dee498d2fd7d2c9247b32d95f38c92c13169e", - "reference": "810dee498d2fd7d2c9247b32d95f38c92c13169e", - "shasum": "" - }, - "require": { - "amphp/amp": "^3", - "php": ">=8.1", - "revolt/event-loop": "^1 || ^0.2" - }, - "require-dev": { - "amphp/php-cs-fixer-config": "^2", - "amphp/phpunit-util": "^3", - "phpunit/phpunit": "^9", - "psalm/phar": "^4.12" - }, - "type": "library", - "autoload": { - "psr-4": { - "Amp\\Pipeline\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Aaron Piotrowski", - "email": "aaron@trowski.com" - }, - { - "name": "Niklas Keller", - "email": "me@kelunik.com" - } - ], - "description": "Asynchronous iterators and operators.", - "homepage": "https://amphp.org/pipeline", - "keywords": [ - "amp", - "amphp", - "async", - "io", - "iterator", - "non-blocking" - ], - "support": { - "issues": "https://github.com/amphp/pipeline/issues", - "source": "https://github.com/amphp/pipeline/tree/v1.0.0" - }, - "funding": [ - { - "url": "https://github.com/amphp", - "type": "github" - } - ], - "time": "2022-12-22T02:13:01+00:00" - }, - { - "name": "amphp/process", - "version": "v2.0.1", - "source": { - "type": "git", - "url": "https://github.com/amphp/process.git", - "reference": "a65d3bc1f36ef12d44df42a68f0f0643183f1052" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/amphp/process/zipball/a65d3bc1f36ef12d44df42a68f0f0643183f1052", - "reference": "a65d3bc1f36ef12d44df42a68f0f0643183f1052", - "shasum": "" - }, - "require": { - "amphp/amp": "^3", - "amphp/byte-stream": "^2", - "amphp/sync": "^2", - "php": ">=8.1", - "revolt/event-loop": "^1 || ^0.2" - }, - "require-dev": { - "amphp/php-cs-fixer-config": "^2", - "amphp/phpunit-util": "^3", - "phpunit/phpunit": "^9", - "psalm/phar": "^5.4" - }, - "type": "library", - "autoload": { - "files": [ - "src/functions.php" - ], - "psr-4": { - "Amp\\Process\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Bob Weinand", - "email": "bobwei9@hotmail.com" - }, - { - "name": "Aaron Piotrowski", - "email": "aaron@trowski.com" - }, - { - "name": "Niklas Keller", - "email": "me@kelunik.com" - } - ], - "description": "A fiber-aware process manager based on Amp and Revolt.", - "homepage": "https://amphp.org/process", - "support": { - "issues": "https://github.com/amphp/process/issues", - "source": "https://github.com/amphp/process/tree/v2.0.1" - }, - "funding": [ - { - "url": "https://github.com/amphp", - "type": "github" - } - ], - "time": "2023-01-15T16:00:57+00:00" - }, - { - "name": "amphp/serialization", - "version": "v1.0.0", - "source": { - "type": "git", - "url": "https://github.com/amphp/serialization.git", - "reference": "693e77b2fb0b266c3c7d622317f881de44ae94a1" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/amphp/serialization/zipball/693e77b2fb0b266c3c7d622317f881de44ae94a1", - "reference": "693e77b2fb0b266c3c7d622317f881de44ae94a1", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "require-dev": { - "amphp/php-cs-fixer-config": "dev-master", - "phpunit/phpunit": "^9 || ^8 || ^7" - }, - "type": "library", - "autoload": { - "files": [ - "src/functions.php" - ], - "psr-4": { - "Amp\\Serialization\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Aaron Piotrowski", - "email": "aaron@trowski.com" - }, - { - "name": "Niklas Keller", - "email": "me@kelunik.com" - } - ], - "description": "Serialization tools for IPC and data storage in PHP.", - "homepage": "https://github.com/amphp/serialization", - "keywords": [ - "async", - "asynchronous", - "serialization", - "serialize" - ], - "support": { - "issues": "https://github.com/amphp/serialization/issues", - "source": "https://github.com/amphp/serialization/tree/master" - }, - "time": "2020-03-25T21:39:07+00:00" - }, - { - "name": "amphp/socket", - "version": "v2.2.0", - "source": { - "type": "git", - "url": "https://github.com/amphp/socket.git", - "reference": "3418a0c5c0d4978b0e8e0619ce1da0851c4053d3" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/amphp/socket/zipball/3418a0c5c0d4978b0e8e0619ce1da0851c4053d3", - "reference": "3418a0c5c0d4978b0e8e0619ce1da0851c4053d3", - "shasum": "" - }, - "require": { - "amphp/amp": "^3", - "amphp/byte-stream": "^2", - "amphp/dns": "^2", - "ext-openssl": "*", - "kelunik/certificate": "^1.1", - "league/uri": "^6.5 | ^7", - "league/uri-interfaces": "^2.3 | ^7", - "php": ">=8.1", - "revolt/event-loop": "^1 || ^0.2" - }, - "require-dev": { - "amphp/php-cs-fixer-config": "^2", - "amphp/phpunit-util": "^3", - "amphp/process": "^2", - "phpunit/phpunit": "^9", - "psalm/phar": "^5.4" - }, - "type": "library", - "autoload": { - "files": [ - "src/functions.php", - "src/Internal/functions.php", - "src/SocketAddress/functions.php" - ], - "psr-4": { - "Amp\\Socket\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Daniel Lowrey", - "email": "rdlowrey@gmail.com" - }, - { - "name": "Aaron Piotrowski", - "email": "aaron@trowski.com" - }, - { - "name": "Niklas Keller", - "email": "me@kelunik.com" - } - ], - "description": "Non-blocking socket connection / server implementations based on Amp and Revolt.", - "homepage": "https://github.com/amphp/socket", - "keywords": [ - "amp", - "async", - "encryption", - "non-blocking", - "sockets", - "tcp", - "tls" - ], - "support": { - "issues": "https://github.com/amphp/socket/issues", - "source": "https://github.com/amphp/socket/tree/v2.2.0" - }, - "funding": [ - { - "url": "https://github.com/amphp", - "type": "github" - } - ], - "time": "2023-08-19T15:28:34+00:00" - }, - { - "name": "amphp/sync", - "version": "v2.1.0", - "source": { - "type": "git", - "url": "https://github.com/amphp/sync.git", - "reference": "50ddc7392cc8034b3e4798cef3cc90d3f4c0441c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/amphp/sync/zipball/50ddc7392cc8034b3e4798cef3cc90d3f4c0441c", - "reference": "50ddc7392cc8034b3e4798cef3cc90d3f4c0441c", - "shasum": "" - }, - "require": { - "amphp/amp": "^3", - "amphp/pipeline": "^1", - "amphp/serialization": "^1", - "php": ">=8.1", - "revolt/event-loop": "^1 || ^0.2" - }, - "require-dev": { - "amphp/php-cs-fixer-config": "^2", - "amphp/phpunit-util": "^3", - "phpunit/phpunit": "^9", - "psalm/phar": "^5.4" - }, - "type": "library", - "autoload": { - "files": [ - "src/functions.php" - ], - "psr-4": { - "Amp\\Sync\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Aaron Piotrowski", - "email": "aaron@trowski.com" - }, - { - "name": "Niklas Keller", - "email": "me@kelunik.com" - }, - { - "name": "Stephen Coakley", - "email": "me@stephencoakley.com" - } - ], - "description": "Non-blocking synchronization primitives for PHP based on Amp and Revolt.", - "homepage": "https://github.com/amphp/sync", - "keywords": [ - "async", - "asynchronous", - "mutex", - "semaphore", - "synchronization" - ], - "support": { - "issues": "https://github.com/amphp/sync/issues", - "source": "https://github.com/amphp/sync/tree/v2.1.0" - }, - "funding": [ - { - "url": "https://github.com/amphp", - "type": "github" - } - ], - "time": "2023-08-19T13:53:40+00:00" - }, - { - "name": "amphp/windows-registry", - "version": "v1.0.0", - "source": { - "type": "git", - "url": "https://github.com/amphp/windows-registry.git", - "reference": "8248247a41af7f97b88e4716c0f8de39696ef111" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/amphp/windows-registry/zipball/8248247a41af7f97b88e4716c0f8de39696ef111", - "reference": "8248247a41af7f97b88e4716c0f8de39696ef111", - "shasum": "" - }, - "require": { - "amphp/byte-stream": "^2", - "amphp/process": "^2", - "php": ">=8.1" - }, - "require-dev": { - "amphp/php-cs-fixer-config": "^2", - "psalm/phar": "^5.4" - }, - "type": "library", - "autoload": { - "psr-4": { - "Amp\\WindowsRegistry\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Niklas Keller", - "email": "me@kelunik.com" - } - ], - "description": "Windows Registry Reader.", - "support": { - "issues": "https://github.com/amphp/windows-registry/issues", - "source": "https://github.com/amphp/windows-registry/tree/v1.0.0" - }, - "funding": [ - { - "url": "https://github.com/amphp", - "type": "github" - } - ], - "time": "2023-01-09T22:29:20+00:00" - }, - { - "name": "daverandom/libdns", - "version": "v2.0.3", - "source": { - "type": "git", - "url": "https://github.com/DaveRandom/LibDNS.git", - "reference": "42c2d700d1178c9f9e78664793463f7f1aea248c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/DaveRandom/LibDNS/zipball/42c2d700d1178c9f9e78664793463f7f1aea248c", - "reference": "42c2d700d1178c9f9e78664793463f7f1aea248c", - "shasum": "" - }, - "require": { - "ext-ctype": "*", - "php": ">=7.0" - }, - "suggest": { - "ext-intl": "Required for IDN support" - }, - "type": "library", - "autoload": { - "files": [ - "src/functions.php" - ], - "psr-4": { - "LibDNS\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "DNS protocol implementation written in pure PHP", - "keywords": [ - "dns" - ], - "support": { - "issues": "https://github.com/DaveRandom/LibDNS/issues", - "source": "https://github.com/DaveRandom/LibDNS/tree/v2.0.3" - }, - "time": "2022-09-20T18:15:38+00:00" - }, - { - "name": "kelunik/certificate", - "version": "v1.1.3", - "source": { - "type": "git", - "url": "https://github.com/kelunik/certificate.git", - "reference": "7e00d498c264d5eb4f78c69f41c8bd6719c0199e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/kelunik/certificate/zipball/7e00d498c264d5eb4f78c69f41c8bd6719c0199e", - "reference": "7e00d498c264d5eb4f78c69f41c8bd6719c0199e", - "shasum": "" - }, - "require": { - "ext-openssl": "*", - "php": ">=7.0" - }, - "require-dev": { - "amphp/php-cs-fixer-config": "^2", - "phpunit/phpunit": "^6 | 7 | ^8 | ^9" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.x-dev" - } - }, - "autoload": { - "psr-4": { - "Kelunik\\Certificate\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Niklas Keller", - "email": "me@kelunik.com" - } - ], - "description": "Access certificate details and transform between different formats.", - "keywords": [ - "DER", - "certificate", - "certificates", - "openssl", - "pem", - "x509" - ], - "support": { - "issues": "https://github.com/kelunik/certificate/issues", - "source": "https://github.com/kelunik/certificate/tree/v1.1.3" - }, - "time": "2023-02-03T21:26:53+00:00" - }, - { - "name": "league/uri", - "version": "7.2.1", - "source": { - "type": "git", - "url": "https://github.com/thephpleague/uri.git", - "reference": "8b644f8ff80352530bbc0ea467d5b5a89b60d832" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/thephpleague/uri/zipball/8b644f8ff80352530bbc0ea467d5b5a89b60d832", - "reference": "8b644f8ff80352530bbc0ea467d5b5a89b60d832", - "shasum": "" - }, - "require": { - "league/uri-interfaces": "^7.2", - "php": "^8.1" - }, - "conflict": { - "league/uri-schemes": "^1.0" - }, - "suggest": { - "ext-bcmath": "to improve IPV4 host parsing", - "ext-fileinfo": "to create Data URI from file contennts", - "ext-gmp": "to improve IPV4 host parsing", - "ext-intl": "to handle IDN host with the best performance", - "jeremykendall/php-domain-parser": "to resolve Public Suffix and Top Level Domain", - "league/uri-components": "Needed to easily manipulate URI objects components", - "php-64bit": "to improve IPV4 host parsing", - "symfony/polyfill-intl-idn": "to handle IDN host via the Symfony polyfill if ext-intl is not present" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "7.x-dev" - } - }, - "autoload": { - "psr-4": { - "League\\Uri\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Ignace Nyamagana Butera", - "email": "nyamsprod@gmail.com", - "homepage": "https://nyamsprod.com" - } - ], - "description": "URI manipulation library", - "homepage": "https://uri.thephpleague.com", - "keywords": [ - "data-uri", - "file-uri", - "ftp", - "hostname", - "http", - "https", - "middleware", - "parse_str", - "parse_url", - "psr-7", - "query-string", - "querystring", - "rfc3986", - "rfc3987", - "rfc6570", - "uri", - "uri-template", - "url", - "ws" - ], - "support": { - "docs": "https://uri.thephpleague.com", - "forum": "https://thephpleague.slack.com", - "issues": "https://github.com/thephpleague/uri-src/issues", - "source": "https://github.com/thephpleague/uri/tree/7.2.1" - }, - "funding": [ - { - "url": "https://github.com/sponsors/nyamsprod", - "type": "github" - } - ], - "time": "2023-08-30T21:06:57+00:00" - }, - { - "name": "league/uri-interfaces", - "version": "7.2.0", - "source": { - "type": "git", - "url": "https://github.com/thephpleague/uri-interfaces.git", - "reference": "43fa071050fcba89aefb5d4789a4a5a73874c44b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/thephpleague/uri-interfaces/zipball/43fa071050fcba89aefb5d4789a4a5a73874c44b", - "reference": "43fa071050fcba89aefb5d4789a4a5a73874c44b", - "shasum": "" - }, - "require": { - "ext-filter": "*", - "php": "^8.1", - "psr/http-factory": "^1", - "psr/http-message": "^1.1 || ^2.0" - }, - "suggest": { - "ext-bcmath": "to improve IPV4 host parsing", - "ext-gmp": "to improve IPV4 host parsing", - "ext-intl": "to handle IDN host with the best performance", - "php-64bit": "to improve IPV4 host parsing", - "symfony/polyfill-intl-idn": "to handle IDN host via the Symfony polyfill if ext-intl is not present" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "7.x-dev" - } - }, - "autoload": { - "psr-4": { - "League\\Uri\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Ignace Nyamagana Butera", - "email": "nyamsprod@gmail.com", - "homepage": "https://nyamsprod.com" - } - ], - "description": "Common interfaces and classes for URI representation and interaction", - "homepage": "https://uri.thephpleague.com", - "keywords": [ - "data-uri", - "file-uri", - "ftp", - "hostname", - "http", - "https", - "parse_str", - "parse_url", - "psr-7", - "query-string", - "querystring", - "rfc3986", - "rfc3987", - "rfc6570", - "uri", - "url", - "ws" - ], - "support": { - "docs": "https://uri.thephpleague.com", - "forum": "https://thephpleague.slack.com", - "issues": "https://github.com/thephpleague/uri-src/issues", - "source": "https://github.com/thephpleague/uri-interfaces/tree/7.2.0" - }, - "funding": [ - { - "url": "https://github.com/sponsors/nyamsprod", - "type": "github" - } - ], - "time": "2023-08-30T19:43:38+00:00" - }, - { - "name": "psr/http-factory", - "version": "1.0.2", - "source": { - "type": "git", - "url": "https://github.com/php-fig/http-factory.git", - "reference": "e616d01114759c4c489f93b099585439f795fe35" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/http-factory/zipball/e616d01114759c4c489f93b099585439f795fe35", - "reference": "e616d01114759c4c489f93b099585439f795fe35", - "shasum": "" - }, - "require": { - "php": ">=7.0.0", - "psr/http-message": "^1.0 || ^2.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Http\\Message\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "https://www.php-fig.org/" - } - ], - "description": "Common interfaces for PSR-7 HTTP message factories", - "keywords": [ - "factory", - "http", - "message", - "psr", - "psr-17", - "psr-7", - "request", - "response" - ], - "support": { - "source": "https://github.com/php-fig/http-factory/tree/1.0.2" - }, - "time": "2023-04-10T20:10:41+00:00" - }, - { - "name": "psr/http-message", - "version": "2.0", - "source": { - "type": "git", - "url": "https://github.com/php-fig/http-message.git", - "reference": "402d35bcb92c70c026d1a6a9883f06b2ead23d71" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/http-message/zipball/402d35bcb92c70c026d1a6a9883f06b2ead23d71", - "reference": "402d35bcb92c70c026d1a6a9883f06b2ead23d71", - "shasum": "" - }, - "require": { - "php": "^7.2 || ^8.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Http\\Message\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "https://www.php-fig.org/" - } - ], - "description": "Common interface for HTTP messages", - "homepage": "https://github.com/php-fig/http-message", - "keywords": [ - "http", - "http-message", - "psr", - "psr-7", - "request", - "response" - ], - "support": { - "source": "https://github.com/php-fig/http-message/tree/2.0" - }, - "time": "2023-04-04T09:54:51+00:00" - }, - { - "name": "revolt/event-loop", - "version": "v1.0.3", - "source": { - "type": "git", - "url": "https://github.com/revoltphp/event-loop.git", - "reference": "0fe2d31e1cddd26664e55d383d3d5da613334c03" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/revoltphp/event-loop/zipball/0fe2d31e1cddd26664e55d383d3d5da613334c03", - "reference": "0fe2d31e1cddd26664e55d383d3d5da613334c03", - "shasum": "" - }, - "require": { - "php": ">=8.1" - }, - "require-dev": { - "ext-json": "*", - "jetbrains/phpstorm-stubs": "^2019.3", - "phpunit/phpunit": "^9", - "psalm/phar": "^4.7" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.x-dev" - } - }, - "autoload": { - "psr-4": { - "Revolt\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Aaron Piotrowski", - "email": "aaron@trowski.com" - }, - { - "name": "Cees-Jan Kiewiet", - "email": "ceesjank@gmail.com" - }, - { - "name": "Christian Lück", - "email": "christian@clue.engineering" - }, - { - "name": "Niklas Keller", - "email": "me@kelunik.com" - } - ], - "description": "Rock-solid event loop for concurrent PHP applications.", - "keywords": [ - "async", - "asynchronous", - "concurrency", - "event", - "event-loop", - "non-blocking", - "scheduler" - ], - "support": { - "issues": "https://github.com/revoltphp/event-loop/issues", - "source": "https://github.com/revoltphp/event-loop/tree/v1.0.3" - }, - "time": "2023-07-29T17:07:12+00:00" - }, - { - "name": "webmozart/assert", - "version": "1.11.0", - "source": { - "type": "git", - "url": "https://github.com/webmozarts/assert.git", - "reference": "11cb2199493b2f8a3b53e7f19068fc6aac760991" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/webmozarts/assert/zipball/11cb2199493b2f8a3b53e7f19068fc6aac760991", - "reference": "11cb2199493b2f8a3b53e7f19068fc6aac760991", - "shasum": "" - }, - "require": { - "ext-ctype": "*", - "php": "^7.2 || ^8.0" - }, - "conflict": { - "phpstan/phpstan": "<0.12.20", - "vimeo/psalm": "<4.6.1 || 4.6.2" - }, - "require-dev": { - "phpunit/phpunit": "^8.5.13" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.10-dev" - } - }, - "autoload": { - "psr-4": { - "Webmozart\\Assert\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Bernhard Schussek", - "email": "bschussek@gmail.com" - } - ], - "description": "Assertions to validate method input/output with nice error messages.", - "keywords": [ - "assert", - "check", - "validate" - ], - "support": { - "issues": "https://github.com/webmozarts/assert/issues", - "source": "https://github.com/webmozarts/assert/tree/1.11.0" - }, - "time": "2022-06-03T18:03:27+00:00" - } - ], - "packages-dev": [], - "aliases": [], - "minimum-stability": "stable", - "stability-flags": [], - "prefer-stable": false, - "prefer-lowest": false, - "platform": { - "php-64bit": ">=8.1.17" - }, - "platform-dev": [], - "plugin-api-version": "2.3.0" -} diff --git a/src/Attribute.php b/src/Attribute.php index 21a5218..b796edd 100644 --- a/src/Attribute.php +++ b/src/Attribute.php @@ -1,9 +1,8 @@ -writeAttr($transactionId); - return pack('n', $this::TYPE).strlen($data).$data.str_repeat("\0", 4 - (strlen($data) % 4)); + return \pack('n', $this::TYPE).\strlen($data).$data.\str_repeat("\0", 4 - (\strlen($data) % 4)); } - public static function read(BufferedReader $reader, int &$totalLength, string $transactionId, ?Cancellation $cancellation = null): ?self { + public static function read(BufferedReader $reader, int &$totalLength, string $transactionId, ?Cancellation $cancellation = null): ?self + { $totalLength -= 4; Assert::true($totalLength >= 0); - $r = unpack('n*', $reader->readLength(4, $cancellation)); + $r = \unpack('n*', $reader->readLength(4, $cancellation)); $type = $r[1]; $length = $r[2]; $result = match ($type) { @@ -45,7 +47,7 @@ abstract class Attribute { XorMappedAddress::TYPE => XorMappedAddress::class, default => null, }; - + $left = self::posmod($length, 4); $totalLength -= $length + $left; Assert::true($totalLength >= 0); @@ -55,8 +57,9 @@ abstract class Attribute { } else { $reader->readLength($length, $cancellation); } - if ($left) - $reader->readLength($left, $cancellation); + if ($left) { + $reader->readLength($left, $cancellation); + } return $result; } diff --git a/src/Attributes/ErrorCode.php b/src/Attributes/ErrorCode.php index 8022347..d339ff3 100644 --- a/src/Attributes/ErrorCode.php +++ b/src/Attributes/ErrorCode.php @@ -1,19 +1,17 @@ -readLength(2, $cancellation); - $class = ord($reader->readLength(1, $cancellation)); - $number = ord($reader->readLength(1, $cancellation)); + $class = \ord($reader->readLength(1, $cancellation)); + $number = \ord($reader->readLength(1, $cancellation)); Assert::true($class >= 3); Assert::true($class <= 6); Assert::true($number < 100); @@ -39,6 +36,6 @@ final class ErrorCode extends Attribute { { $number = $this->err % 100; $class = $this->err - $number; - return "\0\0".chr($class).chr($number).$this->reason; + return "\0\0".\chr($class).\chr($number).$this->reason; } -} \ No newline at end of file +} diff --git a/src/Attributes/Fingerprint.php b/src/Attributes/Fingerprint.php index 4daf5e1..4445772 100644 --- a/src/Attributes/Fingerprint.php +++ b/src/Attributes/Fingerprint.php @@ -1,25 +1,22 @@ -crc ^ self::XOR; } -} \ No newline at end of file +} diff --git a/src/Attributes/MappedAddress.php b/src/Attributes/MappedAddress.php index 719e8cb..b92c54d 100644 --- a/src/Attributes/MappedAddress.php +++ b/src/Attributes/MappedAddress.php @@ -1,9 +1,8 @@ -= 8, "Wrong length!"); $reader->readLength(1, $cancellation); - $len = match (ord($reader->readLength(1, $cancellation))) { - 1 => 4, + $len = match (\ord($reader->readLength(1, $cancellation))) { + 1 => 4, 2 => 16 }; Assert::eq($len+4, $length, "Wrong length!"); - $port = unpack('n', $reader->readLength(2, $cancellation))[1]; + $port = \unpack('n', $reader->readLength(2, $cancellation))[1]; $ip = $reader->readLength($len); return new self(new InternetAddress( - inet_ntop($ip), + \inet_ntop($ip), $port )); } - protected function writeAttr(string $_): string { + protected function writeAttr(string $_): string + { $addr = $this->address->getAddressBytes(); - return "\0".(strlen($addr) === 4 ? 1 : 16).pack('n', $this->address->getPort()).$addr; + return "\0".(\strlen($addr) === 4 ? 1 : 16).\pack('n', $this->address->getPort()).$addr; } -} \ No newline at end of file +} diff --git a/src/Attributes/MessageIntegrity.php b/src/Attributes/MessageIntegrity.php index 19009cb..42702f0 100644 --- a/src/Attributes/MessageIntegrity.php +++ b/src/Attributes/MessageIntegrity.php @@ -1,24 +1,21 @@ -hmac; } -} \ No newline at end of file +} diff --git a/src/Attributes/Software.php b/src/Attributes/Software.php index d250a4f..95f6872 100644 --- a/src/Attributes/Software.php +++ b/src/Attributes/Software.php @@ -1,24 +1,20 @@ -software; } -} \ No newline at end of file +} diff --git a/src/Attributes/Username.php b/src/Attributes/Username.php index a3fafd7..944ac2e 100644 --- a/src/Attributes/Username.php +++ b/src/Attributes/Username.php @@ -1,24 +1,20 @@ -username; } -} \ No newline at end of file +} diff --git a/src/Attributes/XorMappedAddress.php b/src/Attributes/XorMappedAddress.php index b9f6e6f..1fb2ed9 100644 --- a/src/Attributes/XorMappedAddress.php +++ b/src/Attributes/XorMappedAddress.php @@ -1,54 +1,53 @@ -readLength(1, $cancellation); - $type = ord($reader->readLength(1, $cancellation)); - $port = unpack('n', $reader->readLength(2, $cancellation) ^ substr(Message::MAGIC_COOKIE, 2))[1]; + $type = \ord($reader->readLength(1, $cancellation)); + $port = \unpack('n', $reader->readLength(2, $cancellation) ^ \substr(Message::MAGIC_COOKIE, 2))[1]; $ip = match ($type) { - 1 => $reader->readLength($len = 4, $cancellation) ^ Message::MAGIC_COOKIE, + 1 => $reader->readLength($len = 4, $cancellation) ^ Message::MAGIC_COOKIE, 2 => $reader->readLength($len = 16, $cancellation) ^ (Message::MAGIC_COOKIE.$transactionId) }; Assert::eq($len+4, $length); return new self(new InternetAddress( - inet_ntop($ip), + \inet_ntop($ip), $port )); } - protected function writeAttr(string $transactionId): string { + protected function writeAttr(string $transactionId): string + { $addr = $this->address->getAddressBytes(); - if (strlen($addr) === 4) { + if (\strlen($addr) === 4) { $addr ^= Message::MAGIC_COOKIE; } else { $addr ^= Message::MAGIC_COOKIE.$transactionId; } - return "\0".(strlen($addr) === 4 ? 1 : 16).(pack('n', $this->address->getPort()) ^ substr(Message::MAGIC_COOKIE, 2)).$addr; + return "\0".(\strlen($addr) === 4 ? 1 : 16).(\pack('n', $this->address->getPort()) ^ \substr(Message::MAGIC_COOKIE, 2)).$addr; } -} \ No newline at end of file +} diff --git a/src/Message.php b/src/Message.php index 451b904..3421b76 100644 --- a/src/Message.php +++ b/src/Message.php @@ -1,4 +1,4 @@ - */ public readonly array $attributes, public readonly string $transactionId - ) - { - Assert::true(strlen($transactionId) === 12); + ) { + Assert::true(\strlen($transactionId) === 12); } - public function write(WritableStream $writer): void { + public function write(WritableStream $writer): void + { $attributes = ''; foreach ($this->attributes as $attr) { $attributes .= $attr->write($this->transactionId); } $writer->write( - pack('nn', $this->method->value | $this->class->value, strlen($attributes)). + \pack('nn', $this->method->value | $this->class->value, \strlen($attributes)). self::MAGIC_COOKIE.$this->transactionId.$attributes ); } - public static function read(BufferedReader $reader, ?Cancellation $cancellation = null): self { - $type = unpack('n', $reader->readLength(2, $cancellation))[1]; - $length = unpack('n', $reader->readLength(2, $cancellation))[1]; + public static function read(BufferedReader $reader, ?Cancellation $cancellation = null): self + { + $type = \unpack('n', $reader->readLength(2, $cancellation))[1]; + $length = \unpack('n', $reader->readLength(2, $cancellation))[1]; Assert::eq($length % 4, 0); Assert::eq($reader->readLength(4, $cancellation), self::MAGIC_COOKIE, "Wrong magic cookie!"); $transactionId = $reader->readLength(12, $cancellation); @@ -41,7 +43,7 @@ final class Message { while ($length) { $attributes []= Attribute::read($reader, $length, $transactionId, $cancellation); } - + return new self( MessageMethod::from($type & MessageMethod::MASK), MessageClass::from($type & MessageClass::MASK), @@ -49,4 +51,4 @@ final class Message { $transactionId ); } -} \ No newline at end of file +} diff --git a/src/MessageClass.php b/src/MessageClass.php index dae0b09..712bf5c 100644 --- a/src/MessageClass.php +++ b/src/MessageClass.php @@ -1,12 +1,13 @@ -value; -} \ No newline at end of file +} diff --git a/src/MessageMethod.php b/src/MessageMethod.php index 79fc370..ae54dca 100644 --- a/src/MessageMethod.php +++ b/src/MessageMethod.php @@ -1,9 +1,10 @@ - */ private array $pendingOutgoing = []; public function __construct( private string $endpoint - ) - { + ) { $this->socket = connect($endpoint); } /** * @return list */ - public function bind(Attribute ...$attributes): Message { - $msg = new Message(MessageMethod::BINDING, MessageClass::REQUEST, $attributes, random_bytes(12)); + public function bind(Attribute ...$attributes): Message + { + $msg = new Message(MessageMethod::BINDING, MessageClass::REQUEST, $attributes, \random_bytes(12)); $msg->write($this->socket); $read = new ReadableBuffer($this->socket->read()); return Message::read(new BufferedReader($read)); } -} \ No newline at end of file +}