FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Added Nette\Caching\Cache dynamic return type extensions by adaamz · Pull Request #49 · phpstan/phpstan-nette · GitHub

Added Nette\Caching\Cache dynamic return type extensions - #49

Open
adaamz wants to merge 1 commit into
phpstan:1.1.xfrom
adaamz:caching
Open

Added Nette\Caching\Cache dynamic return type extensions#49
adaamz wants to merge 1 commit into
phpstan:1.1.xfrom
adaamz:caching

Conversation

adaamz commented Apr 27, 2020

Copy link
Copy Markdown
Contributor

No description provided.

adaamz force-pushed the caching branch 2 times, most recently from 3434ecc to e5b5c36 Compare April 27, 2020 11:28

Copy link
Copy Markdown
Member

Hi, I worry that some cases will not work well, for example:

	/**
	 * @template TFallback
	 * @param mixed $key
	 * @param (callable(mixed): TFallback)|null $fallback
	 * @return TFallback
	 */
 	public function load($key, callable $fallback = null)

If the fallback is not passed, we have an unresolved TFallback.

And in some other cases I'm not sure that callable(mixed) is right, there might be none or more arguments passed.

adaamz commented Apr 27, 2020

Copy link
Copy Markdown
Contributor Author

Can we somehow tell that if no fallback is passed it should return null?

In source is this https://github.com/nette/caching/blob/be02f7e/src/Caching/Cache.php#L104, so the parameter should be only one?

Copy link
Copy Markdown
Member
  1. TFallback - nope, at that point you can't use generics, but need a dynamic return type extension instead.
  2. There are three callable(mixed) in the stubs, is it true for all of those? What's the diferrence between fn(&$dependencies) and fn(...[&$dependencies])?

adaamz force-pushed the caching branch 2 times, most recently from 492fbf8 to 68dbcda Compare April 27, 2020 13:45

adaamz commented Apr 27, 2020

Copy link
Copy Markdown
Contributor Author
  1. OK, introduced dynamic return type extensions for all previously stubbed methods
  2. i have no clue, im really lost in references in php :)

adaamz changed the title Added Nette\Caching\Cache generic stubs Added Nette\Caching\Cache dynamic return type extensions Apr 27, 2020
}

$fallbackParameterType = $scope->getType($methodCall->args[$fallbackParameterIndex]->value);
if (!$fallbackParameterType instanceof ParametersAcceptor) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Better ask about ->isCallable()->yes(), get ->getCallableParametersAcceptors() and pass it to ParametersAcceptorSelector::selectFromArgs().

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

You mean like this? I hope i got it correctly :)

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

2 participants


Back | FazBrowse Home | New Git URL