Skip to content
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

chore: allow phpstan v1 #130

Draft
wants to merge 6 commits into
base: 5.1
Choose a base branch
from
Draft
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
14 changes: 13 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,20 @@ jobs:
matrix:
php-versions: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3']
coverage: ['pcov']
code-style: ['no']
code-analysis: ['no']
code-analysis-extensions: ['no']
include:
- php-versions: '7.1'
coverage: 'none'
code-style: 'yes'
code-analysis: 'yes'
code-analysis-extensions: 'no'
- php-versions: '8.4'
coverage: 'pcov'
code-style: 'no'
code-analysis: 'yes'
code-analysis-extensions: 'yes'
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down Expand Up @@ -50,8 +56,14 @@ jobs:
- name: Install composer dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader

- name: Extra components for phpstan v1
if: matrix.code-analysis-extensions == 'yes'
run: |
composer config --no-plugins allow-plugins.phpstan/extension-installer true
composer require --dev phpstan/phpstan-phpunit phpstan/phpstan-strict-rules phpstan/extension-installer

- name: Code Analysis (PHP CS-Fixer)
if: matrix.code-analysis == 'yes'
if: matrix.code-style == 'yes'
run: PHP_CS_FIXER_IGNORE_ENV=true php vendor/bin/php-cs-fixer fix --dry-run --diff

- name: Code Analysis (PHPStan)
Expand Down
7 changes: 4 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,14 @@
}
},
"require-dev": {
"friendsofphp/php-cs-fixer": "~2.17.1",
"phpstan/phpstan": "^0.12",
"friendsofphp/php-cs-fixer": "~2.17.1 || ^3.60",
"phpstan/phpstan": "^0.12 || ^1.1",
"phpunit/phpunit" : "^7.5 || ^8.5 || ^9.6"
},
"scripts": {
"phpstan": [
"phpstan analyse lib tests"
"phpstan analyse lib",
"phpstan analyse tests"
],
"cs-fixer": [
"php-cs-fixer fix"
Expand Down
4 changes: 2 additions & 2 deletions lib/EmitterInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function once(string $eventName, callable $callBack, int $priority = 100)
* Lastly, if there are 5 event handlers for an event. The continueCallback
* will be called at most 4 times.
*/
public function emit(string $eventName, array $arguments = [], ?callable $continueCallBack = null): bool;
public function emit(string $eventName, array $arguments = [], callable $continueCallBack = null): bool;

/**
* Returns the list of listeners for an event.
Expand All @@ -74,5 +74,5 @@ public function removeListener(string $eventName, callable $listener): bool;
* removed. If it is not specified, every listener for every event is
* removed.
*/
public function removeAllListeners(?string $eventName = null);
public function removeAllListeners(string $eventName = null);
}
4 changes: 2 additions & 2 deletions lib/EmitterTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function once(string $eventName, callable $callBack, int $priority = 100)
* Lastly, if there are 5 event handlers for an event. The continueCallback
* will be called at most 4 times.
*/
public function emit(string $eventName, array $arguments = [], ?callable $continueCallBack = null): bool
public function emit(string $eventName, array $arguments = [], callable $continueCallBack = null): bool
{
if (\is_null($continueCallBack)) {
foreach ($this->listeners($eventName) as $listener) {
Expand Down Expand Up @@ -160,7 +160,7 @@ public function removeListener(string $eventName, callable $listener): bool
* removed. If it is not specified, every listener for every event is
* removed.
*/
public function removeAllListeners(?string $eventName = null)
public function removeAllListeners(string $eventName = null)
{
if (!\is_null($eventName)) {
unset($this->listeners[$eventName]);
Expand Down
2 changes: 1 addition & 1 deletion lib/Loop/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ function stop()
/**
* Retrieves or sets the global Loop object.
*/
function instance(?Loop $newLoop = null): Loop
function instance(Loop $newLoop = null): Loop
{
static $loop;
if ($newLoop) {
Expand Down
6 changes: 3 additions & 3 deletions lib/Promise.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class Promise
* Each are callbacks that map to $this->fulfill and $this->reject.
* Using the executor is optional.
*/
public function __construct(?callable $executor = null)
public function __construct(callable $executor = null)
{
if ($executor) {
$executor(
Expand Down Expand Up @@ -87,7 +87,7 @@ public function __construct(?callable $executor = null)
* If either of the callbacks throw an exception, the returned promise will
* be rejected and the exception will be passed back.
*/
public function then(?callable $onFulfilled = null, ?callable $onRejected = null): Promise
public function then(callable $onFulfilled = null, callable $onRejected = null): Promise
{
// This new subPromise will be returned from this function, and will
// be fulfilled with the result of the onFulfilled or onRejected event
Expand Down Expand Up @@ -220,7 +220,7 @@ public function wait()
* correctly, and any chained promises are also correctly fulfilled or
* rejected.
*/
private function invokeCallback(Promise $subPromise, ?callable $callBack = null)
private function invokeCallback(Promise $subPromise, callable $callBack = null)
{
// We use 'nextTick' to ensure that the event handlers are always
// triggered outside of the calling stack in which they were originally
Expand Down
4 changes: 2 additions & 2 deletions lib/WildcardEmitterTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function once(string $eventName, callable $callBack, int $priority = 100)
* Lastly, if there are 5 event handlers for an event. The continueCallback
* will be called at most 4 times.
*/
public function emit(string $eventName, array $arguments = [], ?callable $continueCallBack = null): bool
public function emit(string $eventName, array $arguments = [], callable $continueCallBack = null): bool
{
if (\is_null($continueCallBack)) {
foreach ($this->listeners($eventName) as $listener) {
Expand Down Expand Up @@ -195,7 +195,7 @@ public function removeListener(string $eventName, callable $listener): bool
* removed. If it is not specified, every listener for every event is
* removed.
*/
public function removeAllListeners(?string $eventName = null)
public function removeAllListeners(string $eventName = null)
{
if (\is_null($eventName)) {
$this->listeners = [];
Expand Down
Loading