-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* analyse closures * cleanup * analyser test * ate own dog food
- Loading branch information
Showing
15 changed files
with
211 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
build | ||
bin/typhp.phar | ||
vendor | ||
composer.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,3 +53,6 @@ jobs: | |
- chmod +x phpstan.phar | ||
script: | ||
- ./phpstan.phar analyse src --level=5 | ||
|
||
notifications: | ||
email: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace Seferov\Typhp\Tests\Functional\Scenarios; | ||
|
||
use Seferov\Typhp\Tests\Functional\FunctionalTestCase; | ||
|
||
class ClosuresTest extends FunctionalTestCase | ||
{ | ||
public function testNoIssues(): void | ||
{ | ||
$output = $this->process('tests/Functional/Scenarios/Fixtures/ClosuresNoIssues.php'); | ||
$outputLines = $output->getLines(); | ||
$this->assertCount(0, $outputLines); | ||
$this->assertSame(0, $output->getExitCode()); | ||
} | ||
|
||
public function testWithIssues(): void | ||
{ | ||
$output = $this->process('tests/Functional/Scenarios/Fixtures/ClosuresWithIssues.php'); | ||
$outputLines = $output->getLines(); | ||
$this->assertCount(8, $outputLines); | ||
$this->assertSame(4, $output->getExitCode()); | ||
|
||
$this->assertSame('5;n/a (closure);untyped-argument;foo', array_shift($outputLines)); | ||
$this->assertSame('5;n/a (closure);untyped-return', array_shift($outputLines)); | ||
$this->assertSame('11;n/a (closure);untyped-argument;a', array_shift($outputLines)); | ||
$this->assertSame('11;n/a (closure);untyped-return', array_shift($outputLines)); | ||
$this->assertSame('17;foo;untyped-argument;foo', array_shift($outputLines)); | ||
$this->assertSame('17;foo;untyped-return', array_shift($outputLines)); | ||
$this->assertSame('23;n/a (closure);untyped-argument;bar', array_shift($outputLines)); | ||
$this->assertSame('23;n/a (closure);untyped-return', array_shift($outputLines)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace Seferov\Typhp\Tests\Functional\Scenarios\Fixtures; | ||
|
||
$foo = function (int $foo): int { | ||
return $foo; | ||
}; | ||
|
||
array_map($foo, [0, 1, 2]); | ||
|
||
array_filter([0, 1, 2], function (int $a): bool { | ||
return $a > 1; | ||
}); | ||
|
||
class ClosuresNoIssues | ||
{ | ||
public function foo(callable $foo): void | ||
{ | ||
$foo(1); | ||
} | ||
} | ||
|
||
(new ClosuresNoIssues())->foo(function (int $bar): bool { | ||
return $bar > 1; | ||
}); |
25 changes: 25 additions & 0 deletions
25
tests/Functional/Scenarios/Fixtures/ClosuresWithIssues.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace Seferov\Typhp\Tests\Functional\Scenarios\Fixtures; | ||
|
||
$foo = function ($foo) { | ||
return $foo; | ||
}; | ||
|
||
array_map($foo, [0, 1, 2]); | ||
|
||
array_filter([0, 1, 2], function ($a) { | ||
return $a > 1; | ||
}); | ||
|
||
class ClosuresWithIssues | ||
{ | ||
public function foo($foo) | ||
{ | ||
$foo(1); | ||
} | ||
} | ||
|
||
(new ClosuresWithIssues())->foo(function ($bar) { | ||
return $bar > 1; | ||
}); |
Oops, something went wrong.