From 8e9d2e93caf1540d325ccc4fd2d9c8da7f4f9cfe Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Wed, 21 Sep 2016 21:43:32 -0700 Subject: [PATCH] Rename Convert*a*bleTimestamp to Convert*i*bleTimestamp Per the dictionary. Change-Id: I3dcef9fb020c8c6764ee073111ed8c032e4c5a63 --- autoload.php | 2 +- includes/MWTimestamp.php | 2 +- includes/libs/rdbms/database/Database.php | 4 +- .../libs/rdbms/database/DatabasePostgres.php | 2 +- ...Timestamp.php => ConvertibleTimestamp.php} | 6 +-- includes/libs/xmp/XMPValidate.php | 4 +- ...pTest.php => ConvertibleTimestampTest.php} | 44 +++++++++---------- 7 files changed, 32 insertions(+), 32 deletions(-) rename includes/libs/time/{ConvertableTimestamp.php => ConvertibleTimestamp.php} (98%) rename tests/phpunit/includes/libs/time/{ConvertableTimestampTest.php => ConvertibleTimestampTest.php} (75%) diff --git a/autoload.php b/autoload.php index efd34ead5c..433f907d09 100644 --- a/autoload.php +++ b/autoload.php @@ -281,8 +281,8 @@ $wgAutoloadLocalClasses = [ 'ConvertExtensionToRegistration' => __DIR__ . '/maintenance/convertExtensionToRegistration.php', 'ConvertLinks' => __DIR__ . '/maintenance/convertLinks.php', 'ConvertUserOptions' => __DIR__ . '/maintenance/convertUserOptions.php', - 'ConvertableTimestamp' => __DIR__ . '/includes/libs/time/ConvertableTimestamp.php', 'ConverterRule' => __DIR__ . '/languages/ConverterRule.php', + 'ConvertibleTimestamp' => __DIR__ . '/includes/libs/time/ConvertibleTimestamp.php', 'Cookie' => __DIR__ . '/includes/libs/Cookie.php', 'CookieJar' => __DIR__ . '/includes/libs/CookieJar.php', 'CopyFileBackend' => __DIR__ . '/maintenance/copyFileBackend.php', diff --git a/includes/MWTimestamp.php b/includes/MWTimestamp.php index 201e9b6ff5..c1e5cc410b 100644 --- a/includes/MWTimestamp.php +++ b/includes/MWTimestamp.php @@ -28,7 +28,7 @@ * * @since 1.20 */ -class MWTimestamp extends ConvertableTimestamp { +class MWTimestamp extends ConvertibleTimestamp { /** * Get a timestamp instance in GMT * diff --git a/includes/libs/rdbms/database/Database.php b/includes/libs/rdbms/database/Database.php index 04ce8ab008..d3c9d5798f 100644 --- a/includes/libs/rdbms/database/Database.php +++ b/includes/libs/rdbms/database/Database.php @@ -2972,7 +2972,7 @@ abstract class Database implements IDatabase, LoggerAwareInterface { } public function timestamp( $ts = 0 ) { - $t = new ConvertableTimestamp( $ts ); + $t = new ConvertibleTimestamp( $ts ); // Let errors bubble up to avoid putting garbage in the DB return $t->getTimestamp( TS_MW ); } @@ -3459,7 +3459,7 @@ abstract class Database implements IDatabase, LoggerAwareInterface { } try { - $t = new ConvertableTimestamp( $expiry ); + $t = new ConvertibleTimestamp( $expiry ); return $t->getTimestamp( $format ); } catch ( TimestampException $e ) { diff --git a/includes/libs/rdbms/database/DatabasePostgres.php b/includes/libs/rdbms/database/DatabasePostgres.php index 69488af492..8c73a150d7 100644 --- a/includes/libs/rdbms/database/DatabasePostgres.php +++ b/includes/libs/rdbms/database/DatabasePostgres.php @@ -860,7 +860,7 @@ __INDEXATTR__; } function timestamp( $ts = 0 ) { - $ct = new ConvertableTimestamp( $ts ); + $ct = new ConvertibleTimestamp( $ts ); return $ct->getTimestamp( TS_POSTGRES ); } diff --git a/includes/libs/time/ConvertableTimestamp.php b/includes/libs/time/ConvertibleTimestamp.php similarity index 98% rename from includes/libs/time/ConvertableTimestamp.php rename to includes/libs/time/ConvertibleTimestamp.php index a784dc619b..7cada849be 100644 --- a/includes/libs/time/ConvertableTimestamp.php +++ b/includes/libs/time/ConvertibleTimestamp.php @@ -28,7 +28,7 @@ * * @since 1.28 */ -class ConvertableTimestamp { +class ConvertibleTimestamp { /** * Standard gmdate() formats for the different timestamp types. */ @@ -226,11 +226,11 @@ class ConvertableTimestamp { /** * Calculate the difference between two ConvertableTimestamp objects. * - * @param ConvertableTimestamp $relativeTo Base time to calculate difference from + * @param ConvertibleTimestamp $relativeTo Base time to calculate difference from * @return DateInterval|bool The DateInterval object representing the * difference between the two dates or false on failure */ - public function diff( ConvertableTimestamp $relativeTo ) { + public function diff( ConvertibleTimestamp $relativeTo ) { return $this->timestamp->diff( $relativeTo->timestamp ); } diff --git a/includes/libs/xmp/XMPValidate.php b/includes/libs/xmp/XMPValidate.php index 32a3340fa1..aaf649104c 100644 --- a/includes/libs/xmp/XMPValidate.php +++ b/includes/libs/xmp/XMPValidate.php @@ -329,7 +329,7 @@ class XMPValidate implements LoggerAwareInterface { // We know that if we got to this step, year, month day hour and min must be set // by virtue of regex not failing. - $unix = ( new ConvertableTimestamp( + $unix = ( new ConvertibleTimestamp( $res[1] . $res[2] . $res[3] . $res[4] . $res[5] . $res[6] ) )->getTimestamp( TS_UNIX ); $offset = intval( substr( $res[7], 1, 2 ) ) * 60 * 60; @@ -337,7 +337,7 @@ class XMPValidate implements LoggerAwareInterface { if ( substr( $res[7], 0, 1 ) === '-' ) { $offset = -$offset; } - $val = ( new ConvertableTimestamp( $unix + $offset ) )->getTimestamp( TS_EXIF ); + $val = ( new ConvertibleTimestamp( $unix + $offset ) )->getTimestamp( TS_EXIF ); if ( $stripSeconds ) { // If seconds weren't specified, remove the trailing ':00'. diff --git a/tests/phpunit/includes/libs/time/ConvertableTimestampTest.php b/tests/phpunit/includes/libs/time/ConvertibleTimestampTest.php similarity index 75% rename from tests/phpunit/includes/libs/time/ConvertableTimestampTest.php rename to tests/phpunit/includes/libs/time/ConvertibleTimestampTest.php index 986dda422f..d48caf37f0 100644 --- a/tests/phpunit/includes/libs/time/ConvertableTimestampTest.php +++ b/tests/phpunit/includes/libs/time/ConvertibleTimestampTest.php @@ -3,22 +3,22 @@ /** * Tests timestamp parsing and output. */ -class ConvertableTimestampTest extends PHPUnit_Framework_TestCase { +class ConvertibleTimestampTest extends PHPUnit_Framework_TestCase { /** - * @covers ConvertableTimestamp::__construct + * @covers ConvertibleTimestamp::__construct */ public function testConstructWithNoTimestamp() { - $timestamp = new ConvertableTimestamp(); + $timestamp = new ConvertibleTimestamp(); $this->assertInternalType( 'string', $timestamp->getTimestamp() ); $this->assertNotEmpty( $timestamp->getTimestamp() ); $this->assertNotEquals( false, strtotime( $timestamp->getTimestamp( TS_MW ) ) ); } /** - * @covers ConvertableTimestamp::__toString + * @covers ConvertibleTimestamp::__toString */ public function testToString() { - $timestamp = new ConvertableTimestamp( '1406833268' ); // Equivalent to 20140731190108 + $timestamp = new ConvertibleTimestamp( '1406833268' ); // Equivalent to 20140731190108 $this->assertEquals( '1406833268', $timestamp->__toString() ); } @@ -33,11 +33,11 @@ class ConvertableTimestampTest extends PHPUnit_Framework_TestCase { /** * @dataProvider provideValidTimestampDifferences - * @covers ConvertableTimestamp::diff + * @covers ConvertibleTimestamp::diff */ public function testDiff( $timestamp1, $timestamp2, $expected ) { - $timestamp1 = new ConvertableTimestamp( $timestamp1 ); - $timestamp2 = new ConvertableTimestamp( $timestamp2 ); + $timestamp1 = new ConvertibleTimestamp( $timestamp1 ); + $timestamp2 = new ConvertibleTimestamp( $timestamp2 ); $diff = $timestamp1->diff( $timestamp2 ); $this->assertEquals( $expected, $diff->format( '%D %H %I %S' ) ); } @@ -45,66 +45,66 @@ class ConvertableTimestampTest extends PHPUnit_Framework_TestCase { /** * Test parsing of valid timestamps and outputing to MW format. * @dataProvider provideValidTimestamps - * @covers ConvertableTimestamp::getTimestamp + * @covers ConvertibleTimestamp::getTimestamp */ public function testValidParse( $format, $original, $expected ) { - $timestamp = new ConvertableTimestamp( $original ); + $timestamp = new ConvertibleTimestamp( $original ); $this->assertEquals( $expected, $timestamp->getTimestamp( TS_MW ) ); } /** * Test outputting valid timestamps to different formats. * @dataProvider provideValidTimestamps - * @covers ConvertableTimestamp::getTimestamp + * @covers ConvertibleTimestamp::getTimestamp */ public function testValidOutput( $format, $expected, $original ) { - $timestamp = new ConvertableTimestamp( $original ); + $timestamp = new ConvertibleTimestamp( $original ); $this->assertEquals( $expected, (string)$timestamp->getTimestamp( $format ) ); } /** * Test an invalid timestamp. * @expectedException TimestampException - * @covers ConvertableTimestamp + * @covers ConvertibleTimestamp */ public function testInvalidParse() { - new ConvertableTimestamp( "This is not a timestamp." ); + new ConvertibleTimestamp( "This is not a timestamp." ); } /** * @dataProvider provideValidTimestamps - * @covers ConvertableTimestamp::convert + * @covers ConvertibleTimestamp::convert */ public function testConvert( $format, $expected, $original ) { - $this->assertSame( $expected, ConvertableTimestamp::convert( $format, $original ) ); + $this->assertSame( $expected, ConvertibleTimestamp::convert( $format, $original ) ); } /** * Format an invalid timestamp. - * @covers ConvertableTimestamp::convert + * @covers ConvertibleTimestamp::convert */ public function testConvertInvalid() { - $this->assertSame( false, ConvertableTimestamp::convert( 'Not a timestamp', 0 ) ); + $this->assertSame( false, ConvertibleTimestamp::convert( 'Not a timestamp', 0 ) ); } /** * Test an out of range timestamp * @dataProvider provideOutOfRangeTimestamps * @expectedException TimestampException - * @covers ConvertableTimestamp + * @covers ConvertibleTimestamp */ public function testOutOfRangeTimestamps( $format, $input ) { - $timestamp = new ConvertableTimestamp( $input ); + $timestamp = new ConvertibleTimestamp( $input ); $timestamp->getTimestamp( $format ); } /** * Test requesting an invalid output format. * @expectedException TimestampException - * @covers ConvertableTimestamp::getTimestamp + * @covers ConvertibleTimestamp::getTimestamp */ public function testInvalidOutput() { - $timestamp = new ConvertableTimestamp( '1343761268' ); + $timestamp = new ConvertibleTimestamp( '1343761268' ); $timestamp->getTimestamp( 98 ); } -- 2.20.1