Refactor/stage2 macro purge#123
Merged
Merged
Conversation
…_ptr_dtor Remove the PHP5 compatibility shim macro and replace all 54 callsites across 23 files with direct zval_ptr_dtor(&x) calls. The macro's do-while(0) wrapper and Z_ISUNDEF guard are unnecessary in PHP 7+ since zval_ptr_dtor is already safe to call on undef zvals. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
… macros Replace all 6 legacy PHP5TO7/PHP_SCYLLADB macro callsites with their direct equivalents and delete the macro definitions from include/php_driver.h. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…T macros Replace all callsites of PHP5TO7_ZEND_HASH_FOREACH_VAL, _NUM_KEY_VAL, _STR_KEY_VAL, _END and PHP5TO7_ZEND_HASH_GET_CURRENT_DATA[_EX] with bare Zend API. STR_KEY_VAL sites updated char* → zend_string* with ZSTR_VAL/ZSTR_LEN wrappers. Macro definitions removed from php_driver.h. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
- Update Timeuuid.stub.php to declare `implements Value, UuidInterface` with `string|int $uuid = UNKNOWN` constructor parameter - Regenerate Timeuuid_arginfo.h (register_class_Cassandra_Timeuuid now accepts both interface CEs and uses ZEND_ACC_NO_DYNAMIC_PROPERTIES) - Replace PHP_METHOD(Timeuuid, *) with ZEND_METHOD(Cassandra_Timeuuid, *) - Remove manual ZEND_BEGIN_ARG_INFO_EX blocks, PHP_ME table, PHP_FE_END - Remove toDateTime() which was not in the stub (no unit test coverage) - Replace INIT_CLASS_ENTRY + zend_register_internal_class with the generated register_class_Cassandra_Timeuuid() call in define function Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…L/ASSOC macros Inline all PHP5TO7_ZEND_HASH_FIND, PHP5TO7_ZEND_HASH_EXISTS, PHP5TO7_ZEND_HASH_UPDATE, PHP5TO7_ZEND_HASH_ADD, PHP5TO7_ZEND_HASH_DEL, PHP5TO7_ZEND_HASH_INDEX_FIND, PHP5TO7_ZEND_HASH_INDEX_UPDATE, PHP5TO7_ADD_ASSOC_ZVAL_EX, PHP5TO7_ADD_ASSOC_STRINGL_EX, and PHP5TO7_ZEND_HASH_ZVAL_COPY callsites with their bare modern Zend API equivalents across all src/ and util/ files, then remove those macro definitions from include/php_driver.h. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
- Add Blob.stub.php declaring `final class Blob implements Value` with constructor, type(), bytes(), toBinaryString(), __toString() - Generate Blob_arginfo.h from stub - Replace PHP_METHOD(Blob, *) with ZEND_METHOD(Cassandra_Blob, *) - Remove manual ZEND_BEGIN_ARG_INFO_EX blocks, PHP_ME table, PHP_FE_END - Replace INIT_CLASS_ENTRY + zend_register_internal_class with the generated register_class_Cassandra_Blob() call in define function - Retain php_driver_blob_init() as a legacy helper used by util/src/types.cpp php_driver_scalar_init() via TYPES_MAP macro Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
- Add Uuid.stub.php declaring `final class Uuid implements Value, UuidInterface` with constructor (string|UNKNOWN), uuid(), version(), type(), __toString() - Generate Uuid_arginfo.h from stub - Replace PHP_METHOD(Uuid, *) with ZEND_METHOD(Cassandra_Uuid, *) - Remove manual ZEND_BEGIN_ARG_INFO_EX blocks, PHP_ME table, PHP_FE_END - Replace INIT_CLASS_ENTRY + zend_register_internal_class with the generated register_class_Cassandra_Uuid() call in define function - Retain php_driver_uuid_init() as a legacy helper used by util/src/types.cpp php_driver_scalar_init() via TYPES_MAP macro Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…Y/NEXT_INDEX macros Complete Stage 2 Round 2/3 by replacing the three macros the previous agents missed: - PHP5TO7_ZEND_HASH_GET_CURRENT_KEY → zend_hash_get_current_key - PHP5TO7_ZEND_HASH_GET_CURRENT_KEY_EX → zend_hash_get_current_key_ex - PHP5TO7_ZEND_HASH_NEXT_INDEX_INSERT → (void)zend_hash_next_index_insert Files: Collection.cpp, Type/Tuple.cpp, Tuple.cpp, UserTypeValue.cpp, Database/Rows.cpp, util/src/types.cpp. Also remove the dead PHP5-era #else branch in DefaultSession.cpp bind_arguments() — the #if PHP_MAJOR_VERSION >= 7 branch is always taken since we require PHP 8.1+. Deletes the 3 macro definitions from include/php_driver.h. Only PHP5TO7_ZEND_OBJECT_GET/ECALLOC/INIT/INIT_EX remain (Round 5 — deferred until per-module handler refactor). Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…RS_START/END in stubbed modules Modernise argument parsing in Blob, Uuid, Inet, Bigint, Smallint, Tinyint, Float, Decimal, and Varint. All zend_parse_parameters() callsites (in both _init() helpers and arithmetic PHP_METHODs) are converted to ZEND_PARSE_PARAMETERS_START/END with Z_PARAM_* macros. All getThis() occurrences in affected methods are replaced with ZEND_THIS. Duration, Numeric, UuidInterface, and Value received additional linter-applied cleanup in the same pass. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…rfaces Generates stub-based arginfo for the three top-level interface types so that the already-wired register_class_* calls have proper typed method tables instead of the legacy PHP_ABSTRACT_ME/arginfo_none entries. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…ility Adds Inet.stub.php and generated Inet_arginfo.h for the already-wired Cassandra\Inet class. Also fixes signature incompatibility between the newly-typed Cassandra\Value::type(): Type interface and legacy collection classes (Set, Map, Collection, Tuple, UserTypeValue) by adding a typed return arginfo_type_return for their type() method entries. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Adds DateTime/Duration.stub.php and generated Duration_arginfo.h for the already-wired Cassandra\Duration class. The constructor accepts mixed for months/days/nanos to accommodate the int/float/string/Bigint union accepted by the C implementation. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Stage 2 Rounds 1-4 complete on this branch: - Round 1: PHP5TO7_SMART_STR_VAL/LEN, Z_IS_*, ADD_NEXT_INDEX_STRING - Round 2: PHP5TO7_ZEND_HASH_FOREACH_* and GET_CURRENT_* variants - Round 3: HASH_FIND/EXISTS/UPDATE/ADD/DEL/INDEX_*, ADD_ASSOC_*, ZVAL_COPY - Round 4: ZVAL_MAYBE_DESTROY (54 callsites) Round 5 (ZEND_OBJECT macros, 163 callsites) deferred per-module. Stage 3.5 Round A complete: Value/Numeric/UuidInterface interfaces, Uuid, Blob, Inet, Duration, Bigint, Smallint, Tinyint, Float, Decimal, Varint all wired to stub-generated arginfo. 27 stubs total (was 14). Stage 3.6 partial: 70 zend_parse_parameters callsites remain (was 107) in non-stubbed modules. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Replace 25 individual exception .cpp files and per-class php_driver_define_*() calls with a single exceptions.stub.php, generated exceptions_arginfo.h, and a consolidated exceptions.c that registers all 25 Cassandra exception classes in the correct dependency order. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Commit the PHP stub source that was used to generate exceptions_arginfo.h (accidentally omitted from previous commit); force-added because gitignore contains ex*.php from old PHP build artefact patterns. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Replaces legacy INIT_CLASS_ENTRY/PHP_ME/PHP_FE_END pattern in Type.cpp with stub-generated register_class_Cassandra_Type() and updates all static factory method implementations to ZEND_METHOD(Cassandra_Type, ...). Abstract name()/toString() declared as returning ?string to accommodate UserType which can return null. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
- Include Type/Type_arginfo.h - Rename PHP_METHOD(Type, *) to ZEND_METHOD(Cassandra_Type, *) - Use ZEND_PARSE_PARAMETERS_START/END for collection/set/map factories - Replace INIT_CLASS_ENTRY + zend_register_internal_class with register_class_Cassandra_Type() - Remove all manual ZEND_BEGIN_ARG_INFO_EX blocks and PHP_FE_END table Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Replaces legacy PHP_ME/ZEND_BEGIN_ARG_INFO table with stub-generated register_class_Cassandra_Type_Scalar(). Renames PHP_METHOD(TypeScalar, *) to ZEND_METHOD(Cassandra_Type_Scalar, *). Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Replaces PHP_ME/ZEND_BEGIN_ARG_INFO with stub-generated registration. Renames PHP_METHOD(TypeCollection, *) to ZEND_METHOD(Cassandra_Type_Collection, *). Removes PHP 7-era conditional includes and legacy method table. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Replaces legacy method table with stub-generated registration. Renames PHP_METHOD(TypeSet, *) to ZEND_METHOD(Cassandra_Type_Set, *). Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Replaces legacy method table with stub-generated registration. Renames PHP_METHOD(TypeMap, *) to ZEND_METHOD(Cassandra_Type_Map, *). Removes PHP 7-era conditional includes. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Replaces legacy method table with stub-generated registration. Renames PHP_METHOD(TypeTuple, *) to ZEND_METHOD(Cassandra_Type_Tuple, *). Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Replaces legacy method table with stub-generated registration. Renames PHP_METHOD(TypeUserType, *) to ZEND_METHOD(Cassandra_Type_UserType, *). name()/keyspace() declared ?string to match implementation returning null. Removes PHP 7-era conditional includes. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Scalar types like text/ascii/int/boolean return PHP primitives, not Cassandra\Value objects. Using mixed avoids the fatal type-enforcement error at runtime. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…th arithmetic
Two mechanical cleanups across 36 source files:
1. ZEND_STRL macro:
zend_hash_str_update(ht, "useTokenAwareRouting", sizeof("useTokenAwareRouting") - 1, v)
→ zend_hash_str_update(ht, ZEND_STRL("useTokenAwareRouting"), v)
ZEND_STRL("str") expands to ("str"), (sizeof("str")-1) — the canonical
Zend idiom for string literal + length. 88 occurrences converted.
2. Cancelling +1-1 arithmetic:
zend_hash_str_find(ht, hash_key, (size_t)(hash_key_len + 1 - 1))
→ zend_hash_str_find(ht, hash_key, hash_key_len)
The +1 was a PHP5-era null-terminator inclusion that was immediately
cancelled by -1. All occurrences removed (includes nested patterns
like Z_STRLEN(x) + 1 - 1 → Z_STRLEN(x)).
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
- Constructors now typed as int|float|string|ClassName instead of mixed - Arithmetic method params changed from mixed to Numeric (matches interface) - Arithmetic return types changed from Numeric to static (correct covariant return) - Unary ops (abs/neg/sqrt) return static instead of Numeric - Static factory min()/max() return static instead of concrete class name - Duration constructor params typed as int|float|string|Bigint (matches get_param()) - Regenerated all *_arginfo.h files from updated stubs Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…able params - Cluster\Builder: all fluent with*() methods now return static instead of Builder; withBlackListHosts/DCs/WhiteListHosts/DCs changed from single string to variadic string (matches php_driver_parse_hosts impl) - SSLOptions\Builder: all fluent with*() return static; withPrivateKey passphrase made optional nullable; build() return type fixed to \Cassandra\SSLOptions (was missing leading backslash / fully-qualified) - DateTime\Date: fromDateTime() returns static; toDateTime() param is ?Time = null (was non-nullable with UNKNOWN sentinel) - DateTime\Time: fromDateTime() returns static - DateTime\Timestamp: fromDateTime() returns static All arginfo files regenerated; clean build passes; 803 unit tests pass. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
… stubs - Type::tuple() variadic upgraded from mixed to Type (only Type objects accepted) - Collection/Set __construct: mixed → Type|string (matches C++ branch logic) - Map __construct: mixed, mixed → Type|string, Type|string - Collection::key(), Set::key(), Tuple::key() → int (always RETURN_LONG) - UserTypeValue::key() → string (always RETURN_STR) - Regenerate all affected _arginfo.h files; clean build passes; 803 unit tests pass Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Stage 3.5 stub coverage now at 44 stubs. Completed rounds: - Round A: all foundational value types + interfaces (14 classes) - Round B: Type system (8 classes) - Round C: Collections (5 classes) - Round F: TimestampGenerator (3 classes) - Round G: Exceptions (25 classes, consolidated) All stubs strictly typed: - concrete return types instead of mixed/base - 'static' for fluent methods and factory methods - 'int|float|string|T' constructor unions matching C dispatch - 'Type|string' for collection type parameters - nullable/optional params use '?T = null' not 'mixed' Remaining: Round D (Database, 14 classes) + Round E (Schema, 14 classes) Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Inline ecalloc/zend_object_std_init in php_driver_blob_new and move offset/free_obj setup to php_driver_define_Blob. Replace PHP5TO7_ZEND_OBJECT_GET(blob, object) with direct php_driver_blob_object_fetch() call in properties and free functions. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Inline ecalloc/zend_object_std_init in php_driver_uuid_new and move offset/free_obj setup to php_driver_define_Uuid. Replace PHP5TO7_ZEND_OBJECT_GET(uuid, object) with direct fetch calls. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Inline ecalloc/zend_object_std_init in php_driver_inet_new and move offset/free_obj setup to php_driver_define_Inet. Replace PHP5TO7_ZEND_OBJECT_GET(inet, object) with direct fetch calls. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Inline ecalloc/zend_object_std_init in php_driver_duration_new and move offset/free_obj setup to php_driver_define_Duration. Replace PHP5TO7_ZEND_OBJECT_GET(duration, object) with direct fetch calls. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Inline ecalloc/zend_object_std_init in php_driver_future_value_new and move offset/free_obj setup to php_driver_define_FutureValue. Replace PHP5TO7_ZEND_OBJECT_GET(future_value, object) with direct fetch call. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…n.cpp Inline ecalloc/zend_object_std_init in php_driver_future_session_new and move offset/free_obj setup to php_driver_define_FutureSession. Replace PHP5TO7_ZEND_OBJECT_GET(future_session, object) with direct fetch call. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…ions.cpp Inline ecalloc/zend_object_std_init in php_driver_execution_options_new and move offset/free_obj to php_driver_define_ExecutionOptions. Replace PHP5TO7_ZEND_OBJECT_GET(execution_options, object) with direct fetch call. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…nt.cpp Inline ecalloc/zend_object_std_init in php_driver_batch_statement_new and move offset/free_obj to php_driver_define_BatchStatement. Replace PHP5TO7_ZEND_OBJECT_GET(statement, object) and INIT_EX with direct inline code. Also fix END_EXTERN_C placement to wrap define function. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Inline ecalloc/zend_object_std_init in php_driver_bigint_new and move offset/free_obj to php_driver_define_Bigint. Replace all PHP5TO7_ZEND_OBJECT_GET(numeric, object) with direct fetch calls. Uses INIT_EX pattern with bigint-specific handlers. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Inline ecalloc/zend_object_std_init in php_driver_smallint_new and move offset/free_obj to php_driver_define_Smallint. Replace all PHP5TO7_ZEND_OBJECT_GET(numeric, object) with direct fetch calls. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Inline ecalloc/zend_object_std_init in php_driver_tinyint_new and move offset/free_obj to php_driver_define_Tinyint. Replace all PHP5TO7_ZEND_OBJECT_GET(numeric, object) with direct fetch calls. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Inline ecalloc/zend_object_std_init in php_driver_float_new and move offset/free_obj to php_driver_define_Float. Replace all PHP5TO7_ZEND_OBJECT_GET(numeric, object) with direct fetch calls. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Inline ecalloc/zend_object_std_init in php_driver_varint_new and move offset/free_obj to php_driver_define_Varint. Replace all PHP5TO7_ZEND_OBJECT_GET(numeric, object) with direct fetch calls. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Inline ecalloc/zend_object_std_init in php_driver_decimal_new and move offset/free_obj to php_driver_define_Decimal. Replace all PHP5TO7_ZEND_OBJECT_GET(numeric, object) with direct fetch calls. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…n.cpp Inline ecalloc/zend_object_std_init in php_driver_future_session_new and move offset/free_obj setup to php_driver_define_FutureSession. Replace PHP5TO7_ZEND_OBJECT_GET(future_session, object) with direct fetch call. Also fix END_EXTERN_C placement to wrap define function. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…a classes - Add .stub.php definitions for Schema, DefaultSchema, Keyspace, DefaultKeyspace, Table, DefaultTable, Column, DefaultColumn, Index, DefaultIndex, MaterializedView, DefaultMaterializedView, Function_, DefaultFunction, Aggregate, DefaultAggregate - Generate *_arginfo.h files from each stub via gen_stub.php - Replace legacy ZEND_BEGIN_ARG_INFO_EX + PHP_ABSTRACT_ME/PHP_ME/PHP_FE_END blocks with stub-generated method tables and register_class_* calls - Rename PHP_METHOD(Foo, bar) to ZEND_METHOD(Cassandra_Foo, bar) in all Default* implementation files to match stub-generated declarations - Note: Cassandra\Function renamed to Cassandra\Function_ (PHP keyword safety) Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…ata stubs Stage 3.5 Round D (Database surface, 14 classes): Session (interface), DefaultSession, Statement (interface/abstract), SimpleStatement, PreparedStatement, BatchStatement, ExecutionOptions, Future (interface), FutureClose, FuturePreparedStatement, FutureRows, FutureSession, FutureValue, Rows Stage 3.5 Round E (Schema metadata, 16 classes): Schema, DefaultSchema, Keyspace, DefaultKeyspace, Table, DefaultTable, Column, DefaultColumn, Index, DefaultIndex, MaterializedView, DefaultMaterializedView, Function, DefaultFunction, Aggregate, DefaultAggregate Also: - Fix DefaultKeyspace.cpp: method name backreferences (\1) left by agent's sed substitution replaced with correct names; added missing #include "DefaultKeyspace_arginfo.h" - Fix Statement.cpp, Session.cpp, Future.cpp: php_driver_define_* functions moved inside BEGIN_EXTERN_C/END_EXTERN_C so they export with C linkage, resolving undefined symbol at .so load time Build: clean. Unit tests: 803 passed, 27 skipped. Stubs total: 60 (target: 86 classes). Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…ro-purge # Conflicts: # src/Blob.cpp # src/Collection.cpp # src/Database/DefaultIndex.cpp # src/DefaultSession.cpp # src/FuturePreparedStatement.cpp # src/FutureSession.cpp
The stub-generated *_arginfo.h files call zend_register_internal_class_with_flags, which was introduced in PHP 8.4. Provide a static inline shim so the generated headers compile against PHP 8.3 without regenerating the stubs.
PHP 8.4's gen_stub emits zend_register_internal_class_with_flags(), which doesn't exist before PHP 8.4 and broke the PHP 8.3 build. Regenerating with PHP 8.3's gen_stub produces the equivalent two-step pattern (zend_register_internal_class_ex + ce_flags |=) that compiles on all supported versions. Drops the now-unneeded shim from php_driver.h.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.