Page MenuHomePhabricator

Replace hamcrest global functions with namespaced class static functions
Closed, DeclinedPublic

Description

From T181940: Remove composer dump-autoload --optimize from mw-fetch-composer-dev.sh and Quibble, it seems various hamcrest global functions are used in FileImporter

Would be worth swapping them out for their namespaced static functions equivalents

 * Decorates another Matcher, retaining the behavior but allowing tests
 * to be slightly more expressive.
 *
 * For example:  assertThat($cheese, equalTo($smelly))
 *          vs.  assertThat($cheese, is(equalTo($smelly)))
 */
function is($value)
{
    return \Hamcrest\Core\Is::is($value);
}

Event Timeline

Restricted Application added a subscriber: Masumrezarock100. · View Herald Transcript

What's the benefit of doing this? Is there a plan to drop Hamcrest's bootstrap and the "global functions file" it includes?

If so, how would a replacement look like? I played around a bit and found that the current

$this->assertThatHamcrest(
	$html,
	is( 

can be replaced with

use Hamcrest\Core\Is;
$this->assertThatHamcrest(
	$html,
	Is::is( 

But:

thiemowmde changed the task status from Open to Stalled.Jun 24 2020, 8:29 AM
thiemowmde moved this task from Backlog to Watching on the Move-Files-To-Commons board.

Not enough information given. Moving it out of our way for now.

No further information given. Please feel free to reopen this if you think this should still happen. The requested change itself is easy to do. I just would like to understand what the benefit is.