-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
[BUG]: Phalcon 5.1.3 and PHP 8.2 dynamic property deprecation warning #16263
Comments
This is probably similar to #15973 |
Just installed Phalcon 5.2.0 with php8.2 and got deprecations to all classes extending Phalcon\Di\Injectable, the attribute |
It seems that it can also be avoided by setting |
Same for me. In my opinion ignoring/mute deprecations is bad practice. Hope for a fix soon. |
I agree. I wrote the following but got no reply. It is resolved here. |
@s-ohnishi could you provide minimal code example? |
@Jeckerson of course. mvc/simple-volt is used to indicate
Then add the following to views/index.volt:
The old-style tag helpers are on the verge of disappearing, but are still in use at this point. In this state, when you access simple-volt, it will be displayed as follows.
|
Controllers are also affected
|
Related: zephir-lang/zephir#2405 |
@fichtner Did you try the latest code that is in the v5 branch? From what I see Can you let us know please? |
When will it be released? |
We will release this, this weekend maybe earlier to get people going without the DI deprecation warnings. Jeckerson will work on the |
Isn't it a bad practice? As all controllers that extends So far I don't see a clean fix for this... Perhaps introduce a level with a new property, such as I've got another issue, still related to all of this:
(also with |
I see. |
@s-ohnishi in fact using @niden @Jeckerson I think it's a major issue, perhaps we should look at other frameworks to see how they handle this (DI + Controller), such as Symfony or Laravel? Override example (to deal with current issue on controllers): <?php
class MyController extends Phalcon\Mvc\Controller {
private $_di;
public function onConstruct() {
$this->_di = $this->getDi();
}
public function __get($name) {
return $this->_di[$name];
}
public function viewAction() {
$this->view->setVar('test', 'okay'); // no error on view
}
} |
is that so? |
@s-ohnishi you're right, that throws an Exception ( I've always had a hard time using this, as if I create a local property that has the same name as a Di service, that goes wrong. But that's by Phalcon's design, so you're right, that should do the trick. That leaves us with:
|
@dugwood If the |
In general, dynamic properties are a bad practice. One should always define what they want, its type and keep its scope limited to what it should be doing and accessing. However, we do not live in an ideal world and shortcuts do appear for convenience. IMHO the best way for this to be developed would have been through an internal array that would keep all the services and their names and utilize Because we did not use the above and used dynamic properties, we are stuck with this. A few other frameworks are doing the same so they have the same issue. Extending Although we get rid of the issue with DI related properties not throwing a warning, we indeed are hiding potential errors that might come with a simple typo say For the future we will make changes with the way the framework is structured but that will take a few versions to materialize. I will need to do a lot of testing to "remove" the As for |
If
I forgot, only a few of them used |
That is what I tried with the internal array (as mentioned in the reply above) and it failed miserably. I was getting errors from the CLI that the I will definitely work something out later on once we "calm" down from all the issues we have. |
understood. |
The same error is also in the latest version. I'm using PHP v8.2.13 & Phalcon v5.4.0. |
I heard that it was fixed, so I tried it with v5.5.0, but it still hasn't been improved. |
This is also a problem in Models with dynamic properties/where properties has not been defined. |
Hello, any update on this issue? It's impossible to me to upgrade to php 8.2 just because of this error... Running PHP 8.2.12 with Phalcon 5.6.0. Thank you |
I understand that there are various circumstances, but I think it's about time for some progress to be made on this issue. |
This has been fixed for PHP 8.2+ and above |
Describe the bug
With php 8.2 you can not create dynamic properties, so a controller extending the phalcon controller will throw depcrecation warnings for the injected properties from the interface injectable.
To Reproduce
create a controller and extend from phalcon controller. use asset/view etc.
Expected behavior
no warning should be thrown
Details
The text was updated successfully, but these errors were encountered: