Skip to content

Commit

Permalink
feat: add manual tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fox91 committed Dec 25, 2024
1 parent f93aa39 commit 45a66e4
Show file tree
Hide file tree
Showing 652 changed files with 19,345 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@

# Ignore files for distribution archives.
/.* export-ignore
/tests export-ignore
19 changes: 19 additions & 0 deletions tests/fixed/php-7.4/Fox91CodingStandard/ClassPropertySpacing.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php
declare(strict_types=1);

namespace Spacing;

final class ClassPropertySpacing
{
public bool $foo;

/** @var array<string> */
public array $bar;

/** @var array<string> */
public array $baz;

public int $qux;

public int $fred;
}
130 changes: 130 additions & 0 deletions tests/fixed/php-7.4/Fox91CodingStandard/ControlStructures.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
<?php
declare(strict_types=1);

namespace ControlStructures;

use InvalidArgumentException;
use Throwable;

use const PHP_VERSION;

class ControlStructures
{
private const VERSION = PHP_VERSION;

/** @return iterable<int> */
public function varAndIfNoSpaceBetween(): iterable
{
$var = 1;
if (self::VERSION === 0) {
yield 0;
}
}

/** @return iterable<int> */
public function ifAndYieldSpaceBetween(): iterable
{
if (self::VERSION === 0) {
yield 0;
}
yield 1;
}

/** @return iterable<int> */
public function ifAndYieldFromSpaceBetween(): iterable
{
if (self::VERSION === 0) {
yield 0;
}
yield from [];
}

public function ifAndThrowSpaceBetween(): void
{
if (self::VERSION === 0) {
return;
}
throw new InvalidArgumentException();
}

public function ifAndReturnSpaceBetween(): int
{
if (self::VERSION === 0) {
return 0;
}

return 1;
}

public function noSpaceAroundCase(): void
{
switch (self::VERSION) {
case 1:
case 2:
// do something
break;
case 3:
// do something else
break;
default:
}
}

public function spaceBelowBlocks(): void
{
if (true) {
echo 1;
}
do {
echo 2;
} while (true);
while (true) {
echo 3;
}
for ($i = 0; $i < 1; $i++) {
echo $i;
}
foreach ([] as $item) {
echo $item;
}
switch (true) {
default:
}
try {
echo 4;
} catch (Throwable) {
}
echo 5;
}

public function spaceAroundMultilineIfs(): void
{
if (true
&& false
) {
echo 1;
} elseif (false
|| true
) {
echo 2;
}
}

public function spacingAroundCasesWithBreakAndReturn(): void
{
switch (true) {
case 1:
throw new InvalidArgumentException();

case 2:
return;

case 3:
break;

case 4:
echo 1;

}
}
}
51 changes: 51 additions & 0 deletions tests/fixed/php-7.4/Fox91CodingStandard/EarlyReturn.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php
declare(strict_types=1);

namespace Example;

class EarlyReturn
{
public function bar(): bool
{
if ($bar === 'bar') {
return true;
} else {
return false;
}
}

public function foo(): ?string
{
foreach ($items as $item) {
if (!($item->isItem())) {
return 'There is an item that is not an item';
} else {
continue;
}
}

return null;
}

public function baz(): string
{
if ($number > 0) {
return 'Number is grater then 0';
} else {
exit;
}
}

public function quoox(): bool
{
if (true === 'true') {
if (false === false) {
return true;
}
} else {
return false;
}

return true;
}
}
8 changes: 8 additions & 0 deletions tests/fixed/php-7.4/Fox91CodingStandard/ExampleBackedEnum.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php
declare(strict_types=1);

namespace ExampleBackedEnum;

enum ExampleBackedEnum : int
{
}
12 changes: 12 additions & 0 deletions tests/fixed/php-7.4/Fox91CodingStandard/Exceptions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php
declare(strict_types=1);

namespace Exceptions;

use Exception;
use Throwable;

try {
throw new Exception();
} catch (Throwable $throwable) {
}
17 changes: 17 additions & 0 deletions tests/fixed/php-7.4/Fox91CodingStandard/LowCaseTypes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
declare(strict_types=1);

namespace Types;

class LowCaseTypes
{
public function stringToInt(String $string): int
{
return (int) $string;
}

public function returnString(): String
{
return 'foo';
}
}
21 changes: 21 additions & 0 deletions tests/fixed/php-7.4/Fox91CodingStandard/NamingCamelCase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
declare(strict_types=1);

namespace Example;

class NamingCamelCase
{
/** @var mixed */
public $A;

/** @var mixed */
protected $B;

/** @var mixed */
private $C;

public function fcn(string $A): void
{
$Test = $A;
}
}
20 changes: 20 additions & 0 deletions tests/fixed/php-7.4/Fox91CodingStandard/PropertyDeclaration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php
declare(strict_types=1);

namespace Spacing;

final class PropertyDeclaration
{
public bool $boolPropertyWithDefaultValue = false;

public string $stringProperty;

public int $intProperty;

public ? string $nullableString = null;

public function __construct(
public readonly Foo $foo,
) {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php
declare(strict_types=1);

namespace Doctrine;

use function var_dump;

// phpcs:disable PSR1.Files.SideEffects

class TrailingCommaOnFunctions
{
public function a(int $arg,): void
{
}

public function b(
int $arg
): void {
}

public function uses(): void
{
$var = null;

$singleLine = static function (int $arg) use ($var,): void {
var_dump($var);
};

$multiLine = static function (int $arg) use (
$var
): void {
var_dump($var);
};
}
}

$class = new TrailingCommaOnFunctions();

// phpcs:ignore Generic.Functions.FunctionCallArgumentSpacing.NoSpaceAfterComma
$class->a(1,);

$class->a(1);
16 changes: 16 additions & 0 deletions tests/fixed/php-7.4/Fox91CodingStandard/UnusedVariables.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
declare(strict_types=1);

namespace Example;

class UnusedVariables
{
public function unusedInheritedVariablePassedToClosure(): void
{
$foo = 'foo';

$bar = static function () use ($foo): int {
return 1;
};
}
}
Loading

0 comments on commit 45a66e4

Please sign in to comment.