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 $params type declaration to global API functions. #15852

Merged
merged 2 commits into from
Nov 15, 2019

Conversation

mfb
Copy link
Contributor

@mfb mfb commented Nov 15, 2019

Overview

Why not add a type declaration for API $params?

Before

There is no type declaration for API $params; if you pass in scalar you get Warning: Cannot use a scalar value as an array and then Uncaught exception: CiviCRM_API3_Exception: Input variable params is not an array

After

Declare type so IDE can use it, and PHP throws earlier.

@civibot
Copy link

civibot bot commented Nov 15, 2019

(Standard links)

@civibot civibot bot added the master label Nov 15, 2019
@colemanw
Copy link
Member

I think the reason is because PHP did not support this until recently.

@mfb
Copy link
Contributor Author

mfb commented Nov 15, 2019

yes but the array type declaration has been supported since PHP 5.1.0 so this should be ok now :)

(real soon now we can add type declarations for strings, nullables etc..)

@eileenmcnaughton
Copy link
Contributor

I agree - this might not have been possible before php 7 was min ver but it is now

@mfb
Copy link
Contributor Author

mfb commented Nov 15, 2019

right but it was a PHP 5.1 thing not PHP 7. It looks like there are a bunch of tests passing in a not-array and expecting to get a different error message back.

@eileenmcnaughton
Copy link
Contributor

Yeah - I'd be happy to rip out those tests TBH - I feel they are overkill - maybe just one & it doesn't need to be syntax conformance for every entity & action....

@monishdeb
Copy link
Member

Merging as per tag

@monishdeb monishdeb merged commit 8285640 into civicrm:master Nov 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants