Skip to content

Commit 986a51a

Browse files
Merge pull request #38 from i-doit/release-1.0
Release 1.0.0
2 parents b920f1f + 0cccef9 commit 986a51a

12 files changed

Lines changed: 78 additions & 100 deletions

File tree

.github/workflows/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ jobs:
1818
- '8.0'
1919
- '8.1'
2020
- '8.2'
21+
- '8.3'
2122
experimental: [false]
2223
include:
2324
- php-versions: nightly

CHANGELOG.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,27 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased][]
99

10-
Spring clean 2022!
10+
## [1.0.0][] – 2024-12-16
11+
12+
**Note:** Support for all PHP `7` versions has been dropped. PHP `8+` only, from now on :)
1113

1214
### Added
1315

1416
- `Idoit::search()`, `Idoit::batchSearch`: Add search modes "normal" (default), "deep" and "auto-deep"
17+
- Support for PHP `8.3`
1518

1619
### Changed
1720

1821
- **Breaking:** Change Composer package to `idoit/apiclient`
1922
- **Breaking:** Change PHP namespace to `Idoit\APIClient`
2023
- **Breaking:** Move repository to `github.com/i-doit/api-client-php`
2124
- **Breaking:** Require at least PHP version `8.0`
22-
- Recommend PHP version `8.1`
25+
- Recommend PHP version `8.2`
2326
- **Breaking:** Require at least i-doit `1.18.1` and its API add-on `1.12.3`
2427

25-
### Deprecated
26-
27-
- Deprecate support of PHP version `7.4`
28-
2928
### Removed
3029

31-
- **Breaking:** Drop support of PHP version `7.1`, `7.2`, and `7.3`
30+
- **Breaking:** Drop support of PHP version `7.1`, `7.2`, `7.3` and `7.4`
3231

3332
## [0.10][] – 2020-04-07
3433

@@ -234,7 +233,8 @@ Happy summer time ⛱️
234233

235234
Initial release
236235

237-
[Unreleased]: https://github.com/i-doit/api-client-php/compare/0.10...HEAD
236+
[Unreleased]: https://github.com/i-doit/api-client-php/compare/1.0.0...HEAD
237+
[1.0.0]: https://github.com/i-doit/api-client-php/compare/0.10...1.0.0
238238
[0.10]: https://github.com/i-doit/api-client-php/compare/0.9...0.10
239239
[0.9]: https://github.com/i-doit/api-client-php/compare/0.8...0.9
240240
[0.8]: https://github.com/i-doit/api-client-php/compare/0.7...0.8

composer.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"source": "https://github.com/i-doit/api-client-php"
2525
},
2626
"require": {
27-
"php": "^8.0 || ^8.1 || ^8.2",
27+
"php": "^8.0 || ^8.1 || ^8.2 || ^8.3",
2828
"ext-curl": "*",
2929
"ext-date": "*",
3030
"ext-json": "*",
@@ -35,23 +35,23 @@
3535
"require-dev": {
3636
"ext-dom": "*",
3737
"ext-xml": "*",
38-
"brianium/paratest": "^6.4",
38+
"brianium/paratest": "^6.11",
3939
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.2",
4040
"j13k/yaml-lint": "^1.1",
41-
"phan/phan": "^5.3",
41+
"phan/phan": "^5.4",
4242
"php-parallel-lint/php-parallel-lint": "^1.3",
4343
"phpcompatibility/php-compatibility": "^9.3",
4444
"phploc/phploc": "^7.0",
45-
"phpmd/phpmd": "^2.12",
46-
"phpstan/phpstan": "^1.7",
47-
"phpunit/phpunit": "^9.5",
45+
"phpmd/phpmd": "^2.15",
46+
"phpstan/phpstan": "^2.0",
47+
"phpunit/phpunit": "^9.6",
4848
"povils/phpmnd": "^2.5",
49-
"psalm/phar": "^4.23",
49+
"psalm/phar": "^5.26",
5050
"roave/security-advisories": "dev-master",
5151
"sclable/xml-lint": "^0.8.0",
5252
"sebastian/phpcpd": "^6.0",
53-
"seld/jsonlint": "^1.9",
54-
"squizlabs/php_codesniffer": "^3.6",
53+
"seld/jsonlint": "^1.11",
54+
"squizlabs/php_codesniffer": "^3.11",
5555
"symfony/dotenv": "^5.4"
5656
},
5757
"suggest": {

composer.lock

Lines changed: 14 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

phpstan.neon

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
11
parameters:
22
level: 5
3-
checkMissingIterableValueType: false
43
paths:
54
- src
6-
- tests
7-
ignoreErrors:
8-
# Ignore skipped tests:
9-
- message: "#Unreachable statement#"
10-
paths:
11-
- tests/Idoit/APIClient/*

phpunit.xml

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,21 @@
1-
<phpunit
2-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/7.0/phpunit.xsd"
4-
bootstrap="./vendor/autoload.php"
5-
cacheTokens="false"
6-
colors="true"
7-
timeoutForSmallTests="10"
8-
timeoutForMediumTests="30"
9-
timeoutForLargeTests="120"
10-
verbose="true">
11-
<testsuites>
12-
<testsuite name="Unit Tests">
13-
<directory>./tests/Idoit/APIClient/</directory>
14-
</testsuite>
15-
</testsuites>
16-
<logging>
17-
<log type="coverage-text" target="php://stdout"/>
18-
</logging>
19-
<filter>
20-
<whitelist>
21-
<directory suffix=".php">./src/</directory>
22-
</whitelist>
23-
</filter>
24-
<extensions>
25-
<extension class="Idoit\APIClient\Extension\PrintMetaData"/>
26-
<extension class="Idoit\APIClient\Extension\PrintStatistics"/>
27-
</extensions>
1+
<?xml version="1.0"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" bootstrap="./vendor/autoload.php" colors="true" timeoutForSmallTests="10" timeoutForMediumTests="30" timeoutForLargeTests="120" verbose="true">
3+
<coverage>
4+
<include>
5+
<directory suffix=".php">./src/</directory>
6+
</include>
7+
<report>
8+
<text outputFile="php://stdout"/>
9+
</report>
10+
</coverage>
11+
<testsuites>
12+
<testsuite name="Unit Tests">
13+
<directory>./tests/Idoit/APIClient/</directory>
14+
</testsuite>
15+
</testsuites>
16+
<logging/>
17+
<extensions>
18+
<extension class="Idoit\APIClient\Extension\PrintMetaData"/>
19+
<extension class="Idoit\APIClient\Extension\PrintStatistics"/>
20+
</extensions>
2821
</phpunit>

psalm.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
resolveFromConfigFile="true"
55
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
66
xmlns="https://getpsalm.org/schema/config"
7-
phpVersion="7.4"
7+
phpVersion="8.0"
88
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
99
errorBaseline="psalm-baseline.xml"
1010
>

src/API.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,9 @@ class API {
139139
/**
140140
* cURL resource
141141
*
142-
* @var CurlHandle|resource|false|null
142+
* @var CurlHandle|null
143143
*/
144-
protected $resource;
144+
protected CurlHandle|null $resource = null;
145145

146146
/**
147147
* Information about last client request
@@ -247,7 +247,7 @@ public function __destruct() {
247247
* @return bool
248248
*/
249249
public function isConnected(): bool {
250-
return is_resource($this->resource) || $this->resource instanceof CurlHandle;
250+
return $this->resource instanceof CurlHandle;
251251
}
252252

253253
/**
@@ -346,12 +346,14 @@ protected function setCURLOptions(): self {
346346
* @throws RuntimeException on error
347347
*/
348348
public function connect(): self {
349-
$this->resource = curl_init();
349+
$curl = curl_init();
350350

351-
if ($this->resource == false) {
351+
if (!$curl instanceof CurlHandle) {
352352
throw new RuntimeException('Unable to initiate cURL session');
353353
}
354354

355+
$this->resource = $curl;
356+
355357
return $this;
356358
}
357359

@@ -371,6 +373,7 @@ public function disconnect(): self {
371373
}
372374

373375
curl_close($this->resource);
376+
$this->resource = null;
374377

375378
return $this;
376379
}
@@ -619,7 +622,7 @@ protected function execute(array $data): array {
619622
$lastResponse = json_decode(trim($body), true);
620623

621624
if (!is_array($lastResponse)) {
622-
if (is_string($body) && strlen($body) > 0) {
625+
if (strlen($body) > 0) {
623626
throw new RuntimeException(sprintf(
624627
'i-doit responded with an unknown message: %s',
625628
$body

src/CMDBCategory.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,13 @@ public function save(int $objectID, string $categoryConstant, array $attributes,
9494
*/
9595
public function create(int $objectID, string $categoryConst, array $attributes): int {
9696
$params = [
97-
'objID' => $objectID,
97+
'object' => $objectID,
9898
'data' => $attributes,
9999
'category' => $categoryConst
100100
];
101101

102102
$result = $this->api->request(
103-
'cmdb.category.create',
103+
'cmdb.category.save',
104104
$params
105105
);
106106

@@ -217,9 +217,9 @@ public function update(int $objectID, string $categoryConst, array $attributes,
217217
}
218218

219219
$result = $this->api->request(
220-
'cmdb.category.update',
220+
'cmdb.category.save',
221221
[
222-
'objID' => $objectID,
222+
'object' => $objectID,
223223
'category' => $categoryConst,
224224
'data' => $attributes
225225
]
@@ -376,13 +376,13 @@ public function batchCreate(array $objectIDs, string $categoryConst, array $attr
376376
foreach ($objectIDs as $objectID) {
377377
foreach ($attributes as $data) {
378378
$params = [
379-
'objID' => $objectID,
379+
'object' => $objectID,
380380
'data' => $data,
381381
'category' => $categoryConst
382382
];
383383

384384
$requests[] = [
385-
'method' => 'cmdb.category.create',
385+
'method' => 'cmdb.category.save',
386386
'params' => $params
387387
];
388388
}
@@ -493,9 +493,9 @@ public function batchUpdate(array $objectIDs, string $categoryConst, array $attr
493493

494494
foreach ($objectIDs as $objectID) {
495495
$requests[] = [
496-
'method' => 'cmdb.category.update',
496+
'method' => 'cmdb.category.save',
497497
'params' => [
498-
'objID' => $objectID,
498+
'object' => $objectID,
499499
'category' => $categoryConst,
500500
'data' => $attributes
501501
]

src/CMDBCategoryInfo.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,7 @@ public function readAll(): array {
131131

132132
$categories = $this->batchRead($cleanCategoryConstants);
133133

134-
$combinedArray = array_combine($cleanCategoryConstants, $categories);
135-
136-
if (!is_array($combinedArray)) {
137-
throw new RuntimeException('Unable to restructure result');
138-
}
139-
140-
return $combinedArray;
134+
return array_combine($cleanCategoryConstants, $categories);
141135
}
142136

143137
/**

0 commit comments

Comments
 (0)