You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
build: Enable Phan and remove (possibly slow?) use of by-ref
Phan is smart enough to trace the $patterns strings, even through
concatenations, and it even validates the would-be concatenated
version as valid regexp syntax knowing it can be passed to preg_match.
This is amazing.
But, it was not smart enough to realize that buildPatterns() is
always called before self::$patterns is used. Thus, in addition to the
amazing regex syntax validation, it was also at the same time
complaining that preg_match could be passed null, which would be invalid.
I suspect the main reason it ges confused is that it isn't able to
figure out the state after the is_null() call for one key and deduce
that this applies to the other keys as well.
Fix this by letting buildPatterns() own the array in its entirety,
instead of defining half of it in the class, and half of it at runtime.
This simplifies the check to just $patterns as a whole being null,
which Phan does understand.
As a side-effect, this makes the code easier to understand by removing
clever use of by-ref, and it also appears to give the code an
~10% speed up.
Before:
* mediawiki-legacy-shared 752-797/s
* ooui-core 62-68/s
After:
* mediawiki-legacy-shared 815-886/s
* ooui-core 71-83/s
Also:
* Update Wikimedia library boilerplate.
* Resolve file_get_contents() redirect so that there's one less
Little Snitch prompt to approve :)
0 commit comments