diff --git a/.dev/docker/php/8.5/Dockerfile b/.dev/docker/php/8.5/Dockerfile new file mode 100644 index 00000000..53f9a8bc --- /dev/null +++ b/.dev/docker/php/8.5/Dockerfile @@ -0,0 +1,13 @@ +FROM php:8.5-cli-alpine AS lyngvi-php + +RUN apk add --update linux-headers + +RUN apk add --no-cache pcre ${PHPIZE_DEPS} \ + libevent-dev openssl openssl-dev + +RUN pecl install ev xdebug + +RUN docker-php-ext-enable ev xdebug + +RUN wget https://raw.githubusercontent.com/composer/getcomposer.org/f3108f64b4e1c1ce6eb462b159956461592b3e3e/web/installer -O - -q | php -- --quiet +RUN mv /composer.phar /usr/local/bin/composer diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml index 44b73783..2f8f4e4b 100644 --- a/.github/workflows/code-quality.yml +++ b/.github/workflows/code-quality.yml @@ -7,29 +7,16 @@ on: jobs: cs: - runs-on: ubuntu-24.04 + runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - name: Install PHP 8.1 + - name: Install PHP 8.5 uses: shivammathur/setup-php@v2 with: - php-version: 8.3 + php-version: 8.5 - name: Install packages run: composer install --no-progress - name: Run CS run: composer cs - name: Verify namespaces run: bash util/verify-namespacing.sh - - phpmd: - runs-on: ubuntu-24.04 - steps: - - uses: actions/checkout@v3 - - name: Install PHP 8.1 - uses: shivammathur/setup-php@v2 - with: - php-version: 8.3 - - name: Install packages - run: composer install --no-progress - - name: Run MD - run: composer md diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 2feff648..73747252 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -8,12 +8,12 @@ on: jobs: tests: - runs-on: ubuntu-24.04 + runs-on: ubuntu-latest strategy: fail-fast: false matrix: - php: [ '8.2', '8.3', '8.4' ] + php: [ '8.5', '8.6' ] steps: - uses: actions/checkout@v3 diff --git a/composer.json b/composer.json index ea21e06e..d1f9cc1a 100644 --- a/composer.json +++ b/composer.json @@ -16,44 +16,35 @@ }, "minimum-stability": "stable", "require": { - "php": "^8.2", + "php": "^8.5", "react/event-loop": "^1.3.0", "evenement/evenement": "^3.0.0", - "nesbot/carbon": "^2.64 || ^3.0", + "nesbot/carbon": "^3.0", "discord-php/http": "^v10.3.0", "ralouphie/mimey": "^1.0", - "spatie/regex": "^3.1", "react/async": "^4.0.0", "exan/eventer": "^1.0.3", "exan/reactphp-retrier": "^2.0", - "freezemage0/array_find": "^1.0", "react/promise": "^3", "ratchet/pawl": "^0.4.3" }, "require-dev": { "monolog/monolog": "^3.2", "phpunit/phpunit": "^9.5 || ^10.0", - "phpmd/phpmd": "^2.13", "symfony/var-dumper": "^6.2 || ^7.0", "mockery/mockery": "^1.6", "friendsofphp/php-cs-fixer": "^3.20" }, "scripts": { - "md": "phpmd src text ruleset.xml", - "cs": "php-cs-fixer fix --using-cache=no --diff --dry-run --allow-risky=yes", "csf": "php-cs-fixer fix --using-cache=no --allow-risky=yes", "test": "phpunit", "test-coverage": "@php -d xdebug.mode=coverage ./vendor/bin/phpunit --coverage-html .phpunit.cache/cov-html", - "test-8.2": "docker-compose run php8.2 composer test", - "test-8.3": "docker-compose run php8.3 composer test", - "test-8.4": "docker-compose run php8.4 composer test", + "test-8.5": "docker-compose run php8.5 composer test", "test-all": [ - "composer test-8.2", - "composer test-8.3", - "composer test-8.4" + "composer test-8.5" ] }, "config": { diff --git a/docker-compose.yml b/docker-compose.yml index 95f85fc9..c3ca12d6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,10 @@ services: + php8.1: + build: ./.dev/docker/php/8.1 + volumes: + - .:/fenrir:z + working_dir: /fenrir + command: sh php8.2: build: ./.dev/docker/php/8.2 volumes: @@ -17,3 +23,9 @@ services: - .:/fenrir:z working_dir: /fenrir command: sh + php8.5: + build: ./.dev/docker/php/8.5 + volumes: + - .:/fenrir:z + working_dir: /fenrir + command: sh diff --git a/readme.md b/readme.md index ae9780dd..1b852708 100644 --- a/readme.md +++ b/readme.md @@ -88,9 +88,17 @@ For more examples, check out the examples directory ## Support -Fenrir currently supports PHP 8.2+ +Fenrir currently supports PHP 8.4+ Tests should pass nightly builds of newer versions, but this is not a supported usecase. +| PHP Version | Library version | +| ------------- | --------------- | +| 8.5+ | Current | +| 8.2, 8.3, 8.4 | < 1.2 | +| 8.1 | < 1.0.1 | + +Note: Bugfixes/features will not be backported to older versions. Older versions are as-is. + If you're using this in a Apache2/Nginx/etc webserver environment, you should probably limit yourself to only using Fenrir's REST capabilities. These environments typically don't allow long-running processes. diff --git a/ruleset.xml b/ruleset.xml deleted file mode 100644 index e4a43c7e..00000000 --- a/ruleset.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - PHPMD ruleset for Fenrir - - - src/Parts/* - src/Gateway/Events/* - src/Websocket/Objects/* - - - - - - - - - - - - - - - - - - - diff --git a/src/Command/CommandExtension.php b/src/Command/CommandExtension.php index b7de44a2..082fe557 100644 --- a/src/Command/CommandExtension.php +++ b/src/Command/CommandExtension.php @@ -15,8 +15,6 @@ use Ragnarok\Fenrir\Interaction\CommandInteraction; use Ragnarok\Fenrir\Parts\ApplicationCommandInteractionDataOptionStructure; -use function Freezemage\ArrayUtils\find; - abstract class CommandExtension extends EventEmitter implements Extension { protected FilteredEventEmitter $commandListener; @@ -61,7 +59,7 @@ protected function getFullNameByInteraction(InteractionCreate $command): string private function drillName(array $options, array &$names) { /** @var ?ApplicationCommandInteractionDataOptionStructure */ - $subCommand = find($options ?? [], function (ApplicationCommandInteractionDataOptionStructure $option) { + $subCommand = array_find($options ?? [], function (ApplicationCommandInteractionDataOptionStructure $option) { return in_array( $option->type, [ diff --git a/src/Gateway/Connection.php b/src/Gateway/Connection.php index 745c9cc3..692e43f6 100644 --- a/src/Gateway/Connection.php +++ b/src/Gateway/Connection.php @@ -31,9 +31,6 @@ use React\EventLoop\TimerInterface; use React\Promise\PromiseInterface; -/** - * @SuppressWarnings(PHPMD.TooManyPublicMethods) - */ class Connection implements ConnectionInterface { public const DISCORD_VERSION = 10; diff --git a/src/Interaction/CommandInteraction.php b/src/Interaction/CommandInteraction.php index eee67e21..3011c500 100644 --- a/src/Interaction/CommandInteraction.php +++ b/src/Interaction/CommandInteraction.php @@ -12,8 +12,6 @@ use Ragnarok\Fenrir\Rest\Helpers\Webhook\EditWebhookBuilder; use React\Promise\PromiseInterface; -use function Freezemage\ArrayUtils\find as array_find; - class CommandInteraction { /** @var OptionStructure[] */ diff --git a/src/Rest/Channel.php b/src/Rest/Channel.php index bfec86ed..bd48e07a 100644 --- a/src/Rest/Channel.php +++ b/src/Rest/Channel.php @@ -26,9 +26,6 @@ /** * @see https://discord.com/developers/docs/resources/channel * - * @SuppressWarnings(PHPMD.TooManyMethods) - * @SuppressWarnings(PHPMD.TooManyPublicMethods) - * * @todo seperate calls, `$this->reaction->create(...)` instead of `$this->createReaction(...)` etc */ class Channel extends HttpResource diff --git a/src/Rest/Guild.php b/src/Rest/Guild.php index a07e3cd6..34886b5e 100644 --- a/src/Rest/Guild.php +++ b/src/Rest/Guild.php @@ -26,11 +26,6 @@ /** * @see https://discord.com/developers/docs/resources/guild - * - * @SuppressWarnings(PHPMD.TooManyMethods) - * @SuppressWarnings(PHPMD.TooManyPublicMethods) - * @SuppressWarnings(PHPMD.ExcessivePublicCount) - * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) */ class Guild extends HttpResource { diff --git a/src/Rest/Helpers/Command/CommandBuilder.php b/src/Rest/Helpers/Command/CommandBuilder.php index 8af20591..31f9665f 100644 --- a/src/Rest/Helpers/Command/CommandBuilder.php +++ b/src/Rest/Helpers/Command/CommandBuilder.php @@ -11,7 +11,6 @@ use Ragnarok\Fenrir\Enums\InteractionContextType; use Ragnarok\Fenrir\Exceptions\Rest\Helpers\Command\InvalidCommandNameException; use Ragnarok\Fenrir\Rest\Helpers\GetNew; -use Spatie\Regex\Regex; class CommandBuilder { @@ -214,7 +213,7 @@ public function getContexts(): ?array private function isAllowedName($name): bool { - return Regex::match(Command::NAME_REGEX, $name)->hasMatch(); + return preg_match(Command::NAME_REGEX, $name) === 1; } public function get(): array diff --git a/src/Rest/HttpResource.php b/src/Rest/HttpResource.php index ad99521e..df183a44 100644 --- a/src/Rest/HttpResource.php +++ b/src/Rest/HttpResource.php @@ -8,11 +8,7 @@ use Psr\Log\LoggerInterface; use Ragnarok\Fenrir\DataMapper; use React\Promise\PromiseInterface; -use Throwable; -/** - * @SuppressWarnings(PHPMD.NumberOfChildren) - */ abstract class HttpResource { public function __construct( diff --git a/src/Rest/Rest.php b/src/Rest/Rest.php index 1278594d..71c75379 100644 --- a/src/Rest/Rest.php +++ b/src/Rest/Rest.php @@ -8,9 +8,6 @@ use Psr\Log\LoggerInterface; use Ragnarok\Fenrir\DataMapper; -/** - * @SuppressWarnings(PHPMD.TooManyFields) - */ class Rest { public readonly Application $application; diff --git a/src/Rest/Webhook.php b/src/Rest/Webhook.php index 283e6ea7..25bf6da7 100644 --- a/src/Rest/Webhook.php +++ b/src/Rest/Webhook.php @@ -17,7 +17,6 @@ /** * @see https://discord.com/developers/docs/resources/webhook - * @SuppressWarnings(PHPMD.TooManyPublicMethods) */ class Webhook extends HttpResource {