FreeDSx / SNMP

A Pure PHP SNMP Library.
MIT License
57 stars 13 forks source link

Reason for spread operator #6

Closed simPod closed 2 years ago

simPod commented 5 years ago

Hi, what is the reason for using spread operator eg. here https://github.com/FreeDSx/SNMP/blob/0157012f431700f29fc48731712808e0bed58c02/src/FreeDSx/Snmp/OidList.php#L36

Is it just type safety or something else? Thanks!

ChadSikorra commented 5 years ago

Yeah, the main reason for my use of the use of variadics is to enforce type safety since there is no other way to explicitly say we will only accept an array of a certain object. I wish there was a better way to do this in PHP.

simPod commented 5 years ago

@ChadSikorra are you willing to change method signatures to arrays if I enforce type safety? Intend to setup https://github.com/phpstan/phpstan

ChadSikorra commented 5 years ago

I wouldn't mind changing the method signature for the constructor in general on that class, as it's pretty much internally constructed. I just took a look at phpstan...looks pretty nice. And splatting does have a performance penalty (though it's pretty minor).

ChadSikorra commented 2 years ago

Closing this out since PhpStan was integrated.