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

Register stringification for different classes #383

Open
g105b opened this issue Oct 17, 2022 · 1 comment
Open

Register stringification for different classes #383

g105b opened this issue Oct 17, 2022 · 1 comment

Comments

@g105b
Copy link
Member

g105b commented Oct 17, 2022

Binding a value that isn't stringable causes an error currently, and so it should.

However, it would be nice to be able to register a callback to stringify a class, and provide defaults. This will be called within BindableCache, so #382 can be covered by this issue instead.

$documentBinder->registerToString(
  DateTimeInterface::class, 
  fn(DateTimeInterface $dt) => $dt->format("H:i:s")
);

This is just an idea for the syntax.

There should also be the ability to register a default, which can be done by WebEngine for built in types like DateTimeInterface, DateInterval, SplFileObject, etc.

@g105b
Copy link
Member Author

g105b commented Jan 30, 2023

Note that at the current time, DateTimeInterface has its own handler, which defaults to RFC7231 thanks to the new BindValue class.

@g105b g105b added this to the v4 milestone Feb 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant