FWIW, here's my persona FAQ - a simple version of the loging PIC rules as they have been written in the FAR and repeatedly and consistently interpreted by the FAA Legal Counsel for at least 20 years.
(I'm limiting it to student, recreational, private, and commercial pilots. CFIs and ATPs can fend for themselves. If they don't know the rules, tough.)
Rule 1 If you are a recreational, private or commercial pilot, you may log PIC any time you are the sole manipulator of the controls of an aircraft you are rated for.
"Rated" means the category and class (and type, if a type rating is necessary for the aircraft) that is listed on the back of your pilot certificate. Nothing else matters. Not instrument ratings. Not endorsements for high performance, complex, tailwheel aircraft. Not medical currency. Not flight reviews. Not night currency. Nothing.
Rule 2 If you are a student, recreational, private or commercial pilot, you may log PIC any time you are the only person in the aircraft.
This means that even without category and class ratings, you may log PIC time if you are solo. In addition to the obvious (student solo) it also means, for example, that if you are ASEL and solo in an AMEL or ASES, you may log the time as PIC.
Rule 3 If you are a private or commercial pilot, you may log PIC any time you are acting as PIC* of an aircraft on which more than one pilot is required.
More than one pilot may be required because the aircraft is not certified for single-pilot operations. But more common for us, it covers simulated instrument flight where a second "safety pilot" is required by the regulations all the time that the "manipulator" is under the hood. If the two pilots agree that the safety pilot is acting as PIC, the safety pilot can log the time as PIC.
Rule 4
Based on a unpublished 1977 Chief Counsel opinion (there is some reasonable disagreement on whether it's still any good), you may log PIC if you are acting as PIC* and you are the only person on board with the necessary aircraft ratings.
This is the answer to the silly question: "Can I log PIC while I let my two year old fly the airplane?" Frankly, I can't imagine that the FAA gives a hoot about this one way or another.
Rule 5
If you are a student, recreational, private, or commercial pilot and don't fit into Rules 1-4, you may not log the time as PIC even if you are acting as PIC.
*"Acting as PIC" assumes that you are qualified to act as PIC. That does mean being current and having the appropriate endorsements in addition to ratings.