Doğan Uçar
May 4, 2023

--

the difference to class constants is, that at the programming language level, there is no difference in the meaning.

your method accepts a primitive integer and you can pass the STATUS_PENDING = 1 or COLOR_BLUE = 1 - both are valid.

Working with enums, you would have the Status enum and Color enum and use them as type hint for your method.

passing an instance of the Color enum to a method with Status as type hint is not possible.

At the end it is about strictness in your code.

--

--

Doğan Uçar
Doğan Uçar

Written by Doğan Uçar

Software Engineer, PHP/Laminas (Zend), Backend, Cloud, Freelancer & CEO, Open Source Contributor

No responses yet