Skip to content

Commit

Permalink
Merge pull request #8 from loophp/fix-static-analysis-tools-warnings
Browse files Browse the repository at this point in the history
Fix static analysis tools warnings
  • Loading branch information
drupol authored Jul 9, 2020
2 parents 7ac3e17 + 37d1bea commit f9cb3e4
Show file tree
Hide file tree
Showing 38 changed files with 477 additions and 772 deletions.
3 changes: 2 additions & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
github: loophp
github: drupol
custom: ["https://www.paypal.me/drupol"]
22 changes: 18 additions & 4 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache dependencies
uses: actions/cache@v1
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
Expand All @@ -43,14 +43,28 @@ jobs:
run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader

- name: Run Grumphp
run: vendor/bin/grumphp run
run: vendor/bin/grumphp run --no-ansi -n
env:
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}

- name: Send PSALM data
run: vendor/bin/psalm --shepherd --stats
continue-on-error: true

- name: Scrutinizer
run: vendor/bin/ocular code-coverage:upload --format=php-clover build/logs/clover.xml
- name: Send Scrutinizer data
run: |
wget https://scrutinizer-ci.com/ocular.phar
php ocular.phar code-coverage:upload --format=php-clover build/logs/clover.xml
continue-on-error: true

- name: Infection score report
run: |
vendor/bin/infection run -j 2
continue-on-error: true

- name: PHP Insights report
run: |
rm -rf composer.lock vendor
composer require nunomaduro/phpinsights --dev
vendor/bin/phpinsights analyse src/ -n
continue-on-error: true
9 changes: 4 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@
"php": ">= 7.1.3"
},
"require-dev": {
"drupol/php-conventions": "^1.6.14",
"drupol/php-conventions": "^1.7.1",
"friends-of-phpspec/phpspec-code-coverage": "^4.3.2",
"infection/infection": "^0.13.6",
"phpspec/phpspec": "^5.1.2 || ^6.1.1",
"phpstan/phpstan": "^0.12.8",
"phpspec/phpspec": "^5.1.2 || ^6.2.1",
"phpstan/phpstan": "^0.12.32",
"phpstan/phpstan-strict-rules": "^0.12",
"scrutinizer/ocular": "^1.6",
"vimeo/psalm": "^3.8.3"
"vimeo/psalm": "^3.12.2"
},
"config": {
"sort-packages": true
Expand Down
4 changes: 1 addition & 3 deletions src/Combinator.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,11 @@

/**
* Class Combinator.
*
* @psalm-immutable
*/
abstract class Combinator implements CombinatorInterface
{
/**
* @return Closure
* @psalm-pure
*/
public static function with(): Closure
{
Expand Down
23 changes: 7 additions & 16 deletions src/Combinator/A.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,26 @@
/**
* Class A.
*
* @psalm-template AType
* @psalm-template BType
*
* @psalm-immutable
* @template AType
* @template BType
*/
final class A extends Combinator
{
/**
* @psalm-var callable(AType): BType
*
* @var callable
* @var callable(AType): BType
*/
private $f;

/**
* @psalm-var AType
*
* @var mixed
* @var AType
*/
private $x;

/**
* A constructor.
*
* @psalm-param callable(AType): BType $f
* @psalm-param AType $x
*
* @param callable $f
* @param mixed $x
* @param callable(AType): BType $f
* @param AType $x
*/
public function __construct(callable $f, $x)
{
Expand All @@ -47,7 +38,7 @@ public function __construct(callable $f, $x)
}

/**
* @psalm-return BType
* @return BType
*/
public function __invoke()
{
Expand Down
53 changes: 25 additions & 28 deletions src/Combinator/B.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,45 +10,33 @@
/**
* Class B.
*
* @psalm-template AType
* @psalm-template BType
* @psalm-template CType
*
* @psalm-immutable
* @template AType
* @template BType
* @template CType
*/
final class B extends Combinator
{
/**
* @psalm-var callable(AType): BType
*
* @var callable
* @var callable(AType): BType
*/
private $f;

/**
* @psalm-var callable(CType): AType
*
* @var callable
* @var callable(CType): AType
*/
private $g;

/**
* @psalm-var CType
*
* @var mixed
* @var CType
*/
private $x;

/**
* B constructor.
*
* @psalm-param callable(AType): BType $f
* @psalm-param callable(CType): AType $g
* @psalm-param CType $x
*
* @param callable $f
* @param callable $g
* @param mixed $x
* @param callable(AType): BType $f
* @param callable(CType): AType $g
* @param CType $x
*/
public function __construct(callable $f, callable $g, $x)
{
Expand All @@ -58,28 +46,37 @@ public function __construct(callable $f, callable $g, $x)
}

/**
* @psalm-return BType
* @return BType
*/
public function __invoke()
{
return ($this->f)(($this->g)($this->x));
}

/**
* @template AParam
* @template AReturn
* @template NewAType
* @template NewBType
* @template NewCType
*
* @param callable(AParam): AReturn $f
* @param callable(NewAType): (NewBType) $f
*
* @return Closure(callable(mixed): AParam): Closure(mixed): AReturn
* @return Closure(Closure(NewCType):(NewAType)):(Closure(NewCType):(NewBType))
*/
public static function on(callable $f): Closure
{
return
/** @param callable(mixed): AParam $g */
/**
* @param callable(NewCType):(NewAType) $g
*
* @return Closure(NewCType):(NewBType)
*/
static function (callable $g) use ($f): Closure {
return
/** @param mixed $x */
/**
* @param NewCType $x
*
* @return NewBType
*/
static function ($x) use ($f, $g) {
return (new self($f, $g, $x))();
};
Expand Down
52 changes: 22 additions & 30 deletions src/Combinator/C.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,45 +10,33 @@
/**
* Class C.
*
* @psalm-template AType
* @psalm-template BType
* @psalm-template CType
*
* @psalm-immutable
* @template AType
* @template BType
* @template CType
*/
final class C extends Combinator
{
/**
* @psalm-var callable(AType): callable(BType): CType
*
* @var callable
* @var callable(AType): callable(BType): CType
*/
private $f;

/**
* @psalm-var BType
*
* @var mixed
* @var BType
*/
private $x;

/**
* @psalm-var AType
*
* @var mixed
* @var AType
*/
private $y;

/**
* C constructor.
*
* @psalm-param callable(AType): callable(BType): CType $f
* @psalm-param BType $x
* @psalm-param AType $y
*
* @param callable $f
* @param mixed $x
* @param mixed $y
* @param callable(AType): (callable(BType): (CType)) $f
* @param BType $x
* @param AType $y
*/
public function __construct(callable $f, $x, $y)
{
Expand All @@ -58,9 +46,7 @@ public function __construct(callable $f, $x, $y)
}

/**
* @psalm-return CType
*
* @return mixed
* @return CType
*/
public function __invoke()
{
Expand All @@ -72,19 +58,25 @@ public function __invoke()
* @template NewBType
* @template NewCType
*
* @psalm-param callable(NewAType): callable(NewBType): NewCType $f
*
* @param callable(NewAType): NewCType $f
* @param callable(NewAType): (callable(NewBType): (NewCType)) $f
*
* @return Closure(NewBType): Closure(NewAType): NewCType
* @return Closure(NewBType):(Closure(NewAType):(NewCType))
*/
public static function on(callable $f): Closure
{
return
/** @param NewBType $x */
/**
* @param NewBType $x
*
* @return Closure(NewAType):(NewCType)
*/
static function ($x) use ($f): Closure {
return
/** @param NewAType $y */
/**
* @param NewAType $y
*
* @return NewCType
*/
static function ($y) use ($f, $x) {
return (new self($f, $x, $y))();
};
Expand Down
Loading

0 comments on commit f9cb3e4

Please sign in to comment.