Skip to content

Commit

Permalink
Replaced psalm with phpstan
Browse files Browse the repository at this point in the history
  • Loading branch information
PHLAK committed Jan 11, 2023
1 parent 469c229 commit b374930
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test-suite.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
run: composer update

- name: Run Static Analysis
run: vendor/bin/psalm
run: vendor/bin/phpstan analyze --no-progress

tests:
name: Tests
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
},
"require-dev": {
"phlak/coding-standards": "^2.0",
"phpstan/phpstan": "^1.9",
"psy/psysh": "^0.11",
"vimeo/psalm": "^4.1",
"yoast/phpunit-polyfills": "^1.0"
},
"autoload": {
Expand Down
Empty file added phpstan-baseline.neon
Empty file.
27 changes: 27 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
parameters:

paths:
- src
- tests

level: max

checkFunctionNameCase: true
checkMissingIterableValueType: false

reportUnmatchedIgnoredErrors: false

exceptions:
implicitThrows: false

check:
missingCheckedExceptionInThrows: true
tooWideThrowType: true

uncheckedExceptionClasses:
- 'InvalidArgumentException'
- 'RuntimeException'
- 'PHPUnit\Framework\Exception'

includes:
- phpstan-baseline.neon
16 changes: 0 additions & 16 deletions psalm.xml

This file was deleted.

5 changes: 4 additions & 1 deletion src/Codename.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ class Codename
/** Create a new Codename object. */
public function __construct()
{
/** @var string $varriant */
$varriant = (new Varriants)->random();

/** @var string $drink */
$drink = (new Drinks)->random();

$this->codename = "{$varriant}-{$drink}";
Expand All @@ -28,6 +31,6 @@ public function __toString(): string
/** Create a new Codename object statically. */
public static function make(): self
{
return new static;
return new self;
}
}
9 changes: 3 additions & 6 deletions src/Collections/Drinks.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@

use Tightenco\Collect\Support\Collection;

/** @extends Collection<int, string> */
final class Drinks extends Collection
{
/** @var array The items contained in the collection. */
/** @var array<int, string> The items contained in the collection. */
protected $items = [
'affogato',
'americano',
Expand Down Expand Up @@ -37,11 +38,7 @@ final class Drinks extends Collection
'ristretto',
];

/**
* Create a new Varriants collection.
*
* @param mixed $items
*/
/** Create a new Drinks collection. */
public function __construct($items = null)
{
if (isset($items)) {
Expand Down
9 changes: 3 additions & 6 deletions src/Collections/Varriants.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@

use Tightenco\Collect\Support\Collection;

/** @extends Collection<int, string> */
final class Varriants extends Collection
{
/** @var array The items contained in the collection. */
/** @var array<int, string> The items contained in the collection. */
protected $items = [
'almond',
'brown-sugar',
Expand Down Expand Up @@ -44,11 +45,7 @@ final class Varriants extends Collection
'white-chocolate',
];

/**
* Create a new Varriants collection.
*
* @param mixed $items
*/
/** Create a new Varriants collection. */
public function __construct($items = null)
{
if (isset($items)) {
Expand Down
6 changes: 3 additions & 3 deletions tests/CodenameTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@

class CodenameTest extends TestCase
{
public function test_it_can_generate_a_codename()
public function test_it_can_generate_a_codename(): void
{
$codename = new Codename();

$this->assertMatchesRegularExpression('/^([a-z]+)(?:-([a-z]+))+$/', (string) $codename);
}

public function test_it_can_generate_a_codename_staticaly()
public function test_it_can_generate_a_codename_staticaly(): void
{
$codename = Codename::make();

$this->assertMatchesRegularExpression('/^([a-z]+)(?:-([a-z]+))+$/', (string) $codename);
}

public function test_it_can_generate_a_codename_with_the_helper_method()
public function test_it_can_generate_a_codename_with_the_helper_method(): void
{
$codename = cafelias();

Expand Down

0 comments on commit b374930

Please sign in to comment.