The Title::newFromText is documented as follows:
* Title objects returned by this method are guaranteed to be valid, and * thus return true from the isValid() method.
however, this is not true. A simple example would be Title::newFromText( '#' )->isValid() === false.
I've modified one of the Title object tests to show that inconsistency is more widespread than just a single corner case. See https://gerrit.wikimedia.org/r/#/c/mediawiki/core/+/527660 and in particular the test failures for TitleTest there.
I'm wondering why Title::newFromText and Title::isValid use quite different (but similar) code paths? How about merging the two, like https://gerrit.wikimedia.org/r/c/mediawiki/core/+/527640 ?