Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,4 @@ parameters:

scanDirectories:
- vendor/swoole

# phpredis stubs don't include Redis Streams methods (xAdd, xGroup, etc.)
# These methods exist at runtime but PHPStan's stubs are incomplete
# See: https://github.com/phpredis/phpredis-stubs/issues
ignoreErrors:
-
message: '#Call to an undefined method RedisCluster::(x(Add|Group|ReadGroup|Ack|Pending|Claim|AutoClaim|Del|Len|Trim|Info|Range|RevRange)|eval)\(\)#'
path: src/Queue/Connection/RedisStreamCluster.php
- stubs
Comment on lines 8 to +10
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 scanDirectories may conflict with PHPStan's built-in RedisCluster stubs

PHPStan ships with its own incomplete RedisCluster stubs. Adding stubs to scanDirectories tells PHPStan to discover class definitions from that directory as regular PHP code — but since RedisCluster is already declared in PHPStan's internal stubs, this can produce a "class already declared" error at analysis time. The correct option for overriding/extending extension stubs is stubFiles, which is specifically designed to merge with existing type definitions rather than redeclare them.

Suggested change
scanDirectories:
- vendor/swoole
# phpredis stubs don't include Redis Streams methods (xAdd, xGroup, etc.)
# These methods exist at runtime but PHPStan's stubs are incomplete
# See: https://github.com/phpredis/phpredis-stubs/issues
ignoreErrors:
-
message: '#Call to an undefined method RedisCluster::(x(Add|Group|ReadGroup|Ack|Pending|Claim|AutoClaim|Del|Len|Trim|Info|Range|RevRange)|eval)\(\)#'
path: src/Queue/Connection/RedisStreamCluster.php
\ No newline at end of file
- stubs
scanDirectories:
- vendor/swoole
stubFiles:
- stubs/RedisCluster.stub.php

3 changes: 3 additions & 0 deletions pint.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"preset": "psr12",
"exclude": [
"stubs"
],
"rules": {
"single_quote": true
}
Expand Down
15 changes: 15 additions & 0 deletions stubs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# PHPStan Stubs

This directory contains stub files for PHPStan static analysis.

## RedisCluster.stub.php

This file is the official stub file from the [phpredis](https://github.com/phpredis/phpredis) extension.

- **Source**: https://github.com/phpredis/phpredis/blob/develop/redis_cluster.stub.php
- **Purpose**: Provides type definitions for Redis Streams methods (xAdd, xGroup, xReadGroup, etc.) and other RedisCluster methods
- **License**: PHP License (same as phpredis extension)

The phpredis extension provides these stub files in their repository for static analysis tools like PHPStan. Since the stub files are not distributed with the compiled extension, we include them here for PHPStan to use during static analysis.

This is the recommended approach from the phpredis maintainers for using their extension with static analysis tools.
Loading
Loading