In your examples I am not seeing the issue? Am I missing something here? Your examples work exactly as I would have expected them to, as they would in other similar languages like Java and C++. Lets stop the hate for the sake of hating PHP, it definitely has its quirks in relation to methods and order of parameters in particular, but things are getting better and they're not deal-breakers for getting things done.
If you want to see how great things are in PHP, I would checkout the Laravel PHP framework. It is a very well built and robust framework that uses the best parts of PHP and abstracts some of the worse parts to make the experience of developing in PHP fun again.