Skip to content

refactor: standardize parameter naming and improve code clarity#13

Merged
coreyhn merged 5 commits into
mainfrom
refactor/standardize-naming
Jul 2, 2025
Merged

refactor: standardize parameter naming and improve code clarity#13
coreyhn merged 5 commits into
mainfrom
refactor/standardize-naming

Conversation

@coreyhn
Copy link
Copy Markdown
Collaborator

@coreyhn coreyhn commented Jul 2, 2025

This PR is a small tidy-up and naming consistency sweep (mostly for my own peace of mind), but it should make things clearer for anyone else wandering on through.

  • On the Rust side, I’ve improved parameter naming and types for ergonomics: using &str and &[u8] instead of &String and &Vec<u8], and switching to more descriptive names like identifier. I also removed redundant _str suffixes where the type is already clear, keeping things concise but readable. I also standardized JSON parameter naming in the FFI interface, adding a _json suffix where appropriate for consistency with other parameters like context_json, items_json, and terms_json.
  • On the PHP side, I’ve renamed the $ffiCall parameter to $operation to better reflect its purpose as a full operation, not just a raw FFI call. This lines up with the executeFFIOperation method and makes the intent more obvious.

This is a bit of self-soothing PR (maybe more than a bit), but it makes the code more self-documenting and pleasant to work with (at least for me).

coreyhn and others added 5 commits July 2, 2025 17:07
Add `_json` suffix to the `config` parameter in `new_client()` to match
the consistent naming pattern used by all other JSON parameters
(`context_json`, `items_json`, `terms_json`). Updates both the Rust FFI
function signature and the C header declaration to use `config_json`.

This creates consistent naming across the FFI interface where all
JSON string parameters are explicitly marked with the `_json` suffix,
making the parameter types clear.
Remove unnecessary `_str` suffixes from function parameters and
internal variables where the type is already clear from context.

This simplifies variable names while maintaining clarity, as the string
type is evident from function signatures and usage context.
This change updates function parameters throughout the codebase to use
more descriptive names and idiomatic Rust types.

Function signatures now use `&str` instead of `&String` and `&[u8]`
instead of `&Vec<u8>` for better flexibility. These types accept both
owned and borrowed data, making the functions easier to call from
different contexts.

The changes also improve consistency by using descriptive variable names
like `identifier` instead of `ident`, making the code more self-documenting.
…larity

This change updates the parameter name to better describe what it
represents, which is a complete operation that includes setup, execution,
and result processing, rather than just a simple FFI call. The new name
aligns with the method name `executeFFIOperation` and makes the code
more self-documenting.
@coreyhn coreyhn requested a review from calvinbrewer July 2, 2025 23:38
@coreyhn coreyhn merged commit a6aa6e2 into main Jul 2, 2025
@coreyhn coreyhn deleted the refactor/standardize-naming branch July 2, 2025 23:44
coreyhn added a commit that referenced this pull request Jul 6, 2025
This change updates utility function names and parameters to better
reflect their ownership semantics.

Changes include:
- Rename `string_to_c_str` to `string_to_c_string` to correctly indicate
  it returns an owned `CString` rather than a borrowed `CStr`
- Update parameter names from `c_string_ptr` to `c_str_ptr` in functions
  that work with borrowed `CStr` types

The naming now follows this pattern: `c_str` for borrowed
C strings (`CStr`) and `c_string` for owned C strings (`CString`).
This makes ownership semantics clear.

This builds upon and improves the standardization in PR #13.
coreyhn added a commit that referenced this pull request Jul 6, 2025
This change updates utility function names and parameters to better
reflect their ownership semantics.

Changes include:
- Rename `string_to_c_str` to `string_to_c_string` to correctly indicate
  it returns an owned `CString` rather than a borrowed `CStr`
- Update parameter names from `c_string_ptr` to `c_str_ptr` in functions
  that work with borrowed `CStr` types

The naming now follows this pattern: `c_str` for borrowed
C strings (`CStr`) and `c_string` for owned C strings (`CString`).
This makes ownership semantics clear.

This builds upon and improves the standardization in PR #13.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants