Skip to content

Instantly share code, notes, and snippets.

@oplanre
oplanre / TSGen.php
Last active April 28, 2024 14:42
Simple TS interface generator (php impl)
<?php
class TSGen
{
public static function fromJSON(string $json, string $interfaceName): string
{
try {
return self::generateInterface(json_decode($json, true, 512, JSON_THROW_ON_ERROR), $interfaceName);
} catch (JsonException $e) {
throw new InvalidArgumentException("Error parsing JSON: " . $e->getMessage());
@oplanre
oplanre / heap-object.h
Last active April 8, 2024 14:24
PHP Typesystem Extended (C++). This is part of a project i built at work to make it easier/more stable to build php extensions
#pragma once
#include "lend-forward.h"
#include "lend-type.h" // NOLINT(build/include_directory)
#include "lend-internal.h" // NOLINT(build/include_directory)
#include "lend-handle.h" // NOLINT(build/include_directory)
#include "lendconfig.h" // NOLINT(build/include_directory)
#include <cstdint>
namespace lend {
/**
* @class HeapObject