9

>repo about the cool parts of modern php
>literally the first one is already a mindfuck antipattern

Comments
  • 4
    Modern php would include types in the parameters and a return type. I think $b would throw an error rather than be processed.

    Other than that I don't see anything wrong with the example.

    Just a plain old impractical example seen in every introduction to X course.
  • 2
    If you don't specify the type it can be anything, even null.
  • 2
    @nitnip later on its explained.
  • 2
    That is how it works in most languages.
  • 0
    To understand modern php (as in, modern php frameworks that have a lot of "magic" built-in),
    understanding __call, __callStatic, __get, __set and __construct is very helpful.
  • 0
    I seldom use optional/default parameters, if I ever do they are anywhere except for class constructors. Other than that I really don't see the problem with them.
  • 0
    @KDSBest most languages change the type and value of you function parameter on their own?
Add Comment