Repository navigation
Conversation
nette/forms 2.3 and 2.4 describe the return type of Container::getValues() as @return Nette\Utils\ArrayHash|array, which is not more precise than what the extension infers either. Since 2.0.13 the extension was skipped for it and every getValues() call was typed as array|ArrayHash, including getValues(true). Claude-Session: https://claude.ai/code/session_01FBu2xVRvxJ4rGqBf4Mjrhy
|
Hi, why are you still using nette/forms 2.x? This has been unmaintained since around 2018... |
|
@ondrejmirtes Fair point, and we know it's old. I opened the PR because phpstan-nette still declares support for |
#224 skips
FormContainerValuesDynamicReturnTypeExtensionwhen the PHPDoc@returnofgetValues()is not a supertype ofobject|array, assuming thatThat holds for nette/forms 3.0 – 3.2.8, but nette/forms 2.3 and 2.4 (still allowed by
"conflict": {"nette/forms": "<2.3.0"}) declare@return Nette\Utils\ArrayHash|array. Since 2.0.13 their users getarray|Nette\Utils\ArrayHashfor everygetValues()call, includinggetValues(true).This PR keeps the extension also when the PHPDoc type is exactly
ArrayHash|array(checked as mutual supertypes, so a narrower override such asCustomValues|array<string, string>keeps its own PHPDoc).getUntrustedValues()doesn't exist in nette/forms 2.x, soFormContainerUntrustedValuesDynamicReturnTypeExtensionis left as is.Tests
nette/forms 2.x can't be installed next to the
^3.0dev dependencies, so the new data fileFormContainerArrayHashOrArrayValues.phpoverridesgetValues()in aFormsubclass with the nette/forms 2.x PHPDoc. It also has a subclass with a narrower@returnto check that this PHPDoc is still respected.got type array|Nette\Utils\ArrayHash.make lint,make tests,make phpstanandmake cspass (nette/forms 3.3.0, PHPStan 2.3.1). The type tests also pass with--prefer-lowest(nette/forms 3.2.8, PHPStan 2.2.3).getValues(TRUE)→array<string, mixed>,getValues()→Nette\Utils\ArrayHash.