Open bbrala opened 6 months ago
Most constrructor changes rarely affect contrib, but this one very common as it's an base form for basically all settings forms.
A specific solution for this one is probably doable (detect parent class, check if it has a parent::__construct() without the second argument. A more generic implementation would be interesting, but I don't really see how that could be achieved without defning some kind of pattern that allows phpstan to understand that this currently-optional parameter will become required in 11.x.
Well there is a deprecation message in the parent contructor.
public function __construct(
ConfigFactoryInterface $config_factory,
protected ?TypedConfigManagerInterface $typedConfigManager = NULL,
) {
$this->setConfigFactory($config_factory);
if ($this->typedConfigManager === NULL) {
@trigger_error('Calling ConfigFormBase::__construct() without the $typedConfigManager argument is deprecated in drupal:10.2.0 and will be required in drupal:11.0.0. See https://www.drupal.org/node/3373502', E_USER_DEPRECATED);
$this->typedConfigManager = \Drupal::service('config.typed');
}
So wouldn't that be quite possible to find out? Even if not only for this one. Shouldn't that generally be possible to find our if a depraction message might be triggered if default value is used? That might be to much load to do for all constructors perhaps. But if we have this pattern and perhaps we could have a list of classes that might be targetted.
(i might say stupid things, haven't done much phpstan dev)
Feature request
https://www.drupal.org/node/3404140 See https://drupal.slack.com/archives/C03L6441E1W/p1717267194080329?thread_ts=1717267194.080329&cid=C03L6441E1W