Skip to content

Commit

Permalink
[7.x] Types Improvements (#287)
Browse files Browse the repository at this point in the history
* [7.x] Types Improvements

Signed-off-by: Mior Muhammad Zaki <[email protected]>

* wip

Signed-off-by: Mior Muhammad Zaki <[email protected]>

* wip

Signed-off-by: Mior Muhammad Zaki <[email protected]>

---------

Signed-off-by: Mior Muhammad Zaki <[email protected]>
  • Loading branch information
crynobone authored Dec 29, 2024
1 parent 38f1158 commit 4ce62ea
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
1 change: 1 addition & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ includes:
parameters:
paths:
- src
- types

# The level 8 is the highest level
level: 8
Expand Down
12 changes: 12 additions & 0 deletions src/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -406,9 +406,15 @@ function laravel_vendor_exists(ApplicationContract $app, ?string $workingPath =
*
* @api
*
* @template TOperator of string|null
*
* @param string $version
* @param string|null $operator
* @return int|bool
*
* @phpstan-param TOperator $operator
*
* @phpstan-return (TOperator is null ? int : bool)
*/
function laravel_version_compare(string $version, ?string $operator = null)
{
Expand All @@ -427,11 +433,17 @@ function laravel_version_compare(string $version, ?string $operator = null)
*
* @api
*
* @template TOperator of string|null
*
* @param string $version
* @param string|null $operator
* @return int|bool
*
* @throws \RuntimeException
*
* @phpstan-param TOperator $operator
*
* @phpstan-return (TOperator is null ? int : bool)
*/
function phpunit_version_compare(string $version, ?string $operator = null)
{
Expand Down
29 changes: 29 additions & 0 deletions types/functions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

use function Orchestra\Testbench\default_skeleton_path;
use function Orchestra\Testbench\laravel_version_compare;
use function Orchestra\Testbench\package_path;
use function Orchestra\Testbench\phpunit_version_compare;
use function Orchestra\Testbench\workbench_path;
use function PHPStan\Testing\assertType;

assertType('string', default_skeleton_path());
assertType('string', default_skeleton_path('app'));
assertType('string', default_skeleton_path('app', '.gitkeep'));
assertType('string', default_skeleton_path(['app', '.gitkeep']));

assertType('string', package_path());
assertType('string', package_path('laravel'));
assertType('string', package_path('laravel', 'app', '.gitkeep'));
assertType('string', package_path(['laravel', 'app', '.gitkeep']));

assertType('string', workbench_path());
assertType('string', workbench_path('app'));
assertType('string', workbench_path('app', 'Providers'));
assertType('string', workbench_path(['app', 'Providers']));

assertType('bool', laravel_version_compare('7.0.0', '>='));
assertType('int', laravel_version_compare('7.0.0'));

assertType('bool', phpunit_version_compare('9.0.0', '>='));
assertType('int', phpunit_version_compare('9.0.0'));

0 comments on commit 4ce62ea

Please sign in to comment.