povils / phpmnd

PHP Magic Number Detector
MIT License
554 stars 46 forks source link

Check const for arrays #81

Closed exussum12 closed 5 years ago

exussum12 commented 5 years ago

Example

const something = 2; should be accepted but having a const array should not

const something = [1,2,3]; should be something like

const number = 2; const something = [self::number];

povils commented 5 years ago

Hey, thanks for PR. As I agree that sometimes it really makes sense to disallow array constants I don't want to put it as default behaviour:) can we make an option to toggle this?)

exussum12 commented 5 years ago

This way falls back to the settings which the user sets. Which imo would be expected handling. When the code was written it was targeting 5.5 which doeant have array constants. This was added in 5.6.

Personally I think this acts as intended as it respects the already passed in flags