Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add dynamic return type to ResponseHeaderBag::getCookies #242

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

Merged
ondrejmirtes merged 2 commits into phpstan:master from franmomu:response_bag_get_cookies
Feb 1, 2022

Conversation

Copy link
Contributor

@franmomu franmomu commented Feb 1, 2022

if (isset($methodCall->getArgs()[0])) {
$argStrings = TypeUtils::getConstantStrings($scope->getType($methodCall->getArgs()[0]->value));

if (count($argStrings) === 1 && $argStrings[0]->getValue() === ResponseHeaderBag::COOKIES_ARRAY) {
Copy link
Member

@ondrejmirtes ondrejmirtes Feb 1, 2022

Choose a reason for hiding this comment

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

I worry that asking for runtime value of ResponseHeaderBag::COOKIES_ARRAY might fail here in some projects. Can you please check for ClassConstFetch and check that the user fetches the right constant here? Thanks.

franmomu reacted with thumbs up emoji
Copy link
Contributor Author

@franmomu franmomu Feb 1, 2022

Choose a reason for hiding this comment

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

thanks for the guidance, not sure if this is the way you meant, let me know otherwise.

$headerBag->setCookie(Cookie::create('cookie_name'));

assertType('array<int, Symfony\Component\HttpFoundation\Cookie>', $headerBag->getCookies());
assertType('array<string, array<string, array<string, Symfony\Component\HttpFoundation\Cookie>>>', $headerBag->getCookies(ResponseHeaderBag::COOKIES_ARRAY));
Copy link
Member

@ondrejmirtes ondrejmirtes Feb 1, 2022

Choose a reason for hiding this comment

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

Also test the FLAT scenario.

franmomu reacted with thumbs up emoji
@ondrejmirtes ondrejmirtes merged commit 11221af into phpstan:master Feb 1, 2022
Copy link
Member

Thank you!

franmomu reacted with hooray emoji

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@ondrejmirtes ondrejmirtes ondrejmirtes requested changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /