Skip to content

Upgrade language level to PHP 7.4 #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
57 changes: 57 additions & 0 deletions .php_cs.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php declare(strict_types=1);

use PhpCsFixer\Config;
use PhpCsFixer\Finder;

$finder = Finder::create()
->in(__DIR__ . '/src')
->in(__DIR__ . '/tests')
->name('*.php');

return Config::create()
->setRiskyAllowed(true)
->setUsingCache(false)
->setRules([
'@PSR2' => true,
'@Symfony' => true,
'no_useless_else' => true,
'no_useless_return' => true,
'ordered_class_elements' => true,
'ordered_imports' => true,
'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'],
'phpdoc_order' => true,
'phpdoc_summary' => false,
// Removes @param and @return tags that don't provide any useful information.
'no_superfluous_phpdoc_tags' => true,
'blank_line_after_opening_tag' => false,
'concat_space' => ['spacing' => 'one'],
'array_syntax' => ['syntax' => 'short'],
'void_return' => true,
'class_attributes_separation' => ['elements' => ['method', 'property']],
// add declare strict type to every file
'declare_strict_types' => true,
// comparisons should always be strict
'strict_comparison' => true,
// use native phpunit methods
'php_unit_construct' => true,
// Enforce camel case for PHPUnit test methods
'php_unit_method_casing' => ['case' => 'camel_case'],
'php_unit_test_case_static_method_calls' => true,
'php_unit_dedicate_assert' => ['target' => 'newest'],
'php_unit_dedicate_assert_internal_type' => true,
'php_unit_mock' => true,
'php_unit_mock_short_will_return' => true,
'yoda_style' => ['equal' => false, 'identical' => false, 'less_and_greater' => false],
// functions should be used with $strict param set to true
'strict_param' => true,
'array_indentation' => true,
'compact_nullable_typehint' => true,
'modernize_types_casting' => true,
'mb_str_functions' => true,
'general_phpdoc_annotation_remove' => [
'annotations' => ['copyright', 'category'],
],
'single_line_throw' => false,
'nullable_type_declaration_for_default_null_value' => true,
])
->setFinder($finder);
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
language: php
php:
- 5.4
- 5.3
- hhvm
- 7.4
services:
- redis-server
before_script:
Expand Down
18 changes: 10 additions & 8 deletions bin/redis-server.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<?php

declare(strict_types=1);

use Clue\Redis\Protocol\Model\ModelInterface;
use Clue\Redis\Server\Client;
use Clue\Redis\Server\Factory;
use Clue\Redis\Server\Server;
use Clue\Redis\Protocol\Model\ModelInterface;

require __DIR__ . '/../vendor/autoload.php';

Expand All @@ -13,39 +15,39 @@
// read port definition from command args
$port = 6379;
if (isset($argv[2]) && $argv[1] === '--port') {
$port = (int)$argv[2];
$port = (int) $argv[2];
}

$address = '0.0.0.0:' . $port;
$debug = false;

$factory->createServer($address)->then(function(Server $server) use ($address, $debug) {
$factory->createServer($address)->then(function (Server $server) use ($address, $debug): void {
echo 'server listening on ' . $address . '!' . PHP_EOL;

echo 'you can now connect to this server via redis-cli, redis-benchmark or any other redis client' . PHP_EOL;

if ($debug) {
echo 'Debugging is turned on, this will significantly decrease performance' . PHP_EOL;

$server->on('connection', function ($client) {
$server->on('connection', function (Client $client): void {
echo 'client connected' . PHP_EOL;
});

$server->on('error', function ($error, $client) {
$server->on('error', function ($error, Client $client): void {
echo 'ERROR: ' . $error->getMessage() . PHP_EOL;
});

$server->on('request', function (ModelInterface $request, Client $client) {
$server->on('request', function (ModelInterface $request, Client $client): void {
echo $client->getRequestDebug($request) . PHP_EOL;
});

$server->on('disconnection', function ($client) {
$server->on('disconnection', function (Client $client): void {
echo 'client disconnected' . PHP_EOL;
});
} else {
echo 'Debugging is turned off, so you should not see any further output' . PHP_EOL;
}
}, function ($e) {
}, function (\Throwable $e): void {
fwrite(STDERR, 'ERROR: Unable to start listening server: ' . $e->getMessage() . PHP_EOL);
});

Expand Down
17 changes: 14 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,28 @@
}
],
"require": {
"php": ">=5.3",
"php": ">=7.4",
"react/promise": "~1.0|~2.0",
"react/socket": "0.3.*|0.4.*",
"react/event-loop": "0.3.*|0.4.*",
"clue/redis-protocol": "0.3.*",
"evenement/evenement": "~1.0|~2.0"
},
"autoload": {
"psr-4": { "Clue\\Redis\\Server\\": "src" }
"psr-4": {
"Clue\\Redis\\Server\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"Clue\\Redis\\Server\\Tests\\": "tests"
}
},
"bin": [
"bin/redis-server.php"
]
],
"require-dev": {
"phpunit/phpunit": "^9",
"friendsofphp/php-cs-fixer": "^2.16"
}
}
Loading