Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5']
php: ['8.0', '8.1', '8.2', '8.3'] #, '8.4', '8.5']
include:
- php: '8.0'
run-qa: true
Expand Down
13 changes: 9 additions & 4 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,25 @@
* ;
* ```
*/

$finder = (new PhpCsFixer\Finder())
->in(__DIR__)
->ignoreDotFiles(false)
;

return (new PhpCsFixer\Config())
->setRules([
'@Symfony' => true,

// [Symfony] defaults to `camelCase`, we set it to `snake_case` (phpspec style)
// [Symfony] defaults to `camelCase`, we set it to `snake_case` (phpspec style)
'php_unit_method_casing' => ['case' => 'snake_case'],

// [Symfony] defaults to `true`, we set it to `false` for phpspec
'visibility_required' => false,
// [Symfony] defaults to `['elements' => ['const', 'method', 'property']]`
// We exclude `method` for phpspec (no visibility keyword)
// We exclude `const` because we support PHP 8.0 (const visibility is optional)
'modifier_keywords' => ['elements' => ['property']],

// [Symfony] defaults to `['elements' => ['arguments', 'arrays', 'parameters']]`
'trailing_comma_in_multiline' => ['elements' => ['arguments', 'arrays', 'parameters']],
])
->setUsingCache(true)
->setFinder($finder)
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
"require": {
"memio/model": "^3.0",
"memio/pretty-printer": "^3.0",
"php": "^7.2 || ^8.0",
"twig/twig": "^1.18 || ^2.0 || ^3.0"
"php": "^8.0",
"twig/twig": "^3.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.19.3",
"phpspec/phpspec": "^6.1 || ^7.0",
"friendsofphp/php-cs-fixer": "^3.0",
"phpspec/phpspec": "^7.0",
"rector/rector": "^2.3",
"rector/swiss-knife": "^2.3",
"phpstan/phpstan": "^2.1"
Expand Down
2 changes: 1 addition & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ includes:

parameters:
level: 0
phpVersion: 70200
phpVersion: 80000
paths:
- src/
4 changes: 2 additions & 2 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
return RectorConfig::configure()
->withCache(
'/tmp/rector',
FileCacheStorage::class
FileCacheStorage::class,
)
->withPaths([
__DIR__,
Expand All @@ -23,7 +23,7 @@
])
->withSets([
// —— PHP ——————————————————————————————————————————————————————————————
SetList::PHP_72,
SetList::PHP_80,
])
->withRules([
]);
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@

class ContractLineStrategySpec extends ObjectBehavior
{
function it_is_a_line_strategy()
public function it_is_a_line_strategy()
{
$this->shouldImplement(LineStrategy::class);
}

function it_supports_contracts()
public function it_supports_contracts()
{
$contract = (new Contract('Memio\PrettyPrinter\TemplateEngine'));

$this->supports($contract)->shouldBe(true);
}

function it_needs_an_empty_line_after_constants_if_it_also_has_methods()
public function it_needs_an_empty_line_after_constants_if_it_also_has_methods()
{
$contract = (new Contract('Memio\PrettyPrinter\TemplateEngine'))
->addConstant(new Constant('CONSTANT_ONE', 1))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@

class FileLineStrategySpec extends ObjectBehavior
{
function it_is_a_line_strategy()
public function it_is_a_line_strategy()
{
$this->shouldImplement(LineStrategy::class);
}

function it_supports_files()
public function it_supports_files()
{
$file = new File('src/Memio/Model/Contract.php');

$this->supports($file)->shouldBe(true);
}

function it_needs_an_empty_line_after_use_statements()
public function it_needs_an_empty_line_after_use_statements()
{
$file = (new File('src/Memio/Model/Contract.php'))
->addFullyQualifiedName(new FullyQualifiedName('Memio\Model\Phpdoc\StructurePhpdoc'))
Expand Down
10 changes: 5 additions & 5 deletions spec/Memio/TwigTemplateEngine/TwigExtension/Line/LineSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

class LineSpec extends ObjectBehavior
{
function it_executes_the_first_strategy_that_supports_given_model(
LineStrategy $lineStrategy
public function it_executes_the_first_strategy_that_supports_given_model(
LineStrategy $lineStrategy,
) {
$this->add($lineStrategy);

Expand All @@ -33,8 +33,8 @@ function it_executes_the_first_strategy_that_supports_given_model(
$this->needsLineAfter($model, $block)->shouldBe($strategyReturn);
}

function it_fails_when_no_strategy_supports_given_model(
LineStrategy $lineStrategy
public function it_fails_when_no_strategy_supports_given_model(
LineStrategy $lineStrategy,
) {
$this->add($lineStrategy);

Expand All @@ -43,7 +43,7 @@ function it_fails_when_no_strategy_supports_given_model(
$lineStrategy->supports($model)->willReturn(false);

$this->shouldThrow(
InvalidArgumentException::class
InvalidArgumentException::class,
)->duringNeedsLineAfter($model, 'arguments');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@

class MethodPhpdocLineStrategySpec extends ObjectBehavior
{
function it_is_a_line_strategy()
public function it_is_a_line_strategy()
{
$this->shouldImplement(LineStrategy::class);
}

function it_supports_method_phpdocs()
public function it_supports_method_phpdocs()
{
$methodPhpdoc = new MethodPhpdoc();

$this->supports($methodPhpdoc)->shouldBe(true);
}

function it_needs_a_new_line_after_description_if_it_has_any_other_tag()
public function it_needs_a_new_line_after_description_if_it_has_any_other_tag()
{
$methodPhpdoc = (new MethodPhpdoc())
->setDescription(new Description('Helpful description'))
Expand All @@ -43,7 +43,7 @@ function it_needs_a_new_line_after_description_if_it_has_any_other_tag()
$this->needsLineAfter($methodPhpdoc, 'description')->shouldBe(true);
}

function it_needs_a_new_line_after_parameter_tags_if_it_has_a_deprecation_tag()
public function it_needs_a_new_line_after_parameter_tags_if_it_has_a_deprecation_tag()
{
$methodPhpdoc = (new MethodPhpdoc())
->addParameterTag(new ParameterTag('string', 'filename'))
Expand All @@ -53,7 +53,7 @@ function it_needs_a_new_line_after_parameter_tags_if_it_has_a_deprecation_tag()
$this->needsLineAfter($methodPhpdoc, 'parameter_tags')->shouldBe(true);
}

function it_needs_a_new_line_after_deprecation_if_it_also_has_an_api_tag()
public function it_needs_a_new_line_after_deprecation_if_it_also_has_an_api_tag()
{
$methodPhpdoc = (new MethodPhpdoc())
->setDeprecationTag(new DeprecationTag())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@

class ObjectLineStrategySpec extends ObjectBehavior
{
function it_is_a_line_strategy()
public function it_is_a_line_strategy()
{
$this->shouldImplement(LineStrategy::class);
}

function it_supports_objects()
public function it_supports_objects()
{
$objekt = new Objekt('Memio\Model\Objekt');

$this->supports($objekt)->shouldBe(true);
}

function it_needs_an_empty_line_after_constants_if_it_also_has_properties()
public function it_needs_an_empty_line_after_constants_if_it_also_has_properties()
{
$objekt = (new Objekt('Memio\Model\Objekt'))
->addConstant(new Constant('CONSTANT_ONE', 1))
Expand All @@ -44,7 +44,7 @@ function it_needs_an_empty_line_after_constants_if_it_also_has_properties()
$this->needsLineAfter($objekt, ObjectLineStrategy::CONSTANTS_BLOCK)->shouldBe(true);
}

function it_needs_an_empty_line_after_constants_if_it_also_has_methods()
public function it_needs_an_empty_line_after_constants_if_it_also_has_methods()
{
$objekt = (new Objekt('Memio\Model\Objekt'))
->addConstant(new Constant('CONSTANT_ONE', 1))
Expand All @@ -54,7 +54,7 @@ function it_needs_an_empty_line_after_constants_if_it_also_has_methods()
$this->needsLineAfter($objekt, ObjectLineStrategy::CONSTANTS_BLOCK)->shouldBe(true);
}

function it_needs_an_empty_line_after_properties_if_it_also_has_methods()
public function it_needs_an_empty_line_after_properties_if_it_also_has_methods()
{
$objekt = (new Objekt('Memio\Model\Objekt'))
->addProperty(new Property('filename'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@

class StructurePhpdocLineStrategySpec extends ObjectBehavior
{
function it_is_a_line_strategy()
public function it_is_a_line_strategy()
{
$this->shouldImplement(LineStrategy::class);
}

function it_supports_structure_phpdocs()
public function it_supports_structure_phpdocs()
{
$structurePhpdoc = new StructurePhpdoc();

$this->supports($structurePhpdoc)->shouldBe(true);
}

function it_needs_an_empty_line_after_description_if_it_also_has_an_api_tag()
public function it_needs_an_empty_line_after_description_if_it_also_has_an_api_tag()
{
$structurePhpdoc = (new StructurePhpdoc())
->setDescription(new Description('helpful description'))
Expand All @@ -43,7 +43,7 @@ function it_needs_an_empty_line_after_description_if_it_also_has_an_api_tag()
$this->needsLineAfter($structurePhpdoc, StructurePhpdocLineStrategy::DESCRPTION)->shouldBe(true);
}

function it_needs_an_empty_line_after_description_if_it_also_has_a_deprecation_tag()
public function it_needs_an_empty_line_after_description_if_it_also_has_a_deprecation_tag()
{
$structurePhpdoc = (new StructurePhpdoc())
->setDescription(new Description('helpful description'))
Expand All @@ -53,7 +53,7 @@ function it_needs_an_empty_line_after_description_if_it_also_has_a_deprecation_t
$this->needsLineAfter($structurePhpdoc, StructurePhpdocLineStrategy::DESCRPTION)->shouldBe(true);
}

function it_needs_an_empty_line_after_deprecation_tag_if_it_also_has_an_api_tag()
public function it_needs_an_empty_line_after_deprecation_tag_if_it_also_has_an_api_tag()
{
$structurePhpdoc = (new StructurePhpdoc())
->setDeprecationTag(new DeprecationTag())
Expand Down
18 changes: 9 additions & 9 deletions spec/Memio/TwigTemplateEngine/TwigTemplateEngineSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,32 @@

class TwigTemplateEngineSpec extends ObjectBehavior
{
const TEMPLATE_PATH = '/tmp/templates';
const TEMPLATE = 'argument';
const OUTPUT = '$dateTime';
public const TEMPLATE_PATH = '/tmp/templates';
public const TEMPLATE = 'argument';
public const OUTPUT = '$dateTime';

function let(Environment $twig)
public function let(Environment $twig)
{
$this->beConstructedWith($twig);
}

function it_is_a_template_engine()
public function it_is_a_template_engine()
{
$this->shouldHaveType(TemplateEngine::class);
}

function it_can_have_more_paths(
public function it_can_have_more_paths(
Environment $twig,
FilesystemLoader $loader
FilesystemLoader $loader,
) {
$twig->getLoader()->willReturn($loader);
$loader->prependPath(self::TEMPLATE_PATH)->shouldBeCalled();

$this->addPath(self::TEMPLATE_PATH);
}

function it_renders_templates_using_twig(
Environment $twig
public function it_renders_templates_using_twig(
Environment $twig,
) {
$parameters = ['name' => 'dateTime'];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

class ContractLineStrategy implements LineStrategy
{
const CONSTANTS_BLOCK = 'constants';
public const CONSTANTS_BLOCK = 'constants';

public function supports($model): bool
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

class FileLineStrategy implements LineStrategy
{
const USE_STATEMENTS_BLOCK = 'fully_qualified_names';
public const USE_STATEMENTS_BLOCK = 'fully_qualified_names';

public function supports($model): bool
{
Expand Down
2 changes: 1 addition & 1 deletion src/Memio/TwigTemplateEngine/TwigExtension/Line/Line.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ public function needsLineAfter($model, string $block): bool
}
}

throw new InvalidArgumentException('No strategy supports given model '.get_class($model));
throw new InvalidArgumentException('No strategy supports given model '.$model::class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

class ObjectLineStrategy implements LineStrategy
{
const CONSTANTS_BLOCK = 'constants';
const PROPERTIES_BLOCK = 'properties';
public const CONSTANTS_BLOCK = 'constants';
public const PROPERTIES_BLOCK = 'properties';

public function supports($model): bool
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

class StructurePhpdocLineStrategy implements LineStrategy
{
const DESCRPTION = 'description';
const DEPRECATION_TAG = 'deprecation_tag';
public const DESCRPTION = 'description';
public const DEPRECATION_TAG = 'deprecation_tag';

public function supports($model): bool
{
Expand Down
2 changes: 1 addition & 1 deletion src/Memio/TwigTemplateEngine/TwigExtension/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function hasTypehint($model): bool

public function filterNamespace(string $stringType): string
{
$nullablePrefix = '?' === substr($stringType, 0, 1)
$nullablePrefix = str_starts_with($stringType, '?')
? '?'
: '';

Expand Down
Loading