Skip to content

Declare strict types #93

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

Merged
merged 1 commit into from
Oct 5, 2021
Merged

Declare strict types #93

merged 1 commit into from
Oct 5, 2021

Conversation

JaZo
Copy link
Member

@JaZo JaZo commented Oct 4, 2021

Description

I've declared strict types in all classes and also configured PHP-CS-Fixer to make it required.

Motivation and context

To improve code quality and reduce errors.

N.B. Sometimes an id is provided as integer and we don't want to break on that small detail, so I cast them to a string before setting them on the item. Since the type declaration of the id was already a string the output won't change.

How has this been tested?

Tested in a real life application.

Types of changes

What types of changes does your code introduce? Put an x in all the boxes that apply:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

N.B. Declaring strict types can be considered a breaking change, but since we already have strict type checks in our parsers and I added the cast for the ID's, I believe the vast majority of users will not be affected.

Checklist:

Go over all the following points, and put an x in all the boxes that apply.

  • I have read the CONTRIBUTING document.
  • My pull request addresses exactly one patch/feature.
  • I have created a branch for this patch/feature.
  • Each individual commit in the pull request is meaningful.
  • I have added tests to cover my changes.
  • If my change requires a change to the documentation, I have updated it accordingly.

@JaZo JaZo requested a review from Rocksheep October 4, 2021 15:07
@JaZo JaZo force-pushed the feature/strict-types branch from 466dc91 to 7bc049b Compare October 5, 2021 08:22
@JaZo JaZo force-pushed the feature/strict-types branch from 7bc049b to cb78912 Compare October 5, 2021 08:26
Copy link

@Rocksheep Rocksheep left a comment

Choose a reason for hiding this comment

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

Looks good to me! I have run a couple of examples and didn't receive an error. 👍

@JaZo JaZo merged commit c722685 into master Oct 5, 2021
@JaZo JaZo deleted the feature/strict-types branch October 5, 2021 09:19
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