Skip to content
This repository was archived by the owner on Nov 21, 2019. It is now read-only.

Commit 03f3a41

Browse files
Shorthand types must be used (#52)
1 parent bc5be42 commit 03f3a41

File tree

5 files changed

+329
-0
lines changed

5 files changed

+329
-0
lines changed

src/Libero/ruleset.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@
127127
</properties>
128128
</rule>
129129
<rule ref="SlevomatCodingStandard.TypeHints.DisallowArrayTypeHintSyntax"/>
130+
<rule ref="SlevomatCodingStandard.TypeHints.LongTypeHints"/>
130131
<rule ref="SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue"/>
131132
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHintSpacing"/>
132133
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing">
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
---DESCRIPTION---
2+
Shorthand types must be used
3+
---FILENAME---
4+
Foo.php
5+
---CONTENTS---
6+
<?php
7+
8+
declare(strict_types=1);
9+
10+
namespace Vendor;
11+
12+
class Foo
13+
{
14+
/** @var integer */
15+
public $foo;
16+
17+
/** @var boolean */
18+
public $bar;
19+
20+
/** @var array<integer, boolean> */
21+
public $baz;
22+
23+
/**
24+
* @param integer $quux
25+
*
26+
* @return integer
27+
*/
28+
public function qux($quux)
29+
{
30+
}
31+
32+
/**
33+
* @param boolean $corge
34+
*
35+
* @return boolean
36+
*/
37+
public function quuz($corge)
38+
{
39+
}
40+
41+
/**
42+
* @param array<integer, boolean> $garply
43+
*
44+
* @return array<integer, boolean>
45+
*/
46+
public function grault($garply)
47+
{
48+
}
49+
}
50+
51+
---FIXED---
52+
<?php
53+
54+
declare(strict_types=1);
55+
56+
namespace Vendor;
57+
58+
class Foo
59+
{
60+
/** @var int */
61+
public $foo;
62+
63+
/** @var bool */
64+
public $bar;
65+
66+
/** @var array<int, bool> */
67+
public $baz;
68+
69+
/**
70+
* @param int $quux
71+
*
72+
* @return int
73+
*/
74+
public function qux($quux)
75+
{
76+
}
77+
78+
/**
79+
* @param bool $corge
80+
*
81+
* @return bool
82+
*/
83+
public function quuz($corge)
84+
{
85+
}
86+
87+
/**
88+
* @param array<int, bool> $garply
89+
*
90+
* @return array<int, bool>
91+
*/
92+
public function grault($garply)
93+
{
94+
}
95+
}
96+
97+
---

tests/cases/functions/type-long

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
---DESCRIPTION---
2+
Shorthand types must be used
3+
---CONTENTS---
4+
<?php
5+
6+
declare(strict_types=1);
7+
8+
/**
9+
* @param integer $bar
10+
*
11+
* @return integer
12+
*/
13+
function foo($bar)
14+
{
15+
}
16+
17+
/**
18+
* @param boolean $qux
19+
*
20+
* @return boolean
21+
*/
22+
function baz($qux)
23+
{
24+
}
25+
26+
/**
27+
* @param array<integer, boolean> $quuz
28+
*
29+
* @return array<integer, boolean>
30+
*/
31+
function quux($quuz)
32+
{
33+
}
34+
35+
---FIXED---
36+
<?php
37+
38+
declare(strict_types=1);
39+
40+
/**
41+
* @param int $bar
42+
*
43+
* @return int
44+
*/
45+
function foo($bar)
46+
{
47+
}
48+
49+
/**
50+
* @param bool $qux
51+
*
52+
* @return bool
53+
*/
54+
function baz($qux)
55+
{
56+
}
57+
58+
/**
59+
* @param array<int, bool> $quuz
60+
*
61+
* @return array<int, bool>
62+
*/
63+
function quux($quuz)
64+
{
65+
}
66+
67+
---
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
---DESCRIPTION---
2+
Shorthand types must be used
3+
---FILENAME---
4+
Foo.php
5+
---CONTENTS---
6+
<?php
7+
8+
declare(strict_types=1);
9+
10+
namespace Vendor;
11+
12+
interface Foo
13+
{
14+
/**
15+
* @param integer $baz
16+
*
17+
* @return integer
18+
*/
19+
public function bar($baz);
20+
21+
/**
22+
* @param boolean $quux
23+
*
24+
* @return boolean
25+
*/
26+
public function qux($quux);
27+
28+
/**
29+
* @param array<integer, boolean> $corge
30+
*
31+
* @return array<integer, boolean>
32+
*/
33+
public function quuz($corge);
34+
}
35+
36+
---FIXED---
37+
<?php
38+
39+
declare(strict_types=1);
40+
41+
namespace Vendor;
42+
43+
interface Foo
44+
{
45+
/**
46+
* @param int $baz
47+
*
48+
* @return int
49+
*/
50+
public function bar($baz);
51+
52+
/**
53+
* @param bool $quux
54+
*
55+
* @return bool
56+
*/
57+
public function qux($quux);
58+
59+
/**
60+
* @param array<int, bool> $corge
61+
*
62+
* @return array<int, bool>
63+
*/
64+
public function quuz($corge);
65+
}
66+
67+
---

tests/cases/trait/method-type-long

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
---DESCRIPTION---
2+
Shorthand types must be used
3+
---FILENAME---
4+
Foo.php
5+
---CONTENTS---
6+
<?php
7+
8+
declare(strict_types=1);
9+
10+
namespace Vendor;
11+
12+
trait Foo
13+
{
14+
/** @var integer */
15+
public $foo;
16+
17+
/** @var boolean */
18+
public $bar;
19+
20+
/** @var array<integer, boolean> */
21+
public $baz;
22+
23+
/**
24+
* @param integer $quux
25+
*
26+
* @return integer
27+
*/
28+
public function qux($quux)
29+
{
30+
}
31+
32+
/**
33+
* @param boolean $corge
34+
*
35+
* @return boolean
36+
*/
37+
public function quuz($corge)
38+
{
39+
}
40+
41+
/**
42+
* @param array<integer, boolean> $garply
43+
*
44+
* @return array<integer, boolean>
45+
*/
46+
public function grault($garply)
47+
{
48+
}
49+
}
50+
51+
---FIXED---
52+
<?php
53+
54+
declare(strict_types=1);
55+
56+
namespace Vendor;
57+
58+
trait Foo
59+
{
60+
/** @var int */
61+
public $foo;
62+
63+
/** @var bool */
64+
public $bar;
65+
66+
/** @var array<int, bool> */
67+
public $baz;
68+
69+
/**
70+
* @param int $quux
71+
*
72+
* @return int
73+
*/
74+
public function qux($quux)
75+
{
76+
}
77+
78+
/**
79+
* @param bool $corge
80+
*
81+
* @return bool
82+
*/
83+
public function quuz($corge)
84+
{
85+
}
86+
87+
/**
88+
* @param array<int, bool> $garply
89+
*
90+
* @return array<int, bool>
91+
*/
92+
public function grault($garply)
93+
{
94+
}
95+
}
96+
97+
---

0 commit comments

Comments
 (0)