Skip to content

Commit

Permalink
Fix QA
Browse files Browse the repository at this point in the history
  • Loading branch information
gmazzap committed May 5, 2024
1 parent 4f8fa46 commit af17f12
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 23 deletions.
19 changes: 19 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
The MIT License (MIT)

Copyright (c) 2024 Giuseppe Mazzapica and contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
"name": "toobo/type-checker",
"minimum-stability": "dev",
"prefer-stable": true,
"license": "MIT",
"require": {
"php": ">=8.1 < 8.4"
},
"require-dev": {
"phpunit/phpunit": "^10.5.18",
"phpunit/phpunit": "^10.5.20",
"inpsyde/php-coding-standards": "^2",
"vimeo/psalm": "^5.23.1"
"vimeo/psalm": "^5.24.0"
},
"autoload": {
"psr-4": {
Expand Down
11 changes: 11 additions & 0 deletions infection.json5.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://raw.githubusercontent.com/infection/infection/0.28.1/resources/schema.json",
"source": {
"directories": [
"src/"
]
},
"mutators": {
"@default": true
}
}
4 changes: 4 additions & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,8 @@
/>
</properties>
</rule>

<rule ref="Inpsyde.CodeQuality.FunctionLength">
<exclude-pattern>./tests/</exclude-pattern>
</rule>
</ruleset>
22 changes: 14 additions & 8 deletions tests/cases/ByReflectionTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,16 +143,22 @@ public function testComplexType(): void
{
$this->requireDnfTypes();

$func = static function (
(\Countable & \ArrayAccess)
| (\Countable & \Stringable)
| null
| float
| false $param
): void {
};
eval( // phpcs:ignore
<<<'PHP'
$func = static function (
(\Countable & \ArrayAccess)
| (\Countable & \Stringable)
| null
| float
| false $param
): void {};
PHP
);

// phpcs:disable VariableAnalysis
/** @var \Closure $func */
$ref = $this->extractTypeFromCallback($func);
// phpcs:enable VariableAnalysis
$type = Type::byReflectionType($ref);

$string1 = (string) $ref;
Expand Down
21 changes: 13 additions & 8 deletions tests/cases/IsATest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

namespace Toobo\TypeChecker\Tests;

use PHPUnit\Framework\Reorderable;
use PHPUnit\Framework\SelfDescribing;
use Toobo\TypeChecker\Type;

class IsATest extends TestCase
Expand Down Expand Up @@ -98,13 +96,20 @@ public function testDnfType(): void
{
$this->requireDnfTypes();

$func = static fn (
(\ArrayAccess & \Countable)
| (Reorderable & SelfDescribing)
| null $param
): int => 0;

eval( // phpcs:ignore
<<<'PHP'
$func = static fn (
(\ArrayAccess & \Countable)
| (PHPUnit\Framework\Reorderable & PHPUnit\Framework\SelfDescribing)
| null $param
): int => 0;
PHP
);

// phpcs:disable VariableAnalysis
/** @var \Closure $func */
$left = Type::byReflectionType($this->extractTypeFromCallback($func));
// phpcs:enable VariableAnalysis

$right1 = Type::byString(__CLASS__);
$right2 = Type::byString(TestCase::class);
Expand Down
17 changes: 12 additions & 5 deletions tests/cases/MatchedByTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,20 @@ public function testDnfType(): void
{
$this->requireDnfTypes();

$func = static fn (
(\ArrayAccess & \Countable)
| (Reorderable & SelfDescribing)
| null $param
): int => 0;
eval( // phpcs:ignore
<<<'PHP'
$func = static fn (
(ArrayAccess & Countable)
| (PHPUnit\Framework\Reorderable & PHPUnit\Framework\SelfDescribing)
| null $param
): int => 0;
PHP
);

// phpcs:disable VariableAnalysis
/** @var \Closure $func */
$left = Type::byReflectionType($this->extractTypeFromCallback($func));
// phpcs:enable VariableAnalysis

$right1 = Type::byString(__CLASS__);
$right2 = Type::byString(TestCase::class);
Expand Down

0 comments on commit af17f12

Please sign in to comment.