This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Assert | |
{ | |
protected function __construct( | |
) {} | |
protected static function expect( | |
mixed $value, | |
bool $invert, | |
bool $condition, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static constexpr zend_ulong DJBX33A(const char *str, size_t len){ | |
zend_ulong hash = 5381; | |
#if defined(_WIN32) || defined(__i386__) || defined(__x86_64__) || defined(__aarch64__) | |
// Version with multiplication works better on modern CPUs | |
for (; len >= 8; len -= 8, str += 8) { | |
uint64_t chunk; | |
std::memcpy(&chunk, str, sizeof(chunk)); | |
hash = hash * 33 * 33 * 33 * 33 + ((chunk >> (8 * 0)) & 0xff) * 33 * 33 * 33 + ((chunk >> (8 * 1)) & 0xff) * 33 * 33 + | |
((chunk >> (8 * 2)) & 0xff) * 33 + ((chunk >> (8 * 3)) & 0xff); | |
hash = hash * 33 * 33 * 33 * 33 + ((chunk >> (8 * 4)) & 0xff) * 33 * 33 * 33 + ((chunk >> (8 * 5)) & 0xff) * 33 * 33 + |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Sorter { | |
public function __construct(private array $array) {} | |
/** | |
* Sort the array by a specific key in ascending or descending order. | |
* | |
* @param string $key The key to sort by. | |
* @param string $order The order direction, 'asc' for ascending or 'desc' for descending. Default is 'asc'. | |
* @return self |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Pipeline { | |
public function __construct( | |
private mixed $data | |
) {} | |
public function pipe(callable ...$callbacks): static { | |
foreach ($callbacks as $callback) { | |
$this->data = $callback($this->data); | |
} | |
return $this; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Marker type for hashmaps without a value (i.e. hashsets). These won't | |
// allocate space for the value in the entry. | |
struct NoHashMapValue {}; | |
// HashMap entries are (key, value, hash) triplets, with a boolean indicating if | |
// they are an empty entry. Some clients may not need to use the value slot | |
// (e.g. implementers of sets, where the key is the value), in which case they | |
// should use NoHashMapValue. | |
template <typename Key, typename Value> | |
struct TemplateHashMapEntry { | |
static_assert((!std::is_same<Value, NoHashMapValue>::value)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template <typename T> | |
class Vector { | |
public: | |
using value_type = T; | |
using iterator = T *; | |
using const_iterator = const T *; | |
constexpr Vector() : start_(nullptr), length_(0) {} | |
constexpr Vector(T *data, size_t length) : start_(data), length_(length) { DCHECK(length == 0 || data != nullptr); } | |
static Vector<T> New(size_t length) { return Vector<T>(new T[length], length); } | |
constexpr Vector<T> Erase(size_t length) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
readonly class RelationshipInverse | |
{ | |
public function __construct( | |
public string $pivotTable, | |
public string $relatedForeignKey, | |
public string $localKey, | |
public string $type | |
) { | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |