<commit_before><?php

namespace Ornament\Json;

use stdClass;
use ReflectionClass;
use ReflectionProperty;

trait SerializeAll
{
    /**
     * Returns a StdClass model representation suitable for Json serialization.
     * This trait only exports both public and protected properties.
     *
     * @return StdClass
     */
    public function jsonSerialize() : stdClass
    {
        $reflection = new ReflectionClass($this);
        $export = new StdClass;
        foreach ($reflection->getProperties((ReflectionProperty::IS_PUBLIC | ReflectionProperty::IS_PROTECTED) & ~ReflectionProperty::IS_STATIC) as $property) {
            $name = $property->getName();
            $export->$name = $this->$name ?? null;
        }
        return $export;
    }
}
<commit_msg>this, too, should export getters<commit_after><?php

namespace Ornament\Json;

use stdClass;
use ReflectionClass;
use ReflectionProperty;

trait SerializeAll
{
    /**
     * Returns a StdClass model representation suitable for Json serialization.
     * This trait only exports both public and protected properties.
     *
     * @return StdClass
     */
    public function jsonSerialize() : stdClass
    {
        $reflection = new ReflectionClass($this);
        $export = new StdClass;
        foreach ($reflection->getProperties((ReflectionProperty::IS_PUBLIC | ReflectionProperty::IS_PROTECTED) & ~ReflectionProperty::IS_STATIC) as $property) {
            $name = $property->getName();
            $export->$name = $this->$name ?? null;
        }
        $cache = $this->__getModelPropertyDecorations();
        foreach ($cache['methods'] as $prop => $getter) {
            $export->$prop = $this->$getter($prop);
        }
        return $export;
    }
}

{'fraction_non_alphanumeric': 0.11431870669745958, 'fraction_numerical': 0.0, 'mean_word_length': 2.9386363636363635, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2184730', 'n_tokens_mistral': 483, 'n_tokens_neox': 482, 'n_words': 121}