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

Failure to detect fatal error using array_map with subtype #2783

Closed
muglug opened this issue Dec 29, 2019 · 2 comments
Closed

Failure to detect fatal error using array_map with subtype #2783

muglug opened this issue Dec 29, 2019 · 2 comments

Comments

@muglug
Copy link
Contributor

muglug commented Dec 29, 2019

Found in PHPStan's code e.g. https://github.com/phpstan/phpstan-src/blob/35047b54c1d2435fe2e16488bf5a5164f313e123/src/Type/CallableType.php#L134-L138 (not saying that's a bug, but it's a place that Psalm flagged as being potentially dangerous).

<?php

class A {}
class AChild extends A {}

array_map(
	function (AChild $c) : AChild {
		return $c;
	},
	[new A(), new A()]
);

https://phpstan.org/r/14c0aa8d-ade1-4fbb-ba0a-40bdc917682f

@ondrejmirtes ondrejmirtes added this to the Generics milestone Dec 30, 2019
@ondrejmirtes
Copy link
Member

This is the same as #1954.

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants