Comments (11)
I just had an idea how to implement this in an elegant way:
Feel free to test it now, it will be released along with PHPStan 0.10.2 in a few days π
from phpstan-nette.
Yes, I already replaced my codebase with ->getComponent()
calls.
There is no way (and i think there is no plan for that) how to handle dynamic return type extension for array access/set/unset/...
from phpstan-nette.
@CzechBoy Hey, do you have some script or something how to do this change automatically?
from phpstan-nette.
@novjan I don't remember, but I replaced it with some regex.
from phpstan-nette.
Ok, thank you.
Anyway ... do you have some plans about it @ondrejmirtes ?
from phpstan-nette.
@ondrejmirtes Hi. It looks that it works only for first offset.
This is ok:
$this['form']->setDefaults([]);
This is ok:
$this['form-checkbox']->setDefaultValue(TRUE)
This is error:
$this['form']['checkbox']->setDefaultValue(TRUE)
from phpstan-nette.
from phpstan-nette.
@ondrejmirtes Small example:
protected function createComponentFormData()
{
$isEdit = TRUE;
$form = new \Nette\Application\UI\Form;
$form->addText('text');
if ($isEdit) {
$form['form']->addRule($form::FILLED); // Call to an undefined method Nette\ComponentModel\IComponent::addRule().
}
$data = $form->addContainer('data');
$data->addText('text2');
$form['data']['text2']->setDefaultValue('text'); // Cannot access offset 'text2' on Nette\ComponentModel\IComponent.
}
from phpstan-nette.
PHPStan has no way of knowing the type of $form['data']['text2']
. It only works with createComponentFoo
style factories.
from phpstan-nette.
Use this pattern:
$data = $form->addContainer('data');
$text2 = $data->addText('text2');
$text2->setDefaultValue('text');
from phpstan-nette.
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.
from phpstan-nette.
Related Issues (20)
- Resolving BaseControl in presenter HOT 3
- report deprecation errors, when a nette file references a `@deprecated` class HOT 4
- Weird PHPStan errors for renamed interfaces HOT 10
- Strings::match() should be checked for invalid regex HOT 4
- Call to undefined method Nette\Forms\Control HOT 9
- Access to an uninitialized property which is @inject-ed HOT 1
- PHPStan: Call to an undefined method Slince\Shopify\Client::methodName() HOT 2
- Checking links HOT 6
- Nette 3 redirect error HOT 5
- Nette forms callbacks HOT 2
- FatalError after composer update (last version of Nette\PhpGenerator) HOT 3
- Broken compatibility with Nette 2.x HOT 4
- Nette Tester Asserts HOT 6
- Presenter#sendResponse() is not taken as early terminating method call even it is stated in config file HOT 5
- RouteList does not accept Route HOT 10
- False positive on 0.12.15? HOT 8
- Missing dynamic return type for Nette\Http\Session::getSection() HOT 4
- Form events errors HOT 3
- [Security] Workflow release.yml is using vulnerable action metcalfc/changelog-generator HOT 1
- Dependency Dashboard
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from phpstan-nette.