Skip to content

Conversation

@MidnightDesign
Copy link

@MidnightDesign MidnightDesign commented Nov 4, 2025

Changes the context key of the log_record_array type from a sealed array to an unsealed one.

Currently, $logger->records[0]['context']['foo'] results in an error in PHPStan and Pslam because the context key is defined to only ever have (at most) an exception key, but nothing else. This change makes the context array unsealed, meaning it can hold keys other than exception.

Fixes #17

This change is IMO a better solution than #21 which widens the type too far (array<array-key, mixed>).

@MidnightDesign
Copy link
Author

On the other hand, as @derrabus mentioned, exception can actually be any value. So maybe his PR is the more correct one. I would just change the mixed[] to the more explicit array<array-key, mixed>. (It's the same type, just a bit more explicit.)

@Seldaek
Copy link
Contributor

Seldaek commented Nov 11, 2025

Yup closing as I think the other PR is fine, and also I'm not sure if phpstan has support for , ... yet in arrays?

@Seldaek Seldaek closed this Nov 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PHPDoc type for context is too narrow

2 participants