Commit graph

18 commits

Author SHA1 Message Date
Bartosz Dziewoński
290789f080 DeprecationHelper: Don't copy the info into every instance
Store the deprecation info in a static property instead of an
instance property. This was causing noticeable memory use for
the Title class.

Because the deprecated properties are defined in the constructor,
we now have to ignore repeated calls.

Bug: T351732
Change-Id: If9504321c66d9033e4090088cbf21d4dd2bd463f
2024-01-31 17:53:37 +01:00
Timo Tijhof
9cb8bb611b debug: Improve docs, fix ingroup tags, clean up tests
* Remove redundant file-level description and ensure the class desc
  and ingroup tag are on the class block instead.
  Ref https://gerrit.wikimedia.org/r/q/owner:Krinkle+message:ingroup

* Widen `@covers` annotations in unit tests.
  Ref https://gerrit.wikimedia.org/r/q/owner:krinkle+is:merged+message:covers

* Create "Debug" documentation group, covering the debug/ directory.
  This will show up on doc.wikimedia.org under "Modules", where
  each class is listed, and the class page will also link back to
  the group as part of its breadcrumb navigation.

  Test with `php maintenance/mwdocgen.php --file docs/,includes/debug/`
  and then view /w/docs/html/

* Improve docs of various classes and explain relationships better.
  In particular, reformat to ensure each class has a oneline
  description that captures its essential function.

Change-Id: I5d1143a9244b7fd888e1dc31f0fd7965272aa900
2023-10-05 11:54:30 +00:00
Tim Starling
0077c5da15 Use short array destructuring instead of list()
Introduced in PHP 7.1. Because it's shorter and looks nice.

I used regex replacement.

Change-Id: I0555e199d126cd44501f859cb4589f8bd49694da
2022-10-21 15:33:37 +11:00
Matěj Suchánek
1865180ae7 Do minor code cleanup
Remove dead code and fix typos. Should cause no change in behavior.

Change-Id: I5d293b842bc93a28b8bcd799a31b5e6e30fe692e
2022-06-24 13:52:42 +02:00
Umherirrender
2582db5ed2 DeprecationHelper: Fix method name in deprecation message
The wfDeprecated is called directly from __get/__set/__isset which needs
only a 2, not 3. That means the message is one caller of.

Change-Id: Ia29fb0a07841f69a4d8b95431f0915df9793c340
2022-04-11 23:30:06 +00:00
daniel
972dde7107 DeprecationHelper: avoid closures
The cost of creating closures adds up, so avoid it if we can be using
method names instead.

Bug: T297236
Change-Id: Ifb78d5f310fe45db58fd450c9db3c7af295ae399
2021-12-10 17:15:13 +00:00
Derick Alangi
0cfdc33f7e debug: Improve deprecatePublicPropertyFallback() param docs
Spotted while working on I761de85ae5a839e8a695b85ce0fd7200b498da22.

Change-Id: I3667e8376d138e911a1b0324105ece8f928baf2e
2021-11-17 21:12:10 +01:00
Petr Pchelko
ac629eed2d DeprecationHelper: Support mocking and dynamic properties
DeprecationHelper currently breaks dynamic properties
on phpunit mocks. This happens because phpunit starts
mocking the magic methods if they're explicitly defined.

By default, magic methods and up doing nothing, but
if proxying to original methods is enabled, magic methods
are called like regular methods, regarless of whether
property exists or not. With this patch we can workaround
this issue, and create mocks for classes with deprecations.

Needed-By: I4297aea3489bb66c98c664da2332584c27793bfa
Change-Id: Id60a7751ece05669eced6eddd3216da7149411c7
2021-08-04 12:38:02 -07:00
vladshapik
1be1fae99f DeprecationHelper: Support null coalescing on dynamic props
Change-Id: If46287f0b29fee043d212944cb64d56ecf2e413a
2021-08-02 09:00:04 -07:00
Petr Pchelko
0c395c3592 DeprecationHelper: allow or deprecate dynamic property access.
Setting and getting dynamic class properties (e.g. $parser->my_fancy_prop)
is a horrific practice that we should get rid of, but it is still
used. DeprecationHelper right now can not be used on classes
where this practice is used by extensions. Introduce methods
to allow or deprecate this practice.

Change-Id: Ib378bef792dd31be155f186f1a4965a05004a37c
2021-07-29 07:57:20 -07:00
Peter Ovchyn
d8f54cae8b Language: Turn public properties into Getters in LanguageConverter based hierarchy
The main goal is to simplify the construction of the LanguageConverter and
avoid using constructors for derived classes.

In order to hard-deprecate removed property, DeprecationHelper::deprecatePublicPropertyFallback
was introduced.

Bug: T253834
Change-Id: Ib167982e4e872cfdf0fbcb78b7ca597f5ac8d60a
2021-02-03 15:17:42 +02:00
Peter Ovchyn
7d57b967b5 deprecation: Remove DeprecationHelper::newArgumentWithDeprecation and change callers accordingly
Bug: T245075
Change-Id: I0714b1c5d5a379cfe3ca473b72244d4d6bd1b7b8
2020-04-27 20:23:58 +03:00
Peter Ovchyn
50e3bd4fac parser: Inject a LanguageConverterFactory through DI containers:
1. into class Parser
2. into class LinkHoderArray
3. into class DefaultPreferencesFactory

Add more tests for DefaultPreferencesFactory:
1. testVariantsSupport verifies that converter with variants is used correctly.
2. Test testUserGroupMemberships verifies that membership is used correctly

Bug: T243320, T243321, T243317
Change-Id: I1e5c37e18332d0d32391c74c06e3d84862e48df8
2020-02-04 14:42:03 +02:00
Gergő Tisza
a015ee72ae
Fix class name handling in DeprecationHelper
The method for getting the declaring class name was not used when
printing the class name, and was incorrect anyway. Use reflection
when on the error path to ensure the correct class name is used.

Change-Id: Ic9cd4319535d5ab877a0563e0433371e1025d985
2019-04-19 01:09:25 -07:00
jenkins-bot
9282d8f099 Merge "Fix/suppress phan errors related to arrays (#11)" 2019-04-07 16:44:03 +00:00
Kunal Mehta
02b18ba4cd Fix/suppress phan errors related to arrays (#11)
Change-Id: Ie5c05fbc88c51d493bc1462005d2f8dde5f72101
2019-04-07 16:27:02 +00:00
Derick Alangi
bca4196e7d debug: Use __CLASS__ to get the name of the class
self::class would have been better here for consistency across
the code base but seems HHVM handles self::class diferrently from
PHP 7, when used inside a trait. The difference is significant to the
tests and thus we keep the result the same by using __CLASS__ instead.

Change-Id: I58b452341a0567f4d6e6636a7e489531a5569d20
2019-04-07 00:54:35 +00:00
Gergő Tisza
4aedefdbfd
Add helper trait for deprecating properties
Change-Id: I83e6ee4e8eedd49acef2b5d92132d37af715bff3
2018-07-18 15:15:46 +02:00