I met this question and created a separate change to test it: https://gerrit.wikimedia.org/r/c/mediawiki/core/+/678420
Test result after I defined the parameter type of ParserOutput::addCategory() to string was failed:
ParserOutputTest::testDeserialization with data set "ParserOutput:withMetadata, deserialized from serialized, 1.31" ('unserialize', ParserOutput Object (...), Binary String: 0x4f3a31323a225...b4e3b7d) mCategories Failed asserting that two arrays are identical. --- Expected +++ Actual @@ @@ Array &0 ( - 'category2' => '1' - 'category1' => '2' + 'category2' => 1 + 'category1' => 2 )