Skip to content

Commit

Permalink
Merge pull request #31 from acelaya-forks/feature/remove-swoole
Browse files Browse the repository at this point in the history
Drop support for openswoole
  • Loading branch information
acelaya committed Feb 16, 2024
2 parents 5d1905e + ff0583e commit 6b287b3
Show file tree
Hide file tree
Showing 7 changed files with 1 addition and 144 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com), and this
* *Nothing*

### Fixed
* *Nothing*
* Remove support for swoole and openswoole


## [2.5.0] - 2023-11-25
Expand Down
45 changes: 0 additions & 45 deletions functions/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,18 @@
use Laminas\Config\Factory;
use Laminas\Stdlib\Glob;

use function array_combine;
use function array_filter;
use function array_keys;
use function array_map;
use function array_values;
use function extension_loaded;
use function getenv;
use function implode;
use function is_array;
use function is_numeric;
use function is_scalar;
use function putenv;
use function sprintf;
use function str_replace;
use function str_starts_with;
use function strtolower;
use function trim;

use const ARRAY_FILTER_USE_KEY;
use const PHP_SAPI;

const OPENSWOOLE_VERSION_ENV = 'OPENSWOOLE_VERSION';

function loadConfigFromGlob(string $globPattern): array
{
/** @var array $config */
Expand Down Expand Up @@ -70,40 +59,6 @@ function putNotYetDefinedEnv(string $key, mixed $value): void
putenv(sprintf('%s=%s', $key, $normalizedValue));
}

/**
* @deprecated Openswoole support to be removed in Shlink 4.0.0
*/
function getOpenswooleConfigFromEnv(): array
{
$swoolePrefix = 'OPENSWOOLE_';
$env = getenv();
$env = array_filter(
$env,
static fn (string $key) => str_starts_with($key, $swoolePrefix) && $key !== OPENSWOOLE_VERSION_ENV,
ARRAY_FILTER_USE_KEY,
);
$keys = array_map(static fn (string $key) => strtolower(str_replace($swoolePrefix, '', $key)), array_keys($env));
$values = array_map(parseEnvVar(...), array_values($env));

return array_combine($keys, $values);
}

/**
* @deprecated Openswoole support to be removed in Shlink 4.0.0
*/
function openswooleIsInstalled(): bool
{
return extension_loaded('openswoole') || extension_loaded('swoole');
}

/**
* @deprecated Openswoole support to be removed in Shlink 4.0.0
*/
function runningInOpenswoole(): bool
{
return PHP_SAPI === 'cli' && env(OPENSWOOLE_VERSION_ENV) !== null && openswooleIsInstalled();
}

function runningInRoadRunner(): bool
{
return PHP_SAPI === 'cli' && env('RR_MODE') !== null;
Expand Down
3 changes: 0 additions & 3 deletions src/ConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ public function __invoke(): array
return [

'dependencies' => [
'factories' => [
Factory\SwooleInstalledFactory::SWOOLE_INSTALLED => Factory\SwooleInstalledFactory::class,
],
'abstract_factories' => [
Factory\DottedAccessConfigAbstractFactory::class,
],
Expand Down
20 changes: 0 additions & 20 deletions src/Factory/SwooleInstalledFactory.php

This file was deleted.

4 changes: 0 additions & 4 deletions test/ConfigProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use PHPUnit\Framework\TestCase;
use Shlinkio\Shlink\Config\ConfigProvider;
use Shlinkio\Shlink\Config\Factory\DottedAccessConfigAbstractFactory;
use Shlinkio\Shlink\Config\Factory\SwooleInstalledFactory;

class ConfigProviderTest extends TestCase
{
Expand All @@ -25,9 +24,6 @@ public function configIsReturned(): void
$config = ($this->configProvider)();
self::assertArrayHasKey('dependencies', $config);
self::assertEquals([
'factories' => [
SwooleInstalledFactory::SWOOLE_INSTALLED => SwooleInstalledFactory::class,
],
'abstract_factories' => [
DottedAccessConfigAbstractFactory::class,
],
Expand Down
27 changes: 0 additions & 27 deletions test/Factory/SwooleInstalledFactoryTest.php

This file was deleted.

44 changes: 0 additions & 44 deletions test/Functions/GetOpenswooleConfigFromEnvTest.php

This file was deleted.

0 comments on commit 6b287b3

Please sign in to comment.