Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Column Typing + SA Check #166

Merged
merged 3 commits into from
Jul 31, 2021
Merged

Fix Column Typing + SA Check #166

merged 3 commits into from
Jul 31, 2021

Conversation

AlexandruGG
Copy link
Collaborator

@AlexandruGG AlexandruGG commented Jul 31, 2021

This PR:

  • Fixes the type hints for Column/Columnable -> this operation supports any "column" key type as parameter, not just int|string. Furthermore, the return type has to be flexible because it will not be T, but rather whatever type was associated with that key, so it has to be mixed
  • Has unit tests (phpspec)
  • Has static analysis tests (psalm, phpstan)
  • Has documentation

Note: I spotted this issue while trying to do this in another project:

/** @return Collection<int, int> */
public function getIds(): Collection 
{
  // ...
  /** @var list<array{id: numeric-string}> $results */
  $results = $qb->getQuery()->getResult();

  return Collection::fromIterable($results)
    ->column('id')
    ->map(static fn (string $id): (int) $id);  
            // -> I got an error here because the map callable was expecting type `array{id: numeric-string}`
}

@drupol
Copy link
Collaborator

drupol commented Jul 31, 2021

This depends on #166

@drupol
Copy link
Collaborator

drupol commented Jul 31, 2021

All good for me here, merge anytime ! :)

@AlexandruGG AlexandruGG marked this pull request as ready for review July 31, 2021 17:27
@AlexandruGG AlexandruGG enabled auto-merge (squash) July 31, 2021 17:27
@AlexandruGG
Copy link
Collaborator Author

All good for me here, merge anytime ! :)

Turned on auto-merge 😁

Copy link
Collaborator

@drupol drupol left a comment

Choose a reason for hiding this comment

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

👍

@AlexandruGG AlexandruGG merged commit 7432a68 into master Jul 31, 2021
@AlexandruGG AlexandruGG deleted the feature/sa-check-column branch July 31, 2021 17:39
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.

None yet

2 participants