Skip to content

Commit

Permalink
test: Exception > cannot set empty content for id-based Token
Browse files Browse the repository at this point in the history
  • Loading branch information
PedroTroller committed Oct 30, 2020
1 parent 9a1d294 commit 7b6a3e4
Showing 1 changed file with 123 additions and 0 deletions.
123 changes: 123 additions & 0 deletions tests/UseCase/LineBreakBetweenMethods/Regression/Case4.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
<?php

declare(strict_types=1);

namespace tests\UseCase\LineBreakBetweenMethods\Regression;

use PedroTroller\CS\Fixer\CodingStyle\LineBreakBetweenMethodArgumentsFixer;
use tests\UseCase;

/**
* https://github.com/PedroTroller/PhpCSFixer-Custom-Fixers/issues/104
*/
final class Case4 implements UseCase
{
/**
* {@inheritDoc}
*/
public function getFixer()
{
$fixer = new LineBreakBetweenMethodArgumentsFixer();

$fixer->configure([
'max-args' => 4,
'max-length' => 100,
]);

return $fixer;
}

/**
* {@inheritDoc}
*/
public function getRawScript()
{
return <<<'PHP'
<?php
// error, because line is too long and fixer will try to split it
function addDateIntervalaaaaaaaaaaaaaakjfklsdjfklsjfkjklsajlkkldfjklajlkfjaslfjskdfjksajlkfjldaj(DateTimeInterface $date): void
{
echo 'do something';
}
//its ok, because we have spaces before function
function addDateIntervalaaaaaaaaaaaaaakjfklsdjfklsjfkjklsajlkkldfjklajlkfjaslfjskdfjksajlkfjldaj(DateTimeInterface $date): void
{
echo 'do something';
}
//its ok, because we do not have return type
function addDateIntervalaaaaaaaaaaaaaakjfklsdjfklsjfkjklsajlkkldfjklajlkfjaslfjskdfjksajlkfjldaj(DateTimeInterface $date): void
{
echo 'do something';
}
//is ok, because function name less than 100 chars and fixer do not try to split it
function addDateInterval(DateTimeInterface $date): void
{
echo 'do something';
}
//error
function someFuncName(
string $format,
string $time,
DateTimeZone $timezone = null
): void {
echo 'do something';
}
PHP;
}

/**
* {@inheritDoc}
*/
public function getExpectation()
{
return <<<'PHP'
<?php
// error, because line is too long and fixer will try to split it
function addDateIntervalaaaaaaaaaaaaaakjfklsdjfklsjfkjklsajlkkldfjklajlkfjaslfjskdfjksajlkfjldaj(
DateTimeInterface $date
): void {
echo 'do something';
}
//its ok, because we have spaces before function
function addDateIntervalaaaaaaaaaaaaaakjfklsdjfklsjfkjklsajlkkldfjklajlkfjaslfjskdfjksajlkfjldaj(
DateTimeInterface $date
): void {
echo 'do something';
}
//its ok, because we do not have return type
function addDateIntervalaaaaaaaaaaaaaakjfklsdjfklsjfkjklsajlkkldfjklajlkfjaslfjskdfjksajlkfjldaj(
DateTimeInterface $date
): void {
echo 'do something';
}
//is ok, because function name less than 100 chars and fixer do not try to split it
function addDateInterval(DateTimeInterface $date): void
{
echo 'do something';
}
//error
function someFuncName(string $format, string $time, DateTimeZone $timezone = null): void
{
echo 'do something';
}
PHP;
}

/**
* {@inheritDoc}
*/
public function getMinSupportedPhpVersion()
{
return 70000;
}
}

0 comments on commit 7b6a3e4

Please sign in to comment.