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

Add type hints to KlaviyoAPI via PHPDoc #38

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

AJenbo
Copy link

@AJenbo AJenbo commented Dec 18, 2023

Using the API is not very friendly as it does not hint the types and so you constantly have to look things up either in code or docs since the IDE is not able to reason about the code. Also the lack of types prevents static analyzers from validating that the code has been written correctly.

I have added some basic hints to the main class, but there appears to be more room for improvements.

Copy link

@chrishalbert chrishalbert left a comment

Choose a reason for hiding this comment

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

Since this sdk supports 7.4+, we could use type declarations when defining the properties and method signatures. That would add an extra layer of defensive coding around the public properties, which are otherwise open for modification.

The only issue that I can see is that existing code which relies on the dynamic typing of php could break, and with breaking changes comes another major version tag. Then again, this would ensure that the remainder of the code functions exactly as expected though.

@AJenbo
Copy link
Author

AJenbo commented Jan 4, 2024

Yeah I wanted to avoid any breaking changes, but also we need generics to express how the Subclient works which can only be done via PHPDoc as of now.

@chrishalbert
Copy link

chrishalbert commented Jan 4, 2024

Oh yes, I recognized that syntax - I've spent more time trying to get that passing phpstan than doing the actual fix :P Sounds good and in that case, I approve

@obennaci
Copy link

Any chance to have this merged? it's a great QoL change 🙏

@54853315
Copy link

@AJenbo Hey , Are you still alive? Don't left us ! Can you merge this ?

Copy link

@54853315 54853315 left a comment

Choose a reason for hiding this comment

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

LGTM!

@AJenbo
Copy link
Author

AJenbo commented Oct 31, 2024

@AJenbo Hey , Are you still alive? Don't left us ! Can you merge this ?

I'm still alive but this isn't my project so I can't merged, I just made the proposal

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.

4 participants