src/Builder/BaseTypeClassBuilder.php
private function buildJsonSerialize(array $serialize, $indent, array &$result)
    {
        if (count($serialize)) {
            $result[] = '';
            $result[] = $indent . '/**';
            $result[] = $indent . ' * Prepare object properties so they can be serialized to JSON.';
            $result[] = $indent . ' *';
            $result[] = $indent . ' * @return array';
            $result[] = $indent . ' */';
            $result[] = $indent . 'public function jsonSerialize()';
            $result[] = $indent . '{';
            $result[] = $indent . '    return array_merge(parent::jsonSerialize(), [';

            foreach ($serialize as $field) {
                $result[] = $indent . '        ' . var_export($field, true) . ' => $this->' . $this->getGetterName($field) . '(),';
            }

            $result[] = $indent . '    ]);';
            $result[] = $indent . '}';
        }
    }
private function buildJsonSerialize(array $serialize, $indent, array &$result)
    {
        if (count($serialize)) {
            $result[] = '';
            $result[] = $indent . '/**';
            $result[] = $indent . ' * Prepare object properties so they can be serialized to JSON.';
            $result[] = $indent . ' *';
            $result[] = $indent . ' * @return array';
            $result[] = $indent . ' */';
            $result[] = $indent . 'public function jsonSerialize()';
            $result[] = $indent . '{';
            $result[] = $indent . '    return array_merge(parent::jsonSerialize(), [';

            foreach ($serialize as $field) {
                $result[] = $indent . '        ' . var_export($field, true) . ' => $this->' . $this->getGetterName($field) . '(),';
            }

            $result[] = $indent . '    ]);';
            $result[] = $indent . '}';
        }
    }
private function buildJsonSerialize ( array $ serialize , $ indent , array & $ result ) { if ( count ( $ serialize ) ) { $ result [ ] = '' ; $ result [ ] = $ indent . '/**' ; $ result [ ] = $ indent . ' * Prepare object properties so they can be serialized to JSON.' ; $ result [ ] = $ indent . ' *' ; $ result [ ] = $ indent . ' * @return array' ; $ result [ ] = $ indent . ' */' ; $ result [ ] = $ indent . 'public function jsonSerialize()' ; $ result [ ] = $ indent . '{' ; $ result [ ] = $ indent . '    return array_merge(parent::jsonSerialize(), [' ; foreach ( $ serialize as $ field ) { $ result [ ] = $ indent . '        ' . var_export ( $ field , true ) . ' => $this->' . $ this -> getGetterName ( $ field ) . '(),' ; } $ result [ ] = $ indent . '    ]);' ; $ result [ ] = $ indent . '}' ; } }
Build JSON serialize method, if we need to serialize extra fields.

@param array  $serialize
@param string $indent
@param array  $result
Build JSON serialize method if we need to serialize extra fields .