Skip to content

Commit 7037fc4

Browse files
committed
feat: upgrade to php 8.
1 parent 18d84d9 commit 7037fc4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+109
-111
lines changed

.gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
/.idea/
22
/tests/data/
33
/tests/build/
4+
/tests/.phpunit.cache/
45
/vendor/
56
/.env
67
/.php-cs-fixer.cache
7-
/composer.lock
8+
/composer.lock
9+
phpunit.xml
10+
.phpunit.result.cache

composer.json

+7-4
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
}
1010
],
1111
"require": {
12-
"php": ">=5.4"
12+
"php": "^8.0"
1313
},
1414
"require-dev": {
15-
"phpunit/phpunit": "^5.7"
15+
"phpunit/phpunit": "^9.3"
1616
},
1717
"autoload": {
1818
"psr-4": {
@@ -29,7 +29,10 @@
2929
},
3030
"extra": {
3131
"branch-alias": {
32-
"dev-master": "1.0.6-dev"
32+
"dev-master": "2.0.0-dev"
3333
}
34+
},
35+
"config": {
36+
"platform-check": true
3437
}
35-
}
38+
}

phpunit.xml

-49
This file was deleted.

phpunit.xml..dist

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.6/phpunit.xsd"
4+
bootstrap="tests/bootstrap.php"
5+
cacheResultFile="tests/build/test-results"
6+
executionOrder="depends,defects"
7+
forceCoversAnnotation="false"
8+
beStrictAboutCoversAnnotation="false"
9+
beStrictAboutOutputDuringTests="true"
10+
beStrictAboutTodoAnnotatedTests="true"
11+
convertDeprecationsToExceptions="true"
12+
failOnRisky="true"
13+
failOnWarning="true"
14+
verbose="true">
15+
<testsuites>
16+
<testsuite name="default">
17+
<directory>tests</directory>
18+
</testsuite>
19+
</testsuites>
20+
21+
<coverage cacheDirectory="tests/build/code-coverage"
22+
processUncoveredFiles="true">
23+
<include>
24+
<directory suffix=".php">src</directory>
25+
</include>
26+
</coverage>
27+
<!-- For live test
28+
<php>
29+
<env name="API_COMPANY" value="yourcompany" />
30+
<env name="API_KEY" value="yourkey" />
31+
<env name="API_FORMAT" value="json" />
32+
</php>
33+
-->
34+
</phpunit>

src/Auth.php

+13-13
Original file line numberDiff line numberDiff line change
@@ -17,39 +17,39 @@ public static function set()
1717
{
1818
$num_args = func_num_args();
1919
if ($num_args === 1) {
20-
self::$config['url'] = self::$url;
21-
self::$config['key'] = func_get_arg(0);
22-
self::$config['url'] = Factory::build('account')->authenticate()->url;
20+
static::$config['url'] = static::$url;
21+
static::$config['key'] = func_get_arg(0);
22+
static::$config['url'] = Factory::build('account')->authenticate()->url;
2323
} elseif ($num_args === 2) {
24-
self::$config['url'] = $url = func_get_arg(0);
25-
self::checkSubDomain($url);
26-
if (self::$is_subdomain) {
27-
self::$config['url'] = self::$url;
24+
static::$config['url'] = $url = func_get_arg(0);
25+
static::checkSubDomain($url);
26+
if (static::$is_subdomain) {
27+
static::$config['url'] = static::$url;
2828
}
29-
self::$config['key'] = func_get_arg(1);
30-
if (self::$is_subdomain) {
29+
static::$config['key'] = func_get_arg(1);
30+
if (static::$is_subdomain) {
3131
$test = Factory::build('account')->authenticate();
3232
$url = $test->url;
3333
}
34-
self::$config['url'] = $url;
34+
static::$config['url'] = $url;
3535
}
3636
}
3737

3838
public static function get()
3939
{
40-
return array_values(self::$config);
40+
return array_values(static::$config);
4141
}
4242

4343
private static function checkSubDomain($url)
4444
{
4545
$eu_domain = strpos($url, '.eu');
4646

4747
if ($eu_domain !== false) {
48-
self::$url = 'https://authenticate.eu.teamwork.com/';
48+
static::$url = 'https://authenticate.eu.teamwork.com/';
4949
$url = substr($url, 0, $eu_domain);
5050
}
5151
if (strpos($url, '.') === false) {
52-
self::$is_subdomain = true;
52+
static::$is_subdomain = true;
5353
}
5454
}
5555
}

src/Comment/Model.php

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
abstract class Model extends \TeamWorkPm\Model
66
{
7+
protected $resource;
8+
79
protected function init()
810
{
911
$this->parent = 'comment';

src/Factory.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class Factory
66
{
77
/**
88
* @param string $class_name
9-
* @return Model
9+
* @return Model | People | Project\People
1010
*/
1111
public static function build($class_name)
1212
{

src/Response/Model.php

+8-6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace TeamWorkPm\Response;
44

5+
use Traversable;
6+
57
abstract class Model implements \IteratorAggregate, \Countable, \ArrayAccess
68
{
79
protected $string = null;
@@ -49,17 +51,17 @@ public function getHeaders()
4951
return $this->headers;
5052
}
5153

52-
public function getIterator()
54+
public function getIterator(): Traversable
5355
{
5456
return new \ArrayIterator($this->data);
5557
}
5658

57-
public function count()
59+
public function count(): int
5860
{
5961
return count($this->data);
6062
}
6163

62-
public function offsetSet($offset, $value)
64+
public function offsetSet($offset, $value): void
6365
{
6466
if (is_null($offset)) {
6567
$this->data[] = $value;
@@ -68,17 +70,17 @@ public function offsetSet($offset, $value)
6870
}
6971
}
7072

71-
public function offsetExists($offset)
73+
public function offsetExists($offset): bool
7274
{
7375
return isset($this->data[$offset]);
7476
}
7577

76-
public function offsetUnset($offset)
78+
public function offsetUnset($offset): void
7779
{
7880
unset($this->data[$offset]);
7981
}
8082

81-
public function offsetGet($offset)
83+
public function offsetGet($offset): mixed
8284
{
8385
return isset($this->data[$offset]) ? $this->data[$offset] : null;
8486
}

src/Rest.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace TeamWorkPm;
44

5+
use CurlHandle;
6+
57
final class Rest
68
{
79
/**
@@ -103,7 +105,7 @@ private function execute($method, $action, $parameters = null)
103105
* @param string $url
104106
* @param string|null $params
105107
* @param array $headers
106-
* @return false|resource
108+
* @return CurlHandle|false
107109
*/
108110
private static function initCurl($method, $url, $params, $headers)
109111
{

src/Rest/Model.php

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
use TeamWorkPm\Rest;
66

7+
/**
8+
* @method void init()
9+
*/
710
abstract class Model
811
{
912
/**

tests/AccountTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class AccountTest extends TestCase
1313
*/
1414
private $model;
1515

16-
public function setUp()
16+
public function setUp(): void
1717
{
1818
parent::setUp();
1919
$this->model = Factory::build('account');

tests/ActivityTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class ActivityTest extends TestCase
1414
*/
1515
private $model;
1616

17-
public function setUp()
17+
public function setUp(): void
1818
{
1919
parent::setUp();
2020
$this->model = Factory::build('activity');

tests/Category/FileTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class FileTest extends TestCase
1616
private $projectId;
1717
private $id;
1818

19-
public function setUp()
19+
public function setUp(): void
2020
{
2121
parent::setUp();
2222
$this->model = Factory::build('category/file');

tests/Category/LinkTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class LinkTest extends TestCase
1212
private $projectId;
1313
private $id;
1414

15-
public function setUp()
15+
public function setUp(): void
1616
{
1717
parent::setUp();
1818
$this->model = Factory::build('category/link');

tests/Category/MessageTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class MessageTest extends TestCase
1212
private $projectId;
1313
private $id;
1414

15-
public function setUp()
15+
public function setUp(): void
1616
{
1717
parent::setUp();
1818
$this->model = Factory::build('category/message');

tests/Category/NotebookTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class NotebookTest extends TestCase
1212
private $projectId;
1313
private $id;
1414

15-
public function setUp()
15+
public function setUp(): void
1616
{
1717
parent::setUp();
1818
$this->model = Factory::build('category/notebook');

tests/Category/ProjectTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class ProjectTest extends TestCase
1111
private $model;
1212
private $id;
1313

14-
public function setUp()
14+
public function setUp(): void
1515
{
1616
parent::setUp();
1717
$this->model = Factory::build('category/project');

tests/Comment/FileTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class FileTest extends TestCase
1313
private $projectId;
1414
private $id;
1515

16-
public function setUp()
16+
public function setUp(): void
1717
{
1818
parent::setUp();
1919
$this->model = Factory::build('comment/file');

tests/Comment/MilestoneTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class MilestoneTest extends TestCase
1212
private $resourceId;
1313
private $id;
1414

15-
public function setUp()
15+
public function setUp(): void
1616
{
1717
parent::setUp();
1818
$this->model = Factory::build('comment/milestone');

tests/Comment/NotebookTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class NotebookTest extends TestCase
1212
private $resourceId;
1313
private $id;
1414

15-
public function setUp()
15+
public function setUp(): void
1616
{
1717
parent::setUp();
1818
$this->model = Factory::build('comment/notebook');

tests/Comment/TaskTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class TaskTest extends TestCase
1212
private $resourceId;
1313
private $id;
1414

15-
public function setUp()
15+
public function setUp(): void
1616
{
1717
parent::setUp();
1818
$this->model = Factory::build('comment/task');

tests/CompanyTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class CompanyTest extends TestCase
1111
private $id;
1212
private $projectId;
1313

14-
public function setUp()
14+
public function setUp(): void
1515
{
1616
parent::setUp();
1717
$this->model = Factory::build('company');

tests/FileTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class FileTest extends TestCase
1111
private $id;
1212
private $projectId;
1313

14-
public function setUp()
14+
public function setUp(): void
1515
{
1616
parent::setUp();
1717
$this->model = Factory::build('file');

0 commit comments

Comments
 (0)