Skip to content
This repository was archived by the owner on Nov 21, 2019. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Libero/ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@
</properties>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.DisallowArrayTypeHintSyntax"/>
<rule ref="SlevomatCodingStandard.TypeHints.LongTypeHints"/>
<rule ref="SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue"/>
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHintSpacing"/>
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing">
Expand Down
97 changes: 97 additions & 0 deletions tests/cases/classes/method-type-long
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
---DESCRIPTION---
Shorthand types must be used
---FILENAME---
Foo.php
---CONTENTS---
<?php

declare(strict_types=1);

namespace Vendor;

class Foo
{
/** @var integer */
public $foo;

/** @var boolean */
public $bar;

/** @var array<integer, boolean> */
public $baz;

/**
* @param integer $quux
*
* @return integer
*/
public function qux($quux)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't use TypeHintDeclaration to force these to be native types, but in this case it doesn't extend/implement anything. Wonder if we can get it to work in that case? Would mean it could create breaking changes though...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

slevomat/coding-standard#628 got closed pretty quickly. Might become an option in the future.

{
}

/**
* @param boolean $corge
*
* @return boolean
*/
public function quuz($corge)
{
}

/**
* @param array<integer, boolean> $garply
*
* @return array<integer, boolean>
*/
public function grault($garply)
{
}
}

---FIXED---
<?php

declare(strict_types=1);

namespace Vendor;

class Foo
{
/** @var int */
public $foo;

/** @var bool */
public $bar;

/** @var array<int, bool> */
public $baz;

/**
* @param int $quux
*
* @return int
*/
public function qux($quux)
{
}

/**
* @param bool $corge
*
* @return bool
*/
public function quuz($corge)
{
}

/**
* @param array<int, bool> $garply
*
* @return array<int, bool>
*/
public function grault($garply)
{
}
}

---
67 changes: 67 additions & 0 deletions tests/cases/functions/type-long
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
---DESCRIPTION---
Shorthand types must be used
---CONTENTS---
<?php

declare(strict_types=1);

/**
* @param integer $bar
*
* @return integer
*/
function foo($bar)
{
}

/**
* @param boolean $qux
*
* @return boolean
*/
function baz($qux)
{
}

/**
* @param array<integer, boolean> $quuz
*
* @return array<integer, boolean>
*/
function quux($quuz)
{
}

---FIXED---
<?php

declare(strict_types=1);

/**
* @param int $bar
*
* @return int
*/
function foo($bar)
{
}

/**
* @param bool $qux
*
* @return bool
*/
function baz($qux)
{
}

/**
* @param array<int, bool> $quuz
*
* @return array<int, bool>
*/
function quux($quuz)
{
}

---
67 changes: 67 additions & 0 deletions tests/cases/interfaces/method-type-long
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
---DESCRIPTION---
Shorthand types must be used
---FILENAME---
Foo.php
---CONTENTS---
<?php

declare(strict_types=1);

namespace Vendor;

interface Foo
{
/**
* @param integer $baz
*
* @return integer
*/
public function bar($baz);

/**
* @param boolean $quux
*
* @return boolean
*/
public function qux($quux);

/**
* @param array<integer, boolean> $corge
*
* @return array<integer, boolean>
*/
public function quuz($corge);
}

---FIXED---
<?php

declare(strict_types=1);

namespace Vendor;

interface Foo
{
/**
* @param int $baz
*
* @return int
*/
public function bar($baz);

/**
* @param bool $quux
*
* @return bool
*/
public function qux($quux);

/**
* @param array<int, bool> $corge
*
* @return array<int, bool>
*/
public function quuz($corge);
}

---
97 changes: 97 additions & 0 deletions tests/cases/trait/method-type-long
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
---DESCRIPTION---
Shorthand types must be used
---FILENAME---
Foo.php
---CONTENTS---
<?php

declare(strict_types=1);

namespace Vendor;

trait Foo
{
/** @var integer */
public $foo;

/** @var boolean */
public $bar;

/** @var array<integer, boolean> */
public $baz;

/**
* @param integer $quux
*
* @return integer
*/
public function qux($quux)
{
}

/**
* @param boolean $corge
*
* @return boolean
*/
public function quuz($corge)
{
}

/**
* @param array<integer, boolean> $garply
*
* @return array<integer, boolean>
*/
public function grault($garply)
{
}
}

---FIXED---
<?php

declare(strict_types=1);

namespace Vendor;

trait Foo
{
/** @var int */
public $foo;

/** @var bool */
public $bar;

/** @var array<int, bool> */
public $baz;

/**
* @param int $quux
*
* @return int
*/
public function qux($quux)
{
}

/**
* @param bool $corge
*
* @return bool
*/
public function quuz($corge)
{
}

/**
* @param array<int, bool> $garply
*
* @return array<int, bool>
*/
public function grault($garply)
{
}
}

---