diff --git a/src/Redmine/Api/AbstractApi.php b/src/Redmine/Api/AbstractApi.php
index 9a178f20..e34fa81d 100644
--- a/src/Redmine/Api/AbstractApi.php
+++ b/src/Redmine/Api/AbstractApi.php
@@ -2,7 +2,6 @@
namespace Redmine\Api;
-use JsonException;
use Redmine\Api;
use Redmine\Client\Client;
use Redmine\Exception\SerializerException;
@@ -165,7 +164,7 @@ protected function sanitizeParams(array $defaults, array $params)
* Retrieves all the elements of a given endpoint (even if the
* total number of elements is greater than 100).
*
- * @deprecated the `retrieveAll()` method is deprecated, use `retrieveData()` instead.
+ * @deprecated the `retrieveAll()` method is deprecated, use `retrieveData()` instead
*
* @param string $endpoint API end point
* @param array $params optional parameters to be passed to the api (offset, limit, ...)
@@ -297,7 +296,7 @@ protected function attachCustomFieldXML(SimpleXMLElement $xml, array $fields)
}
/**
- * returns the last response body as array
+ * returns the last response body as array.
*
* @throws SerializerException if response body could not be converted into array
*/
@@ -310,14 +309,12 @@ private function getLastResponseBodyAsArray(): array
// parse XML
if (0 === strpos($contentType, 'application/xml')) {
$returnData = XmlSerializer::createFromString($body)->getNormalized();
- } else if (0 === strpos($contentType, 'application/json')) {
+ } elseif (0 === strpos($contentType, 'application/json')) {
$returnData = JsonSerializer::createFromString($body)->getNormalized();
}
- if (! is_array($returnData)) {
- throw new SerializerException(
- 'Could not convert response body into array: ' . $body
- );
+ if (!is_array($returnData)) {
+ throw new SerializerException('Could not convert response body into array: '.$body);
}
return $returnData;
diff --git a/src/Redmine/Api/Issue.php b/src/Redmine/Api/Issue.php
index 302c801f..312ea14a 100644
--- a/src/Redmine/Api/Issue.php
+++ b/src/Redmine/Api/Issue.php
@@ -167,7 +167,7 @@ public function update($id, array $params)
$sanitizedParams = $this->sanitizeParams($defaults, $params);
// Allow assigned_to_id to be `` (empty string) to unassign a user from an issue
- if (array_key_exists('assigned_to_id', $params) && $params['assigned_to_id'] === '') {
+ if (array_key_exists('assigned_to_id', $params) && '' === $params['assigned_to_id']) {
$sanitizedParams['assigned_to_id'] = '';
}
diff --git a/src/Redmine/Api/Wiki.php b/src/Redmine/Api/Wiki.php
index 6f4a178e..1edb7d2d 100644
--- a/src/Redmine/Api/Wiki.php
+++ b/src/Redmine/Api/Wiki.php
@@ -50,7 +50,7 @@ public function show($project, $page, $version = null)
'include' => 'attachments',
];
- if ($version === null) {
+ if (null === $version) {
$path = '/projects/'.$project.'/wiki/'.$page.'.json';
} else {
$path = '/projects/'.$project.'/wiki/'.$page.'/'.$version.'.json';
diff --git a/src/Redmine/Exception/SerializerException.php b/src/Redmine/Exception/SerializerException.php
index cfdafd34..234dc051 100644
--- a/src/Redmine/Exception/SerializerException.php
+++ b/src/Redmine/Exception/SerializerException.php
@@ -2,8 +2,8 @@
namespace Redmine\Exception;
-use RuntimeException;
use Redmine\Exception as RedmineException;
+use RuntimeException;
class SerializerException extends RuntimeException implements RedmineException
{
diff --git a/src/Redmine/Serializer/JsonSerializer.php b/src/Redmine/Serializer/JsonSerializer.php
index 4da4d2ba..83ad0f97 100644
--- a/src/Redmine/Serializer/JsonSerializer.php
+++ b/src/Redmine/Serializer/JsonSerializer.php
@@ -6,7 +6,7 @@
use Redmine\Exception\SerializerException;
/**
- * JsonSerializer
+ * JsonSerializer.
*
* @internal
*/
@@ -25,7 +25,7 @@ public static function createFromString(string $data): self
private string $encoded;
- /** @var mixed $normalized */
+ /** @var mixed */
private $normalized;
private function __construct()
@@ -53,11 +53,7 @@ private function decode(string $encoded): void
\JSON_THROW_ON_ERROR
);
} catch (JsonException $e) {
- throw new SerializerException(
- 'Catched error "' . $e->getMessage() . '" while decoding JSON: ' . $encoded,
- $e->getCode(),
- $e
- );
+ throw new SerializerException('Catched error "'.$e->getMessage().'" while decoding JSON: '.$encoded, $e->getCode(), $e);
}
}
}
diff --git a/src/Redmine/Serializer/PathSerializer.php b/src/Redmine/Serializer/PathSerializer.php
index 6f758912..96320544 100644
--- a/src/Redmine/Serializer/PathSerializer.php
+++ b/src/Redmine/Serializer/PathSerializer.php
@@ -3,7 +3,7 @@
namespace Redmine\Serializer;
/**
- * PathSerializer
+ * PathSerializer.
*
* @internal
*/
@@ -31,13 +31,13 @@ public function getPath(): string
{
$queryString = '';
- if (! empty($this->queryParams)) {
- $queryString = '?' . \http_build_query($this->queryParams);
+ if (!empty($this->queryParams)) {
+ $queryString = '?'.\http_build_query($this->queryParams);
// @see #154: replace every encoded array (`foo[0]=`, `foo[1]=`, etc with `foo[]=`)
$queryString = preg_replace('/%5B[0-9]+%5D/simU', '%5B%5D', $queryString);
}
- return $this->path . $queryString;
+ return $this->path.$queryString;
}
}
diff --git a/src/Redmine/Serializer/XmlSerializer.php b/src/Redmine/Serializer/XmlSerializer.php
index 1fc37a3d..d7632dbb 100644
--- a/src/Redmine/Serializer/XmlSerializer.php
+++ b/src/Redmine/Serializer/XmlSerializer.php
@@ -7,7 +7,7 @@
use SimpleXMLElement;
/**
- * XmlSerializer
+ * XmlSerializer.
*
* @internal
*/
@@ -26,7 +26,7 @@ public static function createFromString(string $data): self
private string $encoded;
- /** @var mixed $normalized */
+ /** @var mixed */
private $normalized;
private SimpleXMLElement $deserialized;
@@ -51,11 +51,7 @@ private function deserialize(string $encoded): void
try {
$this->deserialized = new SimpleXMLElement($encoded);
} catch (Exception $e) {
- throw new SerializerException(
- 'Catched error "' . $e->getMessage() . '" while decoding XML: ' . $encoded,
- $e->getCode(),
- $e
- );
+ throw new SerializerException('Catched error "'.$e->getMessage().'" while decoding XML: '.$encoded, $e->getCode(), $e);
}
$this->normalize($this->deserialized);
@@ -66,11 +62,7 @@ private function normalize(SimpleXMLElement $deserialized): void
try {
$serialized = json_encode($deserialized, \JSON_THROW_ON_ERROR);
} catch (JsonException $e) {
- throw new SerializerException(
- 'Catched error "' . $e->getMessage() . '" while encoding SimpleXMLElement',
- $e->getCode(),
- $e
- );
+ throw new SerializerException('Catched error "'.$e->getMessage().'" while encoding SimpleXMLElement', $e->getCode(), $e);
}
$this->normalized = JsonSerializer::createFromString($serialized)->getNormalized();
diff --git a/tests/Integration/IssueCategoryXmlTest.php b/tests/Integration/IssueCategoryXmlTest.php
index d7207be7..2a78e715 100644
--- a/tests/Integration/IssueCategoryXmlTest.php
+++ b/tests/Integration/IssueCategoryXmlTest.php
@@ -3,7 +3,6 @@
namespace Redmine\Tests\Integration;
use DOMDocument;
-use Exception;
use PHPUnit\Framework\TestCase;
use Redmine\Exception\MissingParameterException;
use Redmine\Tests\Fixtures\MockClient;
diff --git a/tests/Integration/MembershipXmlTest.php b/tests/Integration/MembershipXmlTest.php
index 0dcd5614..9f52f4ca 100644
--- a/tests/Integration/MembershipXmlTest.php
+++ b/tests/Integration/MembershipXmlTest.php
@@ -3,7 +3,6 @@
namespace Redmine\Tests\Integration;
use DOMDocument;
-use Exception;
use PHPUnit\Framework\TestCase;
use Redmine\Exception\MissingParameterException;
use Redmine\Tests\Fixtures\MockClient;
diff --git a/tests/Integration/ProjectXmlTest.php b/tests/Integration/ProjectXmlTest.php
index 88afd570..c9dfdcda 100644
--- a/tests/Integration/ProjectXmlTest.php
+++ b/tests/Integration/ProjectXmlTest.php
@@ -3,7 +3,6 @@
namespace Redmine\Tests\Integration;
use DOMDocument;
-use Exception;
use PHPUnit\Framework\TestCase;
use Redmine\Exception\MissingParameterException;
use Redmine\Tests\Fixtures\MockClient;
diff --git a/tests/Integration/UrlTest.php b/tests/Integration/UrlTest.php
index 543af9d4..fabaada5 100644
--- a/tests/Integration/UrlTest.php
+++ b/tests/Integration/UrlTest.php
@@ -347,13 +347,13 @@ public function testTimeEntry()
// Test for #154: fix http_build_query encoding array values with numeric keys
$res = $api->all([
- "f" => ["spent_on"],
- "op" => ["spent_on" => "><"],
- "v" => [
- "spent_on" => [
- "2016-01-18",
- "2016-01-22"
- ]
+ 'f' => ['spent_on'],
+ 'op' => ['spent_on' => '><'],
+ 'v' => [
+ 'spent_on' => [
+ '2016-01-18',
+ '2016-01-22',
+ ],
],
]);
$this->assertEquals('/time_entries.json?limit=25&offset=0&f%5B%5D=spent_on&op%5Bspent_on%5D=%3E%3C&v%5Bspent_on%5D%5B%5D=2016-01-18&v%5Bspent_on%5D%5B%5D=2016-01-22', $res['path']);
diff --git a/tests/Integration/UserXmlTest.php b/tests/Integration/UserXmlTest.php
index ea858bb7..35688e0e 100644
--- a/tests/Integration/UserXmlTest.php
+++ b/tests/Integration/UserXmlTest.php
@@ -3,7 +3,6 @@
namespace Redmine\Tests\Integration;
use DOMDocument;
-use Exception;
use PHPUnit\Framework\TestCase;
use Redmine\Exception\MissingParameterException;
use Redmine\Tests\Fixtures\MockClient;
diff --git a/tests/Unit/Api/AbstractApiTest.php b/tests/Unit/Api/AbstractApiTest.php
index 0ddede25..5bf704c9 100644
--- a/tests/Unit/Api/AbstractApiTest.php
+++ b/tests/Unit/Api/AbstractApiTest.php
@@ -48,7 +48,7 @@ public function getIsNotNullReturnsCorrectBooleanData()
[true, [0]],
[true, ['0']],
[true, ['']],
- [true, new \stdClass],
+ [true, new \stdClass()],
];
}
diff --git a/tests/Unit/Api/GroupTest.php b/tests/Unit/Api/GroupTest.php
index 980ce148..b84011d6 100644
--- a/tests/Unit/Api/GroupTest.php
+++ b/tests/Unit/Api/GroupTest.php
@@ -2,7 +2,6 @@
namespace Redmine\Tests\Unit\Api;
-use Exception;
use PHPUnit\Framework\TestCase;
use Redmine\Api\Group;
use Redmine\Client\Client;
diff --git a/tests/Unit/Api/IssueCategoryTest.php b/tests/Unit/Api/IssueCategoryTest.php
index 0670408b..e1763a31 100644
--- a/tests/Unit/Api/IssueCategoryTest.php
+++ b/tests/Unit/Api/IssueCategoryTest.php
@@ -2,7 +2,6 @@
namespace Redmine\Tests\Unit\Api;
-use Exception;
use PHPUnit\Framework\TestCase;
use Redmine\Api\IssueCategory;
use Redmine\Client\Client;
diff --git a/tests/Unit/Api/IssueTest.php b/tests/Unit/Api/IssueTest.php
index 4cba4b0b..c35465b1 100644
--- a/tests/Unit/Api/IssueTest.php
+++ b/tests/Unit/Api/IssueTest.php
@@ -23,6 +23,7 @@ public function getPriorityConstantsData()
[5, Issue::PRIO_IMMEDIATE],
];
}
+
/**
* Test the constants.
*
@@ -917,7 +918,7 @@ public function testBuildXmlWithWatcherAndUploadAndCustomFieldAndStandard()
}
/**
- * Test assign an user to an issue
+ * Test assign an user to an issue.
*
* @test
*/
@@ -938,7 +939,6 @@ public function testAssignUserToAnIssue()
$this->stringStartsWith(''."\n".''),
$this->stringContains('5'),
$this->stringEndsWith(''."\n"),
-
)
);
@@ -950,7 +950,7 @@ public function testAssignUserToAnIssue()
}
/**
- * Test unassign an user from an issue
+ * Test unassign an user from an issue.
*
* @test
*/
@@ -958,7 +958,7 @@ public function testUnassignUserFromAnIssue()
{
// Test values
$parameters = [
- 'assigned_to_id' => "",
+ 'assigned_to_id' => '',
];
// Create the used mock objects
@@ -971,7 +971,6 @@ public function testUnassignUserFromAnIssue()
$this->stringStartsWith(''."\n".''),
$this->stringContains(''),
$this->stringEndsWith(''."\n"),
-
)
);
diff --git a/tests/Unit/Api/ProjectTest.php b/tests/Unit/Api/ProjectTest.php
index 84d86c7d..afd51803 100644
--- a/tests/Unit/Api/ProjectTest.php
+++ b/tests/Unit/Api/ProjectTest.php
@@ -2,7 +2,6 @@
namespace Redmine\Tests\Unit\Api;
-use Exception;
use PHPUnit\Framework\TestCase;
use Redmine\Api\Project;
use Redmine\Client\Client;
diff --git a/tests/Unit/Api/TimeEntryTest.php b/tests/Unit/Api/TimeEntryTest.php
index d1f3477a..652da294 100644
--- a/tests/Unit/Api/TimeEntryTest.php
+++ b/tests/Unit/Api/TimeEntryTest.php
@@ -2,7 +2,6 @@
namespace Redmine\Tests\Unit\Api;
-use Exception;
use PHPUnit\Framework\TestCase;
use Redmine\Api\TimeEntry;
use Redmine\Client\Client;
diff --git a/tests/Unit/Api/UserTest.php b/tests/Unit/Api/UserTest.php
index c6a3a5d8..6c3f526f 100644
--- a/tests/Unit/Api/UserTest.php
+++ b/tests/Unit/Api/UserTest.php
@@ -2,7 +2,6 @@
namespace Redmine\Tests\Unit\Api;
-use Exception;
use PHPUnit\Framework\TestCase;
use Redmine\Api\User;
use Redmine\Client\Client;
diff --git a/tests/Unit/Api/VersionTest.php b/tests/Unit/Api/VersionTest.php
index 227bb5a2..77e4c88e 100644
--- a/tests/Unit/Api/VersionTest.php
+++ b/tests/Unit/Api/VersionTest.php
@@ -2,7 +2,6 @@
namespace Redmine\Tests\Unit\Api;
-use Exception;
use PHPUnit\Framework\TestCase;
use Redmine\Api\Version;
use Redmine\Client\Client;
diff --git a/tests/Unit/Serializer/JsonSerializerTest.php b/tests/Unit/Serializer/JsonSerializerTest.php
index 51b199fa..529a5352 100644
--- a/tests/Unit/Serializer/JsonSerializerTest.php
+++ b/tests/Unit/Serializer/JsonSerializerTest.php
@@ -47,7 +47,7 @@ public function getNormalizedAndEncodedData()
],
[
'["foo","bar"]',
- ['foo','bar'],
+ ['foo', 'bar'],
],
[
'{"foo":"bar"}',
diff --git a/tests/Unit/Serializer/PathSerializerTest.php b/tests/Unit/Serializer/PathSerializerTest.php
index f7fe8bb5..d73fd063 100644
--- a/tests/Unit/Serializer/PathSerializerTest.php
+++ b/tests/Unit/Serializer/PathSerializerTest.php
@@ -33,12 +33,12 @@ public function getPathData()
[
'/time_entries.json',
[
- 'f' => ['spent_on'],
+ 'f' => ['spent_on'],
'op' => ['spent_on' => '><'],
- 'v' => [
+ 'v' => [
'spent_on' => [
'2016-01-18',
- '2016-01-22'
+ '2016-01-22',
],
],
],