Skip to content

TypeCaster: unit tests, InvalidTypeCast, and tryToString refactor#296

Merged
transistive merged 4 commits into
mainfrom
cast-to-bool-unit-tests
Mar 20, 2026
Merged

TypeCaster: unit tests, InvalidTypeCast, and tryToString refactor#296
transistive merged 4 commits into
mainfrom
cast-to-bool-unit-tests

Conversation

@p123-stack
Copy link
Copy Markdown
Collaborator

@p123-stack p123-stack commented Mar 18, 2026

Adds unit tests for the TypeCaster class. Replaces null returns with InvalidTypeCast exceptions for invalid casts and updates CypherList and CypherMap to use it. Extracts a private tryToString helper that returns null on failure to simplify control flow in toFloat, toInt, and toBool.

Copy link
Copy Markdown
Collaborator

@transistive transistive left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost there. Let's fix the static analysis and reduce the try catches in the typecast

Comment thread src/TypeCaster.php
@p123-stack p123-stack changed the title Added the unit tests for Typecaster class TypeCaster: unit tests, InvalidTypeCast, and tryToString refactor Mar 20, 2026
@transistive
Copy link
Copy Markdown
Collaborator

fixes #294

@transistive transistive marked this pull request as ready for review March 20, 2026 09:52
@transistive transistive merged commit f978584 into main Mar 20, 2026
15 of 16 checks passed
transistive pushed a commit that referenced this pull request Mar 22, 2026
)

* Update TypeCaster to fix toBool and optimise other methods

* Added the unit tests for TypeCaster class

---------

Co-authored-by: Mark Rigby-Jones <mark.rigby-jones@gtt.net>
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.

3 participants