aboutsummaryrefslogtreecommitdiffstats
path: root/maintenance/findDeprecated.php
Commit message (Collapse)AuthorAgeFilesLines
* Remove terminal colours from findDeprecated.phpTim Starling2025-02-101-11/+2
| | | | | | | | The output of this script is completely unreadable when using a terminal with a light background. The output is fine without the colours. The colours break the PHPUnit test. Change-Id: I731b2e79994194ff1d6c1fc4742be8391c7e1724
* add `use MediaWiki\Maintenance\Maintenance` to some maintenance classesNovem Linguae2024-12-041-0/+2
| | | | | | | | | | | | | F–P. Still need to do P–Z. there's a couple spots where I added `use MediaWiki\Maintenance\LoggedUpdateMaintenance;` or similar instead. some of the existing "use" blocks were in weird spots (e.g. above the copyright docblock, or too far down). i didn't move those because they are out of scope for this patch. Change-Id: I5b6a8f3eae5be85d67bccfcce31c0c2027850f45
* composer.json: Updated nikic/php-parser from ^4.10.2 to ^5.3.1Reedy2024-11-111-1/+1
| | | | | | Bug: T379508 Change-Id: Ia693d5e3424d925172cd2e4b7cb501a031822f3b Depends-On: Iec814da22ff34810077876d3ee0ad0264cfc54a9
* maintenance: Use Maintenance::posix_isatty in findDeprecatedAmmarpad2024-10-231-1/+1
| | | | | | So that the script does not require posix extension Change-Id: Id74aa62a8b9844667b1c9d55c2f031998c0f9a3e
* Test findDeprecated.phpDreamy Jazz2024-10-151-9/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | Why: * Maintenance scripts in core have low test coverage * This can cause issues such as the findDeprecated.php maintenance script not working, as described in T374832 * Testing the broken script after fixing it will avoid the script breaking again. What: * Fix the findDeprecated.php maintenance script to actually show when code is hard-deprecated. * Modify the script to allow mocking of the MediaWiki install path in PHPUnit tests * Create FindDeprecatedTest which tests that the script produces an expected output, without being specific about how the code finds the methods (to allow the method to be changed as discussed in T243403) ** To do this, create a folder in the data folder for the PHPUnit tests that has a mock file structure allowing the test to use a fixed list of soft and hard deprecated methods. Bug: T374832 Bug: T371167 Change-Id: Ic4933cef95ef1af7fa3939625ac1747106c71230
* maintenance: Add missing documentation to class propertiesUmherirrender2024-09-131-0/+3
| | | | | | | | | | Add doc-typehints to class properties found by the PropertyDocumentation sniff to improve the documentation. Once the sniff is enabled it avoids that new code is missing type declarations. This is focused on documentation and does not change code. Change-Id: I7dec01892a987a87b1b79374a1c28f97d055e8fa
* Exclude boilerplate maintenance code from code coverage reportsDreamy Jazz2024-08-271-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | Why: * Maintenance scripts in core have bolierplate code that is added before and after the class to allow directly running the maintenance script. * Running the maintenance script directly has been deprecated since 1.40, so this boilerplate code is only to support a now deprecated method of running maintenance scripts. * This code cannot also be marked as covered, due to PHPUnit not recognising code coverage for files. * Therefore, it is best to ignore this boilerplate code in code coverage reports as it cannot be marked as covered and also is for deprecated code. What: * Wrap the boilerplate code (requiring Maintenance.php and then later defining the maintenance script class and running if the maintenance script was called directly) with @codeCoverageIgnore comments. * Some files use a different boilerplate code, however, these should also be marked as ignored for coverage for the same reason that coverage is not properly reported for files. Bug: T371167 Change-Id: I32f5c6362dfb354149a48ce9c28da9a7fc494f7c
* maintenance: Fix broken strpos in findDeprecated scriptthiemowmde2024-01-251-1/+1
| | | | | | | | | | | | | The idea here was obviously to speed up the process by skipping files that don't contain the substring "@deprecated" anywhere. Only these files are parsed and traversed – which can be expensive. The problem is that PHP's strpos() function never returns -1. It returns false. This patch doesn't change what the script does. It just runs faster. Change-Id: I95a5a0fd3e024ec4132f53d770e3f61031d81250
* Remove unused key variable from foreach loopsUmherirrender2022-09-211-1/+1
| | | | Change-Id: Id2d91e30a6f7cc4eb93427b50efc1c5c77f14b75
* Add explicit casts between scalar typesUmherirrender2022-03-081-1/+1
| | | | | | | | | php internal functions like floor/round/ceil documented to return float, most cases the result is used as int, added casts Found by phan strict checks Change-Id: I92daeb0f7be8a0566fd9258f66ed3aced9a7b792
* maintenance: Mark some closures as staticReedy2021-02-071-1/+1
| | | | | Bug: T274036 Change-Id: Ic959dfddcf2867e4cf26970f375b347f4b41584d
* Suppress PhanUndeclaredProperty for custom properties and phan bugsDaimona Eaytoy2019-09-141-0/+1
| | | | | | | And remove the issue from the exclusions list. Bug: T231636 Change-Id: Iee73ddb554e354abe52d13dcfc453f9a15bb8877
* Use PHP 7 '<=>' operator in 'sort()' callbacksBartosz Dziewoński2018-05-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | `$a <=> $b` returns `-1` if `$a` is lesser, `1` if `$b` is lesser, and `0` if they are equal, which are exactly the values 'sort()' callbacks are supposed to return. It also enables the neat idiom `$a[x] <=> $b[x] ?: $a[y] <=> $b[y]` to sort arrays of objects first by 'x', and by 'y' if they are equal. * Replace a common pattern like `return $a < $b ? -1 : 1` with the new operator (and similar patterns with the variables, the numbers or the comparison inverted). Some of the uses were previously not correctly handling the variables being equal; this is now automatically fixed. * Also replace `return $a - $b`, which is equivalent to `return $a <=> $b` if both variables are integers but less intuitive. * (Do not replace `return strcmp( $a, $b )`. It is also equivalent when both variables are strings, but if any of the variables is not, 'strcmp()' converts it to a string before comparison, which could give different results than '<=>', so changing this would require careful review and isn't worth it.) * Also replace `return $a > $b`, which presumably sort of works most of the time (returns `1` if `$b` is lesser, and `0` if they are equal or `$a` is lesser) but is erroneous. Change-Id: I19a3d2fc8fcdb208c10330bd7a42c4e05d7f5cf3
* Use ::class to resolve class names in maintenance scriptsUmherirrender2018-01-231-1/+1
| | | | | | | This helps to find renamed or misspelled classes earlier. Phan will check the class names Change-Id: I1d4567f47f93eb1436cb98558388e48d35258666
* Update nikic/php-parser to 3.1.3Kunal Mehta2018-01-051-1/+4
| | | | | | | | And fix the only incompatibility in findDeprecated.php. It's OK to throw exceptions on invalid files since we lint all PHP files so there should be no invalid ones. Change-Id: Ie5913c2aae4b521a4b6f805e911e4e2764386b45
* Improve some parameter docsUmherirrender2017-09-101-0/+2
| | | | | | Add missing @return and @param to function docs and fixed some @param Change-Id: I810727961057cfdcc274428b239af5975c57468d
* Upgrade PhpParser to 2.1 and update findDeprecated.phpTim Starling2016-08-151-1/+4
| | | | | | | | The old PhpParser had dynamic class_alias() calls in its autoloader which caused HHVM RepoAuthoritative compilation to fail with a fatal error. These b/c aliases were removed in 2.0. Change-Id: I6e2e3412204249a50a5806c33f48f426ab8c4511
* Convert all array() syntax to []Kunal Mehta2016-02-171-4/+4
| | | | | | | | | | Per wikitech-l consensus: https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html Notes: * Disabled CallTimePassByReference due to false positives (T127163) Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b
* Use addDescription() instead of accessing mDescription directlyMax Semenik2016-01-301-1/+1
| | | | Change-Id: I0e2aa83024b8abf5298cfea4b21bf45722ad3103
* Remove various double empty newlinesumherirrender2015-12-271-1/+0
| | | | | | | The double empty newline is not needed between functions, variable or at end of file Change-Id: Ib866a95084c4601ac150a2b402cfa184ebc18afa
* Add a maintenance script for finding deprecated interfacesOri Livneh2015-12-191-0/+199
Add a maintenance script, findDeprecated.php, which iterates through $IP/include/**.php, looking for functions and methods which have been marked as deprecated (via a '@deprecated' tag in the doc-block), and then prints a detailed report indicating the version, file, line and version of each deprecated interface. Change-Id: I9518a52b8c51ee972552a94f5367c1faa7e04a3a