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.

Comments

ishore created an issue. See original summary.

ishore’s picture

StatusFileSize
new2.45 KB

Figured out where the #[\ReturnTypeWillChange] should actually go, changed the files, and error messages have now gone. I attach a patch file.

gagarine’s picture

StatusFileSize
new17.84 KB

Reuploading the patch from #2 without being ziped.

@ishore check https://www.drupal.org/docs/develop/git/using-git-to-contribute-to-drupa...

gagarine’s picture

Issue summary: View changes
fathima.asmat’s picture

Title: Highcharts and PHP 8.1 produces error messages » PHP 8.1 produces error messages on all charts (jsonSerialize)
Issue tags: +PHP 8.1
fathima.asmat’s picture

StatusFileSize
new30.22 KB

The deprecation warning for JsonSerialize() function appears fro all chart types from the submodules. This patch adds
#[\ReturnTypeWillChange] to all those methods.

fathima.asmat’s picture

StatusFileSize
new30.17 KB

The previous patch has added an unnecessary space on the front that is removed in this patch.

fathima.asmat’s picture

fathima.asmat’s picture

Status: Active » Needs review
jcmartinez’s picture

#7 patch works for me.

gagarine’s picture

Status: Needs review » Reviewed & tested by the community

nikathone’s picture

Status: Reviewed & tested by the community » Fixed

Patched committed to 8.x-3.x.

nikathone’s picture

Status: Fixed » Closed (fixed)