Problem/Motivation
Drupal 9.4.2
PHP 8.1
Highcharts 8.1.0
The below error messages are displayed when generating a (column) chart using Highcharts. The charts generate okay, but display the error messages:
Deprecated function: Return type of Drupal\charts_highcharts\Settings\Highcharts\Xaxis::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in include() (line 8 of modules/contrib/charts/modules/charts_highcharts/src/Settings/Highcharts/Xaxis.php).
Deprecated function: Return type of Drupal\charts_highcharts\Settings\Highcharts\ChartLabel::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in include() (line 8 of modules/contrib/charts/modules/charts_highcharts/src/Settings/Highcharts/ChartLabel.php).
Deprecated function: Return type of Drupal\charts_highcharts\Settings\Highcharts\ChartTitle::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in include() (line 8 of modules/contrib/charts/modules/charts_highcharts/src/Settings/Highcharts/ChartTitle.php).
Deprecated function: Return type of Drupal\charts_highcharts\Settings\Highcharts\YaxisLabel::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in include() (line 8 of modules/contrib/charts/modules/charts_highcharts/src/Settings/Highcharts/YaxisLabel.php).
Deprecated function: Return type of Drupal\charts_highcharts\Settings\Highcharts\Yaxis::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in include() (line 8 of modules/contrib/charts/modules/charts_highcharts/src/Settings/Highcharts/Yaxis.php).
Deprecated function: Return type of Drupal\charts_highcharts\Settings\Highcharts\PlotOptions::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in include() (line 8 of modules/contrib/charts/modules/charts_highcharts/src/Settings/Highcharts/PlotOptions.php).
Deprecated function: Return type of Drupal\charts_highcharts\Settings\Highcharts\PlotOptionsStacking::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in include() (line 8 of modules/contrib/charts/modules/charts_highcharts/src/Settings/Highcharts/PlotOptionsStacking.php).
Deprecated function: Return type of Drupal\charts_highcharts\Settings\Highcharts\PlotOptionsSeries::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in include() (line 8 of modules/contrib/charts/modules/charts_highcharts/src/Settings/Highcharts/PlotOptionsSeries.php).
Deprecated function: Return type of Drupal\charts_highcharts\Settings\Highcharts\PlotOptionsSeriesDataLabels::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in include() (line 8 of modules/contrib/charts/modules/charts_highcharts/src/Settings/Highcharts/PlotOptionsSeriesDataLabels.php).
Deprecated function: Return type of Drupal\charts_highcharts\Settings\Highcharts\ChartCredits::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in include() (line 8 of modules/contrib/charts/modules/charts_highcharts/src/Settings/Highcharts/ChartCredits.php).
Deprecated function: Return type of Drupal\charts_highcharts\Settings\Highcharts\ChartLegend::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in include() (line 8 of modules/contrib/charts/modules/charts_highcharts/src/Settings/Highcharts/ChartLegend.php).
Deprecated function: Return type of Drupal\charts_highcharts\Settings\Highcharts\ChartLegendItemStyle::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in include() (line 8 of modules/contrib/charts/modules/charts_highcharts/src/Settings/Highcharts/ChartLegendItemStyle.php).
Deprecated function: Return type of Drupal\charts_highcharts\Settings\Highcharts\ExportingOptions::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in include() (line 8 of modules/contrib/charts/modules/charts_highcharts/src/Settings/Highcharts/ExportingOptions.php).
Deprecated function: Return type of Drupal\charts_highcharts\Settings\Highcharts\HighchartsOptions::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in include() (line 8 of modules/contrib/charts/modules/charts_highcharts/src/Settings/Highcharts/HighchartsOptions.php).
Deprecated function: Return type of Drupal\charts_highcharts\Settings\Highcharts\Chart::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in include() (line 8 of modules/contrib/charts/modules/charts_highcharts/src/Settings/Highcharts/Chart.php).
Deprecated function: Return type of Drupal\charts_highcharts\Settings\Highcharts\Tooltip::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in include() (line 8 of modules/contrib/charts/modules/charts_highcharts/src/Settings/Highcharts/Tooltip.php).I did try adding the #[\ReturnTypeWillChange] entry to each of the above mentioned files, but doing so just produces a blank screen and no errors on generation of the chart. I have tried this with both the Production and Development versions of 8.x-3.3, with the same result.
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | php-8.1-json-serialize-7.patch | 30.17 KB | fathima.asmat |
| #3 | php8.1-fix-3295201-3.patch | 17.84 KB | gagarine |
Comments
Comment #2
ishore commentedFigured out where the #[\ReturnTypeWillChange] should actually go, changed the files, and error messages have now gone. I attach a patch file.
Comment #3
gagarine commentedReuploading the patch from #2 without being ziped.
@ishore check https://www.drupal.org/docs/develop/git/using-git-to-contribute-to-drupa...
Comment #4
gagarine commentedComment #5
fathima.asmat commentedComment #6
fathima.asmat commentedThe deprecation warning for
JsonSerialize()function appears fro all chart types from the submodules. This patch adds#[\ReturnTypeWillChange] to all those methods.Comment #7
fathima.asmat commentedThe previous patch has added an unnecessary space on the front that is removed in this patch.
Comment #8
fathima.asmat commentedComment #9
fathima.asmat commentedComment #10
jcmartinez#7 patch works for me.
Comment #11
gagarine commentedComment #13
nikathonePatched committed to 8.x-3.x.
Comment #14
nikathone