Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .dev/docker/php/8.5/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
19 changes: 3 additions & 16 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 4 additions & 13 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
12 changes: 12 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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
10 changes: 9 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
32 changes: 0 additions & 32 deletions ruleset.xml

This file was deleted.

4 changes: 1 addition & 3 deletions src/Command/CommandExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
[
Expand Down
3 changes: 0 additions & 3 deletions src/Gateway/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@
use React\EventLoop\TimerInterface;
use React\Promise\PromiseInterface;

/**
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
*/
class Connection implements ConnectionInterface
{
public const DISCORD_VERSION = 10;
Expand Down
2 changes: 0 additions & 2 deletions src/Interaction/CommandInteraction.php
Original file line number Diff line number Diff line change
Expand Up @@ -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[] */
Expand Down
3 changes: 0 additions & 3 deletions src/Rest/Channel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 0 additions & 5 deletions src/Rest/Guild.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
3 changes: 1 addition & 2 deletions src/Rest/Helpers/Command/CommandBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions src/Rest/HttpResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
3 changes: 0 additions & 3 deletions src/Rest/Rest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
use Psr\Log\LoggerInterface;
use Ragnarok\Fenrir\DataMapper;

/**
* @SuppressWarnings(PHPMD.TooManyFields)
*/
class Rest
{
public readonly Application $application;
Expand Down
1 change: 0 additions & 1 deletion src/Rest/Webhook.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

/**
* @see https://discord.com/developers/docs/resources/webhook
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
*/
class Webhook extends HttpResource
{
Expand Down
Loading