-
Notifications
You must be signed in to change notification settings - Fork 61
Fix crashes with Nette 3.2 #69
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
Merged
Conversation
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
Nette Forms 3.2.0 replaced SplObjectStorage with WeakMap nette/forms@ec8ecfd
291a615 introduced type hints so the method now expects a string for name, consistent with `nette/component-model` (nette/component-model@47dab8f). This unfortunately leads to an error when rendering a form since range produces integers: Kdyby\Replicator\Container::createOne(): Argument Kdyby#1 ($name) must be of type ?string, int given
`Container::getComponents()` returns array when `$deep` is false (by default): nette/component-model@7f613ee The method also no longer takes any arguments: nette/component-model@4e0946a
It was introduced in 7ae4bd3 as using `string|false` but the actual type was not reflected in the annotation. Let’s tighten it up as `?string` and use type hint. This is required for PHPStan level 3.
The check was there to allow passing the callable as the first and only argument but that got broken by introduction of type hints in 291a615 so PHPStan would complain: Call to function is_bool() with bool will always evaluate to true. But we do not need this now that we support PHP 8 with named arguments: https://www.php.net/manual/en/functions.arguments.php#functions.named-arguments
Mostly adding generic types to iterables. Disabling `treatPhpDocTypesAsCertain` since we cannot guarantee the caller of public methods will respect the annotation and without this, PHPStan will complain about redundant `is_iterable`.
This was a bit annoying since the annotations in nette and phpstan-nette are not the most precise.
e7cc49e to
5a15cae
Compare
Contributor
|
@jakubboucek can I ask you for a review? |
After updating from 2.1.22 to 2.1.23, PHPStan started to complain:
Offset int|string might not exist on $this(Kdyby\Replicator\Container).
🪪 offsetAccess.notFound
https://github.com/phpstan/phpstan/releases/tag/2.1.23
Let’s inline the contents of `Nette\ComponentModel\ArrayAccess::offsetGet()`.
Contributor
Author
|
Pushed a fix for newer PHPStan. Fixing the Rector CI in #70 since it is unrelated. |
Contributor
OK. I am going to merge it and release it during the week. Thanks! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When trying this with latest Nette, I got several crashes. Trying to fix them all and increase PHPStan level so that I can be more certain more are not hiding in the shadows.