A Senior Developer working mostly with PHP and JavaScript, with a bit of Python thrown in for good measure, all on Linux. My tooling is simple, it's GitLab and JetBrains where possible.
It's also worth mentioning that for "6. When to use self over $this?", that you have to use self as the return type of a class function (PHP 7.4+) when you are declaring the return types, and returning the full class object (for things like method chaining). e.g.
If you don't want to do method chaining, you don't have to return $this from setName(), but self is used as the return type, when performing return $this within a function
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
It's also worth mentioning that for "6. When to use self over $this?", that you have to use
self
as the return type of a class function (PHP 7.4+) when you are declaring the return types, and returning the full class object (for things like method chaining). e.g.This would allow you to do mad stuff like:
If you don't want to do method chaining, you don't have to return
$this
fromsetName()
, butself
is used as the return type, when performingreturn $this
within a function