Skip to content

Commit 6cad491

Browse files
huangdijiaCopilot
andauthored
feat: Add PHPStan type testing (#970)
* feat: add PHPStan type checking configuration and composer script Add PHPStan configuration for type assertion testing and a new composer script for running type checks. This includes: - New phpstan.types.neon.dist configuration file for type checking - New types/ directory with helper function type assertions - New composer script 'check:types' for running type analysis This enhancement allows developers to validate type assertions for helper functions and ensure type safety across the codebase. * Add comprehensive PHPStan type tests for all helper functions (#971) * Initial plan * feat: add comprehensive type tests for all helper functions Co-authored-by: huangdijia <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: huangdijia <[email protected]> * Move call() tests to Functions.php and update type assertions Deleted Command/Functions.php and moved its call() tests to Helpers/Functions.php. Updated type assertions and test cases in Helpers/Functions.php for improved accuracy and consistency with current return types. Co-Authored-By: Deeka Wong <[email protected]> * fix: remove unnecessary backslash from Throwable type hint in dispatch job * refactor: rename check:types script to type-testing for clarity * fix: move type-testing script to the correct position in composer.json * fix: remove unnecessary blank line before type-testing script in composer.json * feat: add Support.php with various utility classes and type assertions * fix: add return type hints for __invoke methods in ClientBuilderFactory and HubFactory * feat: add PHPStan type assertion tests for macros component (#973) * Initial plan * feat: add type assertion tests for macros component Co-authored-by: huangdijia <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: huangdijia <[email protected]> * feat: add PHPStan type testing for cache component (#972) * Initial plan * feat: add comprehensive type testing for cache component Co-authored-by: huangdijia <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: huangdijia <[email protected]> * fix: remove unused imports in Cache and Macros components * feat: update PHPStan configuration and enhance type assertions in various components * fix: update parameter type hint for Str::of method * fix: remove unused Factory method tests in Cache Manager * feat: add type testing step in CI workflow * fix: comment out unused setMultiple tests in Repository * fix: comment out unused getMultiple tests in Repository --------- Co-authored-by: Deeka Wong <[email protected]> Co-authored-by: Copilot <[email protected]>
1 parent bd70f66 commit 6cad491

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/Factory/ClientBuilderFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class ClientBuilderFactory
3636
'tracing',
3737
];
3838

39-
public function __invoke(ContainerInterface $container)
39+
public function __invoke(ContainerInterface $container): ClientBuilder
4040
{
4141
$userConfig = $container->get(ConfigInterface::class)->get('sentry', []);
4242
$userConfig['enable_tracing'] ??= true;

src/Factory/HubFactory.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Sentry\ClientBuilder;
2020
use Sentry\Integration as SdkIntegration;
2121
use Sentry\State\Hub;
22+
use Sentry\State\HubInterface;
2223

2324
use function Hyperf\Support\make;
2425

@@ -28,7 +29,7 @@
2829
*/
2930
class HubFactory
3031
{
31-
public function __invoke(ContainerInterface $container)
32+
public function __invoke(ContainerInterface $container): HubInterface
3233
{
3334
$clientBuilder = $container->get(ClientBuilder::class);
3435
$options = $clientBuilder->getOptions();

0 commit comments

Comments
 (0)