Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempt to cast before failing? #1

Open
richplane opened this issue Jun 10, 2016 · 0 comments
Open

Attempt to cast before failing? #1

richplane opened this issue Jun 10, 2016 · 0 comments

Comments

@richplane
Copy link

When setting a property wouldn't it be reasonable for Synthesize to attempt to cast to the desired type before throwing a TypeException ?

For instance:

$latitude_that_could_be_from_db = '53.4562';
$an_object->latitude = $latitude_that_could_be_from_db;

this throws an exception 'Frozensheep\Synthesize\Exception\TypeException' with message 'Expected value of type Frozensheep\Synthesize\Type\FloatObject, string given'.

It seems like we have a choice of casting everything outside or inside of the Synthesize package; wouldn't be be easier for users of this it if was done inside?

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

No branches or pull requests

1 participant