Skip to content

Commit

Permalink
Updated coding standard and updated PHPStan (#452)
Browse files Browse the repository at this point in the history
  • Loading branch information
lulco authored Dec 17, 2023
1 parent e4945f1 commit 7ef44a6
Show file tree
Hide file tree
Showing 26 changed files with 59 additions and 17 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@

## [Unreleased][unreleased]

### Fixed
- Updated coding standard (Possible **BC break** - added `final` or `abstract` to (almost) all classes)
- Bleeding edge changes - updated typehints

## [0.16.3] - 2023-11-26
### Added
- Support for PHP 8.3
-

## [0.16.2] - 2023-11-22
### Fixed
- Fixed first class callable filters
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"require": {
"php": ">=7.4 <8.4",
"ext-json": "*",
"phpstan/phpstan": "^1.10.21",
"phpstan/phpstan": "^1.10.50",
"phpstan/phpstan-nette": "^1.2.6",
"latte/latte": "^2.11.6 | ^3.0.4",
"nette/utils": "^3.2|^4.0",
Expand All @@ -18,7 +18,7 @@
"nette/application": "^3.1.6",
"nette/forms": "^3.1.12",
"nikic/php-parser": "^4.15",
"efabrica/coding-standard": "^0.5",
"efabrica/coding-standard": "^0.6",
"phpstan/phpstan-strict-rules": "^1.4",
"spaze/phpstan-disallowed-calls": "^2.11"
},
Expand Down
4 changes: 3 additions & 1 deletion src/Analyser/LatteContextAnalyser.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Efabrica\PHPStanLatte\Analyser;

use Efabrica\PHPStanLatte\LatteContext\CollectedData\CollectedRelatedFiles;
Expand All @@ -16,7 +18,7 @@
use PHPStan\Rules\RuleErrorBuilder;
use Throwable;

class LatteContextAnalyser
final class LatteContextAnalyser
{
private ScopeFactory $scopeFactory;

Expand Down
2 changes: 2 additions & 0 deletions src/Analyser/LatteContextCollectorRegistry.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Efabrica\PHPStanLatte\Analyser;

use Efabrica\PHPStanLatte\LatteContext\Collector\AbstractLatteContextCollector;
Expand Down
2 changes: 1 addition & 1 deletion src/Analyser/LatteContextData.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use PHPStan\Rules\RuleError;
use PHPStan\Rules\RuleErrorBuilder;

class LatteContextData
final class LatteContextData
{
/** @var array<RuleError> */
private array $errors;
Expand Down
2 changes: 2 additions & 0 deletions src/Collector/CollectedData/CollectedValueObject.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Efabrica\PHPStanLatte\Collector\CollectedData;

abstract class CollectedValueObject
Expand Down
2 changes: 2 additions & 0 deletions src/Collector/Collector/AbstractCollector.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Efabrica\PHPStanLatte\Collector\Collector;

use Efabrica\PHPStanLatte\Collector\CollectedData\CollectedValueObject;
Expand Down
3 changes: 3 additions & 0 deletions src/Compiler/NodeVisitor/AddFormClassesNodeVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,9 @@ public function enterNode(Node $node): ?Node
return null;
}

/**
* @return Node|Node[]|null
*/
public function leaveNode(Node $node)
{
foreach ($this->errorControlNodes as $errorControlNode) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Efabrica\PHPStanLatte\LatteContext\CollectedData;

abstract class CollectedLatteContextObject
Expand Down
2 changes: 2 additions & 0 deletions src/LatteContext/Collector/AbstractLatteContextCollector.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Efabrica\PHPStanLatte\LatteContext\Collector;

use Efabrica\PHPStanLatte\LatteContext\CollectedData\CollectedError;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Efabrica\PHPStanLatte\LatteContext\Collector;

use PhpParser\Node;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Efabrica\PHPStanLatte\LatteContext\Collector;

use Efabrica\PHPStanLatte\LatteContext\CollectedData\CollectedError;
Expand Down
5 changes: 4 additions & 1 deletion src/LatteContext/Collector/RelatedFilesCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ public function getNodeTypes(): array
];
}

public function collectData(Node $node, Scope $scope): ?array
/**
* @return CollectedRelatedFiles[]
*/
public function collectData(Node $node, Scope $scope): array
{
$relatedFiles = [];
if ($node instanceof InClassNode) {
Expand Down
2 changes: 2 additions & 0 deletions src/LatteContext/Resolver/ClassLatteContextResolver.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Efabrica\PHPStanLatte\LatteContext\Resolver;

use Efabrica\PHPStanLatte\LatteContext\LatteContext;
Expand Down
2 changes: 2 additions & 0 deletions src/LatteContext/Resolver/LatteContextResolverInterface.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Efabrica\PHPStanLatte\LatteContext\Resolver;

use Efabrica\PHPStanLatte\Template\Component;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Efabrica\PHPStanLatte\LatteContext\Resolver\Nette;

use Efabrica\PHPStanLatte\LatteContext\Resolver\ClassLatteContextResolver;
Expand All @@ -8,7 +10,7 @@
use PHPStan\Type\MixedType;
use PHPStan\Type\ObjectType;

class NetteApplicationUIControlLatteContextResolver extends ClassLatteContextResolver
final class NetteApplicationUIControlLatteContextResolver extends ClassLatteContextResolver
{
public function getVariables(): array
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Efabrica\PHPStanLatte\LatteContext\Resolver\Nette;

use Efabrica\PHPStanLatte\LatteContext\Resolver\ClassLatteContextResolver;
Expand All @@ -9,7 +11,7 @@
use PHPStan\Type\MixedType;
use PHPStan\Type\ObjectType;

class NetteApplicationUIPresenterLatteContextResolver extends ClassLatteContextResolver
final class NetteApplicationUIPresenterLatteContextResolver extends ClassLatteContextResolver
{
public function getVariables(): array
{
Expand Down
2 changes: 1 addition & 1 deletion src/LinkProcessor/LinkProcessorException.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use RuntimeException;

class LinkProcessorException extends RuntimeException
final class LinkProcessorException extends RuntimeException
{

}
2 changes: 1 addition & 1 deletion src/Rule/LatteCompileErrorsRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/**
* @implements Rule<FuncCall>
*/
class LatteCompileErrorsRule implements Rule
final class LatteCompileErrorsRule implements Rule
{
public function getNodeType(): string
{
Expand Down
4 changes: 3 additions & 1 deletion src/Template/ItemCombinator.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<?php

declare(strict_types=1);

namespace Efabrica\PHPStanLatte\Template;

use Efabrica\PHPStanLatte\Type\TemplateTypeHelper;
use PHPStan\Type\TypeCombinator;

class ItemCombinator
final class ItemCombinator
{
/**
* @template T of NameItem
Expand Down
4 changes: 3 additions & 1 deletion src/Type/TemplateTypeHelper.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Efabrica\PHPStanLatte\Type;

use PHPStan\Type\ErrorType;
Expand All @@ -8,7 +10,7 @@
use PHPStan\Type\Type;
use PHPStan\Type\TypeTraverser;

class TemplateTypeHelper
final class TemplateTypeHelper
{
public static function resolveTemplateType(Type $type, string $declaringClass, ?string $currentClass): Type
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use RuntimeException;

class ExpectedErrorsScanner
final class ExpectedErrorsScanner
{
/**
* @return list<array{error: string, line: int, tip: ?string}>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<?php

declare(strict_types=1);

namespace Efabrica\PHPStanLatte\Tests\Rule\LatteTemplatesRule\EngineBootstrap;

use Latte\Engine;

class FirstClassCallableFilters
final class FirstClassCallableFilters
{
public function objectFilter(string $input): string
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<?php

declare(strict_types=1);

namespace Efabrica\PHPStanLatte\Tests\Rule\LatteTemplatesRule\EngineBootstrap;

use Latte\Engine;

class Filters
final class Filters
{
public function objectFilter(string $input): string
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public function testVariables(): void
'default.latte',
],
[
'Dumped type: array<string>',
"Dumped type: array<'bar'|'baz'|'foo'>", // False positive - TODO create DynamicMethodReturnTypeExtension for Latte\Runtime\Filters::slice - inspire in ArraySliceFunctionReturnTypeExtension and SubstrDynamicReturnTypeExtension
92,
'default.latte',
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Efabrica\PHPStanLatte\Tests\Rule\LatteTemplatesRule\SimpleControl\Fixtures\TraitVariables;

class MiddleControl extends BaseControl
final class MiddleControl extends BaseControl
{
use MiddleControlBehavior;
}

0 comments on commit 7ef44a6

Please sign in to comment.