Skip to content

Commit

Permalink
fixes some coding style issues
Browse files Browse the repository at this point in the history
  • Loading branch information
k00ni committed Nov 8, 2022
1 parent a93cd6a commit 19ba212
Show file tree
Hide file tree
Showing 13 changed files with 64 additions and 75 deletions.
2 changes: 1 addition & 1 deletion lib/Literal/Date.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function __construct($value = null, $lang = null, $datatype = null)
}

// Convert DateTimeInterface object into string
if ($value instanceof DateTimeInterface) {
if ($value instanceof \DateTimeInterface) {
$value = $value->format('Y-m-d');
}

Expand Down
4 changes: 2 additions & 2 deletions lib/Literal/DateTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ public function __construct($value = null, $lang = null, $datatype = null)

// workaround for PHP < 7.2: if not used, script will throw "Undefined class constant 'ATOM'"
if (\defined('\DateTimeInterface::ATOM')) {
$format = DateTimeInterface::ATOM;
$format = \DateTimeInterface::ATOM;
} else {
$format = \DateTime::ATOM;
}

// Convert DateTime objects into string
if ($value instanceof DateTimeInterface) {
if ($value instanceof \DateTimeInterface) {
$atom = $value->format($format);
$value = preg_replace('/[\+\-]00(\:?)00$/', 'Z', $atom);
}
Expand Down
5 changes: 2 additions & 3 deletions test/EasyRdf/HttpTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
*/

use EasyRdf\Http;
use InvalidArgumentException;
use Test\EasyRdf\Http\MockClient;
use Test\TestCase;

Expand All @@ -64,7 +63,7 @@ public function testSetDefaultHttpClient()

public function testSetDefaultHttpClientNull()
{
$this->expectException(InvalidArgumentException::class);
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage(
'$httpClient should be an object of class Zend\Http\Client or EasyRdf\Http\Client'
);
Expand All @@ -73,7 +72,7 @@ public function testSetDefaultHttpClientNull()

public function testSetDefaultHttpClientString()
{
$this->expectException(InvalidArgumentException::class);
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage(
'$httpClient should be an object of class Zend\Http\Client or EasyRdf\Http\Client'
);
Expand Down
5 changes: 2 additions & 3 deletions test/EasyRdf/Literal/DateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Test\EasyRdf\Literal;

use DateTime;
use EasyRdf\Literal\Date;
use Test\TestCase;

Expand Down Expand Up @@ -54,7 +53,7 @@ public function testConstructFromString()

public function testConstructFromDateTime()
{
$dt = new DateTime('2011-07-18');
$dt = new \DateTime('2011-07-18');
$literal = new Date($dt);
$this->assertStringEquals('2011-07-18', $literal);
$this->assertClass('DateTime', $literal->getValue());
Expand All @@ -78,7 +77,7 @@ public function testConstructNoValue()
{
// Would be very unlucky if this ran at midnight and failed
// (but it is possible)
$today = new DateTime('today');
$today = new \DateTime('today');
$literal = new Date();
$this->assertEquals($today, $literal->getValue());
$this->assertMatchesRegularExpressionPolyfill('|^\d{4}-\d{2}-\d{2}$|', (string) $literal);
Expand Down
3 changes: 1 addition & 2 deletions test/EasyRdf/Literal/DateTimeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Test\EasyRdf\Literal;

use DateTimeImmutable;
use EasyRdf\Literal\DateTime;
use Test\TestCase;

Expand Down Expand Up @@ -92,7 +91,7 @@ public function testConstructFromDateTimeUTC()

public function testConstructFromDateTimeImmutableUTC()
{
$dt = new DateTimeImmutable('2010-09-08T07:06:05Z');
$dt = new \DateTimeImmutable('2010-09-08T07:06:05Z');
$literal = new DateTime($dt);
$this->assertStringEquals('2010-09-08T07:06:05Z', $literal);
$this->assertClass('DateTime', $literal->getValue());
Expand Down
3 changes: 1 addition & 2 deletions test/EasyRdf/LiteralTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use EasyRdf\Literal;
use EasyRdf\ParsedUri;
use EasyRdf\RdfNamespace;
use Exception;
use Test\TestCase;

/**
Expand Down Expand Up @@ -199,7 +198,7 @@ public function testCreateWithFloatInBadLocale()
$this->assertSame('1.5', $literal->getValue());

setlocale(\LC_NUMERIC, $current_locale);
} catch (Exception $e) {
} catch (\Exception $e) {
setlocale(\LC_NUMERIC, $current_locale);
throw $e;
}
Expand Down
17 changes: 8 additions & 9 deletions test/EasyRdf/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use EasyRdf\Format;
use EasyRdf\Graph;
use EasyRdf\Parser;
use InvalidArgumentException;
use Test\EasyRdf\Parser\MockParser;
use Test\TestCase;

Expand Down Expand Up @@ -88,7 +87,7 @@ public function testParseFormatObject()

public function testParseNullGraph()
{
$this->expectException(InvalidArgumentException::class);
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage(
'$graph should be an EasyRdf\Graph object and cannot be null'
);
Expand All @@ -97,7 +96,7 @@ public function testParseNullGraph()

public function testParseNonObjectGraph()
{
$this->expectException(InvalidArgumentException::class);
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage(
'$graph should be an EasyRdf\Graph object and cannot be null'
);
Expand All @@ -106,7 +105,7 @@ public function testParseNonObjectGraph()

public function testParseNonGraph()
{
$this->expectException(InvalidArgumentException::class);
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage(
'$graph should be an EasyRdf\Graph object and cannot be null'
);
Expand All @@ -129,7 +128,7 @@ public function testParseEmptyData()

public function testParseNullFormat()
{
$this->expectException(InvalidArgumentException::class);
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage(
'$format cannot be null or empty'
);
Expand All @@ -138,7 +137,7 @@ public function testParseNullFormat()

public function testParseEmptyFormat()
{
$this->expectException(InvalidArgumentException::class);
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage(
'$format cannot be null or empty'
);
Expand All @@ -147,7 +146,7 @@ public function testParseEmptyFormat()

public function testParseBadObjectFormat()
{
$this->expectException(InvalidArgumentException::class);
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage(
'$format should be a string or an EasyRdf\Format object'
);
Expand All @@ -156,7 +155,7 @@ public function testParseBadObjectFormat()

public function testParseIntegerFormat()
{
$this->expectException(InvalidArgumentException::class);
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage(
'$format should be a string or an EasyRdf\Format object'
);
Expand All @@ -165,7 +164,7 @@ public function testParseIntegerFormat()

public function testParseNonStringBaseUri()
{
$this->expectException(InvalidArgumentException::class);
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage(
'$baseUri should be a string'
);
Expand Down
Loading

0 comments on commit 19ba212

Please sign in to comment.