Page MenuHomePhorge

Make misc get*ApplicationClass[Name]() calls return ::class constant instead of string
ClosedPublic

Authored by aklapper on Jan 23 2024, 13:36.

Details

Summary

::class is available since PHP 5.5 (5.5 is a minimal requirement by Phorge): https://www.php.net/manual/en/language.oop5.basic.php#language.oop5.basic.class.class
It makes finding code using IDEs easier; see discussion in D25500.

Thus replace all string return values with returning the ::class constant instead, with one exception: 'PhabricatorSettingApplication' in PhabricatorUserPreferencesSearchEngine.php does not exist and makes arc lint fail so this string remained unchanged.

Also note that two occurrences were wrapped in pht() for reasons I do not know.

List of functions whose return value get updated in this code change:

  • getApplicationClassName()
  • getAdapterApplicationClass()
  • getDatasourceApplicationClass()
  • getEditorApplicationClass()
  • getEngineApplicationClass()
  • getPHIDTypeApplicationClass()
  • getQueryApplicationClass()

cf. T15158

Test Plan

Too broad - click around, basically.

Diff Detail

Repository
rP Phorge
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Believe me or not but I've spent 15 intense minutes to use my big eyes to check all 571 files to catch whatever line that had not the very same class name A/B.

(This was somehow easy thanks to Differential's green-light color of snippets without changes, and green-hard color for new characters. I first opened each section (I'm a fast clicker on "Load File", starting from the bottom). I've done some pauses to look at the sky and eat some good tiramisù - delicious. Yes, I checked all opened files with my big human eyes.)

The lint says there are not syntax errors.

I'm not aware of any performance downside, since the class is not loaded when doing this kind of things. But hey, I don't know. So asked on SO.

https://stackoverflow.com/questions/77895755/will-php-autoloader-load-when-calling-the-class-constant

Thanks

sgtm

This revision is now accepted and ready to land.Jan 28 2024, 17:46

@valerio.bozzolan Thanks. I guess I owe you a drink next weekend :)