Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
218cf02
refactor(stage2-round4): replace PHP5TO7_ZVAL_MAYBE_DESTROY with zval…
Apr 26, 2026
b4f5c1e
refactor(stage2-round1): inline PHP5TO7_SMART_STR/ADD_NEXT_INDEX/Z_IS…
Apr 26, 2026
13bca07
refactor(stage2-round2): replace PHP5TO7_ZEND_HASH_FOREACH/GET_CURREN…
Apr 26, 2026
24a38a2
refactor(datetime): wire Timeuuid to stub-generated arginfo
Apr 26, 2026
6a5c5da
refactor(stage2-round3): replace PHP5TO7_ZEND_HASH_FIND/UPDATE/ADD/DE…
Apr 26, 2026
9f3919c
refactor(blob): wire Blob to stub-generated arginfo
Apr 26, 2026
48b352b
refactor(uuid): wire Uuid to stub-generated arginfo
Apr 26, 2026
e3fea52
refactor(stage2-round2-cleanup): inline remaining HASH_GET_CURRENT_KE…
Apr 26, 2026
10d552b
refactor(zpp): replace zend_parse_parameters with ZEND_PARSE_PARAMETE…
Apr 26, 2026
dfb95fc
refactor(stub): wire Bigint to stub-generated arginfo
Apr 26, 2026
133e623
refactor(stub): wire Smallint to stub-generated arginfo
Apr 26, 2026
89e16e2
refactor(stub): wire Tinyint to stub-generated arginfo
Apr 26, 2026
b5cf656
refactor(stub): wire Float to stub-generated arginfo
Apr 26, 2026
bc413ec
refactor(stub): wire Decimal to stub-generated arginfo
Apr 26, 2026
6567c2b
refactor(stub): wire Varint to stub-generated arginfo
Apr 26, 2026
8c6c12c
feat(stubs): add PHP stubs for Value, UuidInterface, and Numeric inte…
Apr 26, 2026
0cc1415
feat(stubs): add Inet stub and fix Value interface signature compatib…
Apr 26, 2026
0b7c90a
feat(stubs): add Duration stub and generated arginfo
Apr 26, 2026
b97bc0c
chore: gitignore
Apr 26, 2026
5419cde
docs(plan): mark Stage 2 Rounds 1-4 done; update stub coverage progress
Apr 26, 2026
f1b5746
feat(stubs): add exception class stubs (Stage 3.5 Round G)
Apr 26, 2026
e35a066
feat(stubs): add exceptions.stub.php source file
Apr 26, 2026
1328c43
feat(stub): add Type base class stub and generate arginfo
Apr 26, 2026
3b7c680
refactor(Type): wire Type.cpp to stub-generated arginfo
Apr 26, 2026
0a824ee
feat(stub): add Type\Scalar stub and wire to arginfo
Apr 26, 2026
4d70d5f
feat(stub): add Type\Collection stub and wire to arginfo
Apr 26, 2026
fe6951f
feat(stub): add Type\Set stub and wire to arginfo
Apr 26, 2026
000f92b
feat(stub): add Type\Map stub and wire to arginfo
Apr 26, 2026
3e85f29
feat(stub): add Type\Tuple stub and wire to arginfo
Apr 26, 2026
6994006
feat(stub): add Type\UserType stub and wire to arginfo
Apr 26, 2026
f0fe310
feat(stub): add Type\Custom stub and wire to arginfo
Apr 26, 2026
adba36d
feat(stub): add Collection stub and wire to arginfo
Apr 26, 2026
80dcec4
feat(stub): add Set stub and wire to arginfo
Apr 26, 2026
810b82c
feat(stub): add Map stub and wire to arginfo
Apr 26, 2026
499b9ff
feat(stub): add Tuple stub and wire to arginfo
Apr 26, 2026
7e5f03a
feat(stub): add UserTypeValue stub and wire to arginfo
Apr 26, 2026
219715f
feat(stubs): add TimestampGenerator stubs (Stage 3.5 Round F)
Apr 26, 2026
19d31c6
refactor(cluster): replace PHP5TO7_ZEND_OBJECT macros (Stage 2 Round 5)
Apr 26, 2026
41cdef5
fix(stub): Type\Scalar::create() returns mixed, not Cassandra\Value
Apr 26, 2026
768713b
refactor: replace sizeof("lit")-1 with ZEND_STRL; eliminate +1-1 leng…
Apr 26, 2026
b616526
refactor(stub): tighten parameter and return types in numeric stubs
Apr 26, 2026
801df16
refactor(stubs): tighten return types to static and fix variadic/null…
Apr 26, 2026
ce82fb2
refactor(stub): tighten parameter and return types in collection/Type…
Apr 26, 2026
07d2107
docs(plan): update stub coverage progress — Rounds B, C, F, G complete
Apr 26, 2026
88fe6be
refactor(round5): remove PHP5TO7_ZEND_OBJECT macros from Blob.cpp
Apr 26, 2026
675a800
refactor(round5): remove PHP5TO7_ZEND_OBJECT macros from Uuid.cpp
Apr 26, 2026
14175c3
refactor(round5): remove PHP5TO7_ZEND_OBJECT macros from Inet.cpp
Apr 26, 2026
549bf84
refactor(round5): remove PHP5TO7_ZEND_OBJECT macros from Duration.cpp
Apr 26, 2026
df8db74
refactor(round5): remove PHP5TO7_ZEND_OBJECT macros from FutureValue.cpp
Apr 26, 2026
910476a
refactor(round5): remove PHP5TO7_ZEND_OBJECT macros from FutureSessio…
Apr 26, 2026
0909026
refactor(round5): remove PHP5TO7_ZEND_OBJECT macros from ExecutionOpt…
Apr 26, 2026
3c77d5b
refactor(round5): remove PHP5TO7_ZEND_OBJECT macros from BatchStateme…
Apr 26, 2026
3921e7a
refactor(round5): remove PHP5TO7_ZEND_OBJECT macros from Bigint.cpp
Apr 26, 2026
4ac61e0
refactor(round5): remove PHP5TO7_ZEND_OBJECT macros from Smallint.cpp
Apr 26, 2026
90bd011
refactor(round5): remove PHP5TO7_ZEND_OBJECT macros from Tinyint.cpp
Apr 26, 2026
e438786
refactor(round5): remove PHP5TO7_ZEND_OBJECT macros from Float.cpp
Apr 26, 2026
4b59d50
refactor(round5): remove PHP5TO7_ZEND_OBJECT macros from Varint.cpp
Apr 26, 2026
d7b08bf
refactor(round5): remove PHP5TO7_ZEND_OBJECT macros from Decimal.cpp
Apr 26, 2026
a6a8d11
refactor(round5): remove PHP5TO7_ZEND_OBJECT macros from FutureSessio…
Apr 26, 2026
d84683a
feat(database): add PHP stubs and wire arginfo for all schema metadat…
Apr 26, 2026
99dd8a8
feat(stubs): Stage 3.5 Rounds D+E — Database surface and schema metad…
Apr 26, 2026
8e331bd
Merge remote-tracking branch 'origin/v1.3.x' into refactor/stage2-mac…
CodeLieutenant May 21, 2026
e1222df
fix(php83): shim zend_register_internal_class_with_flags for PHP < 8.4
CodeLieutenant May 21, 2026
a108718
fix(arginfo): regenerate stubs with PHP 8.3 gen_stub for backward compat
CodeLieutenant May 21, 2026
385dc7a
chore: gitignore .claude/scheduled_tasks.lock and untrack it
CodeLieutenant May 21, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .claude/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"Skill(php-development)",
"Skill(php-expert)",
"Skill(cmake-review)",
"Bash(pie build *)"
"Bash(pie build *)",
"Bash(git *)"
]
}
}
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Directories to ignore
.claude/worktrees
.claude/scheduled_tasks.lock
/.idea/
/.vagrant/
/bin/
Expand Down Expand Up @@ -57,4 +59,4 @@ cassandra.log
/**/.idea/
php-old/
target/
docker/scylladb/certs/
docker/scylladb/certs/
22 changes: 14 additions & 8 deletions docs/plans/REFACTORING_PLAN.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,15 @@ Stage 3 in the full plan. Bigger commitment; gates Stage 4.

### Round D — Universal stub coverage (target: v1.5.0 or v1.6.0)

Stage 3.5 in the full plan. **86 classes total, 14 done, 72 to go.** Order:

- [ ] Round A foundational (12 classes): `Cassandra` facade, `Value`, `Numeric`, `UuidInterface`, `Uuid`, `Inet`, `Blob`, `Duration`, `Bigint`, `Smallint`, `Tinyint`, `Float`, `Decimal`, `Varint`, `Custom`.
Stage 3.5 in the full plan. **86 classes total, 27 done, 59 to go.** Order:

- [x] Round A foundational: `Value` (interface), `Numeric` (interface), `UuidInterface` (interface), `Uuid`, `Blob`, `Inet`, `Duration`, `Bigint`, `Smallint`, `Tinyint`, `Float`, `Decimal`, `Varint`, `Timeuuid` (wired). All stubs strictly typed (concrete return types, `static` for fluent/factory, `int|float|string|T` constructors). Done on `refactor/stage2-macro-purge`.
- [x] Round B Type system: `Type`, `Type\Scalar`, `Type\Collection`, `Type\Set`, `Type\Map`, `Type\Tuple`, `Type\UserType`, `Type\Custom`. Strictly typed. Done on `refactor/stage2-macro-purge`.
- [x] Round C Collections: `Collection`, `Set`, `Map`, `Tuple`, `UserTypeValue`. Constructor types tightened (`Type|string`); `key()` typed as `int` or `string` per implementation. Done on `refactor/stage2-macro-purge`.
- [x] Round F TimestampGenerator: `TimestampGenerator` (interface), `Monotonic`, `ServerSide`. Done on `refactor/stage2-macro-purge`.
- [x] Round G Exceptions: all 25 exception classes consolidated into `exceptions.stub.php`. Done on `refactor/stage2-macro-purge`.
- [ ] Round D Database surface: `Session`, `DefaultSession`, `SimpleStatement`, `PreparedStatement`, `BatchStatement`, `ExecutionOptions`, `Future*`, `Rows`.
- [ ] Round E Schema metadata: `Schema`, `Keyspace`, `Table`, `Column`, `Index`, `MaterializedView`, `Function`, `Aggregate` classes.
- [ ] Round B Type system (8 classes): `Type`, `Type\{Scalar,Collection,Set,Map,Tuple,UserType,Custom}`.
- [ ] Round C Collections (5 classes): `Collection`, `Set`, `Map`, `Tuple`, `UserTypeValue`.
- [ ] Round D Database (14 classes): `Session`, `DefaultSession`, `Statement`, `SimpleStatement`, `PreparedStatement`, `BatchStatement`, `ExecutionOptions`, `Future`, `FutureClose`, `FuturePreparedStatement`, `FutureRows`, `FutureSession`, `FutureValue`, `Rows`.
Expand All @@ -72,11 +78,11 @@ Stage 3.6 in the full plan. **107 `zend_parse_parameters` callsites across 37 fi

Stage 2 in the full plan. Previously attempted as a flat sweep (PR #122 wave-1) and reverted because it caused collection/UDT round-trip regressions and a buffer overflow. Redo *module-by-module alongside Round D's stub work*.

- [ ] Round 1 — pure renames (6 macros, 22 callsites): `PHP5TO7_SMART_STR_VAL/LEN`, `PHP_SCYLLADB_Z_IS_*`, `PHP5TO7_ADD_NEXT_INDEX_STRING`. Lowest risk; can ship standalone.
- [ ] Round 2 — hashtable iteration (8 macros, ~188 callsites): `PHP5TO7_ZEND_HASH_FOREACH_*`, `GET_CURRENT_*`. Medium risk — the `STR_KEY_VAL` `char*` ↔ `zend_string*` adaptation is the historical landmine. Must include round-trip tests for Collection/Map/Set/UDT in CI before merging.
- [ ] Round 3 — hashtable mutation (11 macros, ~161 callsites): `PHP5TO7_ZEND_HASH_FIND/EXISTS/UPDATE/ADD/DEL/INDEX_*`, `ADD_ASSOC_*`, `ZVAL_COPY`.
- [ ] Round 4 — zval lifecycle (1 macro, 58 callsites): `PHP5TO7_ZVAL_MAYBE_DESTROY`. Drop the `do { … } while (0)` wrapper since callsites are inlined code, not macro expansions.
- [ ] Round 5 — load-bearing (4 macros, ~168 callsites): `PHP5TO7_ZEND_OBJECT_GET/ECALLOC/INIT/INIT_EX`. Coupled to handler refactor; do per-module after the module's stub + Z_PARAM port.
- [x] Round 1 — pure renames (6 macros): `PHP5TO7_SMART_STR_VAL/LEN`, `PHP_SCYLLADB_Z_IS_*`, `PHP5TO7_ADD_NEXT_INDEX_STRING`. Done on `refactor/stage2-macro-purge`.
- [x] Round 2 — hashtable iteration: `PHP5TO7_ZEND_HASH_FOREACH_*`, `GET_CURRENT_*` (all variants). Done; STR_KEY_VAL adapted to `zend_string *`.
- [x] Round 3 — hashtable mutation: `PHP5TO7_ZEND_HASH_FIND/EXISTS/UPDATE/ADD/DEL/INDEX_*`, `ADD_ASSOC_*`, `ZVAL_COPY`. Done.
- [x] Round 4 — zval lifecycle: `PHP5TO7_ZVAL_MAYBE_DESTROY` → `zval_ptr_dtor`. Done (54 callsites).
- [ ] Round 5 — load-bearing (4 macros, 163 callsites): `PHP5TO7_ZEND_OBJECT_GET/ECALLOC/INIT/INIT_EX`. Deferred per-module alongside handler refactor (Stage 4). 163 callsites remain in `php_driver.h` macros.
- [ ] **Stage 2.3 — delete `util/`** (12 headers + 10 cpp files): inline thin wrappers into owning modules; replace `uthash.h` with `zend_hash`; replace `php_driver_ref` with native resource refcounting (depends on Round B).

### Round G — Module ports to C23 (target: v1.6.0–v2.0.0)
Expand Down
92 changes: 0 additions & 92 deletions include/php_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ typedef unsigned long ulong;

#define PHP5TO7_ZEND_OBJECT_GET(type_name, object) php_driver_##type_name##_object_fetch(object)

#define PHP5TO7_SMART_STR_VAL(ss) ((ss).s ? (ss).s->val : NULL)
#define PHP5TO7_SMART_STR_LEN(ss) ((ss).s ? (ss).s->len : 0)

#define PHP5TO7_ZEND_OBJECT_ECALLOC(type_name, ce) \
(php_driver_##type_name *)ecalloc(1, sizeof(php_driver_##type_name) + zend_object_properties_size(ce))

Expand All @@ -76,95 +73,6 @@ typedef unsigned long ulong;
return &self->zendObject; \
} while (0)

#define PHP5TO7_ADD_ASSOC_ZVAL_EX(zv, key, len, val) add_assoc_zval_ex((zv), (key), (size_t)(len - 1), val)

#define PHP5TO7_ADD_ASSOC_STRINGL_EX(zv, key, key_len, str, str_len) \
add_assoc_stringl_ex((zv), (key), (size_t)(key_len - 1), (char *)(str), (size_t)(str_len))

#define PHP5TO7_ADD_NEXT_INDEX_STRING(zv, str) add_next_index_string((zv), (char *)(str));

#define PHP5TO7_ZEND_HASH_FOREACH_VAL(ht, _val) ZEND_HASH_FOREACH_VAL(ht, _val)

#define PHP5TO7_ZEND_HASH_FOREACH_NUM_KEY_VAL(ht, _h, _val) ZEND_HASH_FOREACH_NUM_KEY_VAL(ht, _h, _val)

#if PHP_VERSION_ID >= 80200

#define PHP5TO7_ZEND_HASH_FOREACH_STR_KEY_VAL(ht, _key, _val) \
ZEND_HASH_FOREACH(ht, 0); \
if (__key) \
{ \
(_key) = ZSTR_VAL(__key); \
} \
else \
{ \
(_key) = NULL; \
} \
_val = _z;

#else

#define PHP5TO7_ZEND_HASH_FOREACH_STR_KEY_VAL(ht, _key, _val) \
ZEND_HASH_FOREACH(ht, 0); \
if (_p->key) \
{ \
(_key) = _p->key->val; \
} \
else \
{ \
(_key) = NULL; \
} \
_val = _z;

#endif

#define PHP5TO7_ZEND_HASH_FOREACH_END(ht) ZEND_HASH_FOREACH_END()

#define PHP5TO7_ZEND_HASH_GET_CURRENT_DATA(ht, res) ((res = zend_hash_get_current_data((ht))) != NULL)

#define PHP5TO7_ZEND_HASH_GET_CURRENT_DATA_EX(ht, res, pos) ((res = zend_hash_get_current_data_ex((ht), (pos))) != NULL)

#define PHP5TO7_ZEND_HASH_GET_CURRENT_DATA_EX(ht, res, pos) ((res = zend_hash_get_current_data_ex((ht), (pos))) != NULL)

#define PHP5TO7_ZEND_HASH_GET_CURRENT_KEY(ht, str_index, num_index) \
zend_hash_get_current_key((ht), (str_index), (num_index))

#define PHP5TO7_ZEND_HASH_GET_CURRENT_KEY_EX(ht, str_index, num_index, pos) \
zend_hash_get_current_key_ex((ht), (str_index), (num_index), pos)

#define PHP5TO7_ZEND_HASH_EXISTS(ht, key, len) zend_hash_str_exists((ht), (key), (size_t)(len - 1))

#define PHP5TO7_ZEND_HASH_FIND(ht, key, len, res) ((res = zend_hash_str_find((ht), (key), (size_t)(len - 1))) != NULL)

#define PHP5TO7_ZEND_HASH_INDEX_FIND(ht, index, res) \
((res = zend_hash_index_find((ht), (zend_ulong)(index))) != NULL)

#define PHP5TO7_ZEND_HASH_NEXT_INDEX_INSERT(ht, val, val_size) ((void)zend_hash_next_index_insert((ht), (val)))

#define PHP5TO7_ZEND_HASH_UPDATE(ht, key, len, val, val_size) \
((void)zend_hash_str_update((ht), (key), (size_t)(len - 1), (val)))

#define PHP5TO7_ZEND_HASH_INDEX_UPDATE(ht, index, val, val_size) ((void)zend_hash_index_update((ht), (index), (val)))

#define PHP5TO7_ZEND_HASH_ADD(ht, key, len, val, val_size) \
((void)zend_hash_str_add((ht), (key), (size_t)(len - 1), (val)))

#define PHP5TO7_ZEND_HASH_DEL(ht, key, len) ((zend_hash_str_del((ht), (key), (size_t)(len - 1))) == SUCCESS)

#define PHP5TO7_ZEND_HASH_ZVAL_COPY(dst, src) zend_hash_copy((dst), (src), (copy_ctor_func_t)zval_add_ref);

#define PHP_SCYLLADB_Z_IS_BOOL_P(zv) (Z_TYPE_P(zv) == IS_TRUE || Z_TYPE_P(zv) == IS_FALSE)
#define PHP_SCYLLADB_Z_IS_FALSE_P(zv) (Z_TYPE_P(zv) == IS_FALSE)
#define PHP_SCYLLADB_Z_IS_TRUE_P(zv) (Z_TYPE_P(zv) == IS_TRUE)

#define PHP5TO7_ZVAL_MAYBE_DESTROY(zv) \
do \
{ \
if (!Z_ISUNDEF(zv)) \
{ \
zval_ptr_dtor(&(zv)); \
ZVAL_UNDEF(&(zv)); \
} \
} while (0)

extern zend_module_entry php_driver_module_entry;
#define phpext_cassandra_ptr &php_driver_module_entry
Expand Down
27 changes: 1 addition & 26 deletions include/php_driver_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -674,31 +674,7 @@ extern PHP_SCYLLADB_API zend_class_entry *php_driver_tuple_ce;
extern PHP_SCYLLADB_API zend_class_entry *php_driver_user_type_value_ce;

/* Exceptions */
void php_driver_define_Exception();
void php_driver_define_InvalidArgumentException();
void php_driver_define_DomainException();
void php_driver_define_LogicException();
void php_driver_define_RuntimeException();
void php_driver_define_TimeoutException();
void php_driver_define_ExecutionException();
void php_driver_define_ReadTimeoutException();
void php_driver_define_WriteTimeoutException();
void php_driver_define_UnavailableException();
void php_driver_define_TruncateException();
void php_driver_define_ValidationException();
void php_driver_define_InvalidQueryException();
void php_driver_define_InvalidSyntaxException();
void php_driver_define_UnauthorizedException();
void php_driver_define_UnpreparedException();
void php_driver_define_ConfigurationException();
void php_driver_define_AlreadyExistsException();
void php_driver_define_AuthenticationException();
void php_driver_define_ProtocolException();
void php_driver_define_ServerException();
void php_driver_define_IsBootstrappingException();
void php_driver_define_OverloadedException();
void php_driver_define_DivideByZeroException();
void php_driver_define_RangeException();
void php_driver_define_Exceptions(void);

/* Types */
void php_driver_define_Value();
Expand Down Expand Up @@ -749,7 +725,6 @@ extern PHP_SCYLLADB_API zend_class_entry *php_driver_execution_exception_ce;
extern PHP_SCYLLADB_API zend_class_entry *php_driver_truncate_exception_ce;
extern PHP_SCYLLADB_API zend_class_entry *php_driver_write_timeout_exception_ce;
extern PHP_SCYLLADB_API zend_class_entry *php_driver_read_timeout_exception_ce;
extern PHP_SCYLLADB_API zend_class_entry *php_driver_truncate_exception_ce;
extern PHP_SCYLLADB_API zend_class_entry *php_driver_unavailable_exception_ce;
extern PHP_SCYLLADB_API zend_class_entry *php_driver_validation_exception_ce;
extern PHP_SCYLLADB_API zend_class_entry *php_driver_invalid_syntax_exception_ce;
Expand Down
Loading
Loading