Skip to content

Commit 18d84d9

Browse files
committed
[TASK] Fix php code style
1 parent 5b56a13 commit 18d84d9

36 files changed

+114
-107
lines changed

.gitattributes

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
.gitattributes export-ignore
2-
.php_cs export-ignore
3-
/tests export-ignore
41
/examples export-ignore
2+
/tests export-ignore
3+
/.gitattributes export-ignore
4+
/.gitignore export-ignore
5+
/.php-cs-fixer.php export-ignore
6+
/phpunit.xml export-ignore
7+
/.phpstorm.meta.php export-ignore
8+
/rector.php export-ignore

.gitignore

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
/tests/data/
33
/tests/build/
44
/vendor/
5-
.env
6-
.php_cs.cache
7-
composer.lock
5+
/.env
6+
/.php-cs-fixer.cache
7+
/composer.lock

.php-cs-fixer.php

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
if (PHP_SAPI !== 'cli') {
6+
die('This script supports command line usage only. Please check your command.');
7+
}
8+
9+
return (new \PhpCsFixer\Config())
10+
->setFinder(
11+
(new \PhpCsFixer\Finder())
12+
->ignoreVCSIgnored(true)
13+
->in([
14+
__DIR__ . '/src/',
15+
__DIR__ . '/tests/',
16+
])
17+
)
18+
->setRiskyAllowed(true)
19+
->setRules([
20+
'@PSR2' => true,
21+
'@DoctrineAnnotation' => true,
22+
'no_leading_import_slash' => true,
23+
'array_syntax' => ['syntax' => 'short'],
24+
'cast_spaces' => ['space' => 'none'],
25+
'concat_space' => ['spacing' => 'one'],
26+
'declare_equal_normalize' => ['space' => 'single'],
27+
'dir_constant' => true,
28+
'function_typehint_space' => true,
29+
'lowercase_cast' => true,
30+
'native_function_casing' => true,
31+
'no_alias_functions' => true,
32+
'no_blank_lines_after_phpdoc' => true,
33+
'no_empty_statement' => true,
34+
'no_leading_namespace_whitespace' => true,
35+
'no_short_bool_cast' => true,
36+
'no_singleline_whitespace_before_semicolons' => true,
37+
'no_superfluous_elseif' => true,
38+
'no_trailing_comma_in_singleline_array' => true,
39+
'no_unneeded_control_parentheses' => true,
40+
'no_unused_imports' => true,
41+
'no_useless_else' => true,
42+
'no_whitespace_in_blank_line' => true,
43+
'ordered_imports' => true,
44+
'phpdoc_no_access' => true,
45+
'phpdoc_no_empty_return' => true,
46+
'phpdoc_no_package' => true,
47+
'phpdoc_scalar' => true,
48+
'phpdoc_trim' => true,
49+
'phpdoc_types' => true,
50+
'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'],
51+
'return_type_declaration' => ['space_before' => 'none'],
52+
'single_quote' => true,
53+
'whitespace_after_comma_in_array' => true,
54+
]);

.php_cs

-12
This file was deleted.

composer.json

-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
"require-dev": {
1515
"phpunit/phpunit": "^5.7"
1616
},
17-
"minimum-stability": "dev",
1817
"autoload": {
1918
"psr-4": {
2019
"TeamWorkPm\\": "src/"
@@ -28,9 +27,6 @@
2827
"tests/functions.php"
2928
]
3029
},
31-
"config": {
32-
"preferred-install": "dist"
33-
},
3430
"extra": {
3531
"branch-alias": {
3632
"dev-master": "1.0.6-dev"

src/Milestone.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ protected function init()
1515
'attributes' => [
1616
'type' => 'integer',
1717
],
18-
],//format YYYYMMDD
18+
], //format YYYYMMDD
1919
'notify' => [
2020
'required' => false,
2121
'attributes' => [
@@ -35,7 +35,7 @@ protected function init()
3535
],
3636
],
3737
'responsible_party_ids' => true,
38-
# USE ONLY FOR UPDATE OR PUT METHOD
38+
// USE ONLY FOR UPDATE OR PUT METHOD
3939
'move_upcoming_milestones' => [
4040
'sibling' => true,
4141
'required' => false,

src/People.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ public function update(array $data)
274274

275275
/**
276276
* @param int $id
277-
* @param null $project_id
277+
* @param int|null $project_id
278278
*
279279
* @return bool
280280
* @throws \TeamWorkPm\Exception

src/Portfolio/Card.php

-1
Original file line numberDiff line numberDiff line change
@@ -113,5 +113,4 @@ public function update(array $data)
113113

114114
return $this->rest->put("$this->action/$cardId/move", $data);
115115
}
116-
117116
}

src/Project.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ protected function init()
4848
'status' => false,
4949
'customFields' => [
5050
'required' => false,
51-
'type' => 'array'
52-
]
51+
'type' => 'array',
52+
],
5353
];
5454
}
5555

src/Project/People.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,10 @@ public function update(array $data)
181181
$project_id = (int)(empty($data['project_id']) ? 0 : $data['project_id']);
182182
$person_id = (int)(empty($data['person_id']) ? 0 : $data['person_id']);
183183
if ($project_id <= 0) {
184-
throw new Exception("Required field project_id");
184+
throw new Exception('Required field project_id');
185185
}
186186
if ($person_id <= 0) {
187-
throw new Exception("Required field person_id");
187+
throw new Exception('Required field person_id');
188188
}
189189
return $this->rest->put("projects/$project_id/people/$person_id", $data);
190190
}

src/Request/JSON.php

+4-6
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,19 @@
22

33
namespace TeamWorkPm\Request;
44

5-
use \stdClass;
6-
75
class JSON extends Model
86
{
97
protected function parseParameters($parameters)
108
{
119
if (!empty($parameters) && is_array($parameters)) {
12-
$object = new stdClass();
10+
$object = new \stdClass();
1311
$parent = $this->getParent();
14-
$object->$parent = new stdClass();
12+
$object->$parent = new \stdClass();
1513
$parent = $object->$parent;
1614

1715
if ($this->actionInclude('/reorder')) {
1816
foreach ($parameters as $id) {
19-
$item = new stdClass();
17+
$item = new \stdClass();
2018
$item->id = $id;
2119
$parent->{$this->parent}[] = $item;
2220
}
@@ -38,7 +36,7 @@ protected function parseParameters($parameters)
3836
}
3937
}
4038
}
41-
if (null !== $value) {
39+
if ($value !== null) {
4240
if (is_string($value)) {
4341
$value = mb_encode_numericentity(
4442
$value,

src/Request/Model.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ protected function getValue(&$field, &$options, array $parameters)
7979
if (!is_array($options)) {
8080
$options = ['required' => $options, 'attributes' => []];
8181
}
82-
$isNull = null === $value;
82+
$isNull = $value === null;
8383
if ($this->method === 'POST' && $options['required']) {
8484
if ($isNull) {
8585
throw new Exception('Required field ' . $field);
@@ -118,7 +118,7 @@ protected function getValue(&$field, &$options, array $parameters)
118118

119119
protected function actionInclude($value)
120120
{
121-
return false !== strrpos($this->action, $value);
121+
return strrpos($this->action, (string)$value) !== false;
122122
}
123123

124124
protected function getParent()

src/Request/XML.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ protected function parseParameters($parameters)
3232
$element = $this->doc->createElement($field);
3333
if (isset($options['attributes'])) {
3434
foreach ($options['attributes'] as $name => $type) {
35-
if (null !== $value) {
35+
if ($value !== null) {
3636
$element->setAttribute($name, $type);
3737
if ($name == 'type') {
3838
if ($type == 'array') {
@@ -48,7 +48,7 @@ protected function parseParameters($parameters)
4848
}
4949
}
5050
}
51-
if (null !== $value) {
51+
if ($value !== null) {
5252
if (is_bool($value)) {
5353
$value = var_export($value, true);
5454
}

src/Response/JSON.php

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

33
namespace TeamWorkPm\Response;
44

5-
use ArrayObject;
6-
use stdClass;
75
use TeamWorkPm\Exception;
86
use TeamWorkPm\Helper\Str;
97

@@ -134,17 +132,17 @@ protected function getContent()
134132
}
135133

136134
/**
137-
* @param array|stdClass $source
135+
* @param array|\stdClass $source
138136
*
139-
* @return ArrayObject
137+
* @return \ArrayObject
140138
*/
141139
protected static function camelizeObject($source)
142140
{
143141
if (!is_object($source) && !is_array($source)) {
144142
return $source;
145143
}
146144

147-
$destination = new ArrayObject([], ArrayObject::ARRAY_AS_PROPS);
145+
$destination = new \ArrayObject([], \ArrayObject::ARRAY_AS_PROPS);
148146
foreach ($source as $key => $value) {
149147
if (ctype_upper($key)) {
150148
$key = strtolower($key);

src/Response/Model.php

+2-7
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,7 @@
22

33
namespace TeamWorkPm\Response;
44

5-
use ArrayAccess;
6-
use ArrayIterator;
7-
use Countable;
8-
use IteratorAggregate;
9-
10-
abstract class Model implements IteratorAggregate, Countable, ArrayAccess
5+
abstract class Model implements \IteratorAggregate, \Countable, \ArrayAccess
116
{
127
protected $string = null;
138

@@ -56,7 +51,7 @@ public function getHeaders()
5651

5752
public function getIterator()
5853
{
59-
return new ArrayIterator($this->data);
54+
return new \ArrayIterator($this->data);
6055
}
6156

6257
public function count()

src/Response/XML.php

+7-9
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22

33
namespace TeamWorkPm\Response;
44

5+
use SimpleXMLElement;
56
use TeamWorkPm\Exception;
6-
use \TeamWorkPm\Helper\Str;
7-
use \stdClass;
8-
use \SimpleXMLElement;
9-
use \DOMDocument;
7+
use TeamWorkPm\Helper\Str;
108

119
class XML extends Model
1210
{
@@ -95,7 +93,7 @@ public function parse($data, array $headers)
9593
*/
9694
protected function getContent()
9795
{
98-
$dom = new DOMDocument('1.0');
96+
$dom = new \DOMDocument('1.0');
9997
$dom->loadXML($this->string);
10098
$dom->preserveWhiteSpace = false;
10199
$dom->formatOutput = true;
@@ -106,15 +104,15 @@ protected function getContent()
106104
/**
107105
* Convierte un objecto SimpleXMLElement a stdClass
108106
*
109-
* @param SimpleXMLElement $source
107+
* @param \SimpleXMLElement $source
110108
* @param bool $isArray
111-
* @return stdClass
109+
* @return \stdClass
112110
*/
113111
private static function toStdClass(
114-
SimpleXMLElement $source,
112+
\SimpleXMLElement $source,
115113
$isArray = false
116114
) {
117-
$destination = $isArray ? [] : new stdClass();
115+
$destination = $isArray ? [] : new \stdClass();
118116
foreach ($source as $key => $value) {
119117
$key = Str::camel($key);
120118
$attrs = $value->attributes();

src/Tag.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,4 @@ public function addTagToResource($resource = '', $id = null)
9999
{
100100
return $this->rest->put("$resource/$id/$this->action");
101101
}
102-
}
102+
}

src/Task.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ protected function init()
6161
],
6262
'responsible_party_id' => false,
6363
'attachments' => false,
64-
'pending_file_attachments' => false
64+
'pending_file_attachments' => false,
6565
];
6666
$this->parent = 'todo-item';
6767
$this->action = 'todo_items';

tests/AccountTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,4 @@ public function authenticate()
4747
$this->fail($e->getMessage());
4848
}
4949
}
50-
}
50+
}

tests/ActivityTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,4 @@ public function getByProject()
6161
$this->fail($e->getMessage());
6262
}
6363
}
64-
}
64+
}

tests/CompanyTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function insert($data)
3232
$this->fail('An expected exception has not been raised.');
3333
} catch (Exception $e) {
3434
$this->assertEquals(
35-
"Invalid value for field countrycode",
35+
'Invalid value for field countrycode',
3636
$e->getMessage()
3737
);
3838
}

0 commit comments

Comments
 (0)