-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This updates packages including the ones that have been locked to particular versions in #278, as a workaround has been added here. Duplicates mapping config from the main app to the PHPStan Latte extension, again, and adds a check that the config is the same in all files. I'd need to add `unformatPresenterClass()` somewhere somehow if it wasn't the duplicated config. And while that's a copy/pasta, with the test it's acceptable. Partially rolls back #84 - efabrica/phpstan-latte updated from 0.16.3 to 0.17.0 minor See changes: efabrica-team/[email protected] Release notes: https://github.com/efabrica-team/phpstan-latte/releases/tag/0.17.0 - nette/application updated from v3.1.14 to v3.2.1 minor See changes: nette/[email protected] Release notes: https://github.com/nette/application/releases/tag/v3.2.1 - nette/forms updated from v3.1.15 to v3.2.1 minor See changes: nette/[email protected] Release notes: https://github.com/nette/forms/releases/tag/v3.2.1 - nette/http updated from v3.2.4 to v3.3.0 minor See changes: nette/[email protected] Release notes: https://github.com/nette/http/releases/tag/v3.3.0 - php-parallel-lint/php-parallel-lint updated from v1.3.2 to v1.4.0 minor See changes: php-parallel-lint/[email protected] Release notes: https://github.com/php-parallel-lint/PHP-Parallel-Lint/releases/tag/v1.4.0 - phpstan/phpstan updated from 1.10.64 to 1.10.66 patch See changes: phpstan/[email protected] Release notes: https://github.com/phpstan/phpstan/releases/tag/1.10.66 - roave/security-advisories updated from dev-latest@1054e91 to dev-latest@6900b81 See changes: Roave/SecurityAdvisories@1054e91...6900b81
- Loading branch information
Showing
191 changed files
with
3,703 additions
and
2,683 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
site/app/Application/MappingCheck/ApplicationMappingCheck.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
|
||
namespace MichalSpacekCz\Application\MappingCheck; | ||
|
||
use MichalSpacekCz\Application\MappingCheck\Exceptions\ApplicationMappingMismatchException; | ||
use MichalSpacekCz\Application\MappingCheck\Exceptions\ApplicationMappingMultiplePrimaryFilesException; | ||
use MichalSpacekCz\Application\MappingCheck\Exceptions\ApplicationMappingNoOtherFilesException; | ||
use MichalSpacekCz\Application\MappingCheck\Exceptions\ApplicationMappingNoPrimaryFileException; | ||
use MichalSpacekCz\Application\MappingCheck\Files\ApplicationMappingCheckFile; | ||
|
||
readonly class ApplicationMappingCheck | ||
{ | ||
|
||
/** | ||
* @param list<ApplicationMappingCheckFile> $files | ||
*/ | ||
public function __construct( | ||
private array $files, | ||
) { | ||
} | ||
|
||
|
||
/** | ||
* @return list<string> | ||
* @throws ApplicationMappingMultiplePrimaryFilesException | ||
* @throws ApplicationMappingNoPrimaryFileException | ||
* @throws ApplicationMappingMismatchException | ||
* @throws ApplicationMappingNoOtherFilesException | ||
*/ | ||
public function checkFiles(): array | ||
{ | ||
$primaryFile = null; | ||
$otherFilenames = $otherFiles = []; | ||
foreach ($this->files as $file) { | ||
if ($file->isPrimaryFile()) { | ||
if ($primaryFile !== null) { | ||
throw new ApplicationMappingMultiplePrimaryFilesException($primaryFile, $file); | ||
} | ||
$primaryFile = $file; | ||
} else { | ||
$otherFilenames[] = $file->getFilename(); | ||
$otherFiles[] = $file; | ||
} | ||
} | ||
if ($primaryFile === null) { | ||
throw new ApplicationMappingNoPrimaryFileException($otherFilenames); | ||
} | ||
if ($otherFiles === []) { | ||
throw new ApplicationMappingNoOtherFilesException($primaryFile); | ||
} | ||
foreach ($otherFiles as $file) { | ||
if ($primaryFile->getMapping() !== $file->getMapping()) { | ||
throw new ApplicationMappingMismatchException($primaryFile, $file); | ||
} | ||
} | ||
return array_merge([$primaryFile->getFilename()], $otherFilenames); | ||
} | ||
|
||
} |
10 changes: 10 additions & 0 deletions
10
site/app/Application/MappingCheck/Exceptions/ApplicationMappingException.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
|
||
namespace MichalSpacekCz\Application\MappingCheck\Exceptions; | ||
|
||
use Exception; | ||
|
||
abstract class ApplicationMappingException extends Exception | ||
{ | ||
} |
16 changes: 16 additions & 0 deletions
16
site/app/Application/MappingCheck/Exceptions/ApplicationMappingFileNotFoundException.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
|
||
namespace MichalSpacekCz\Application\MappingCheck\Exceptions; | ||
|
||
use Throwable; | ||
|
||
class ApplicationMappingFileNotFoundException extends ApplicationMappingException | ||
{ | ||
|
||
public function __construct(string $file, ?Throwable $previous = null) | ||
{ | ||
parent::__construct("Application mapping file not found: '{$file}'", previous: $previous); | ||
} | ||
|
||
} |
16 changes: 16 additions & 0 deletions
16
site/app/Application/MappingCheck/Exceptions/ApplicationMappingInvalidConfigException.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
|
||
namespace MichalSpacekCz\Application\MappingCheck\Exceptions; | ||
|
||
use Throwable; | ||
|
||
class ApplicationMappingInvalidConfigException extends ApplicationMappingException | ||
{ | ||
|
||
public function __construct(string $file, string $message, ?Throwable $previous = null) | ||
{ | ||
parent::__construct("Application mapping config invalid in '{$file}': {$message}", previous: $previous); | ||
} | ||
|
||
} |
34 changes: 34 additions & 0 deletions
34
site/app/Application/MappingCheck/Exceptions/ApplicationMappingMismatchException.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
|
||
namespace MichalSpacekCz\Application\MappingCheck\Exceptions; | ||
|
||
use MichalSpacekCz\Application\MappingCheck\Files\ApplicationMappingCheckFile; | ||
use Throwable; | ||
|
||
class ApplicationMappingMismatchException extends ApplicationMappingException | ||
{ | ||
|
||
public function __construct(ApplicationMappingCheckFile $primary, ApplicationMappingCheckFile $file, ?Throwable $previous = null) | ||
{ | ||
$message = sprintf( | ||
"Application mapping in '%s' ('%s') doesn't match the primary mapping in '%s' ('%s')", | ||
$file->getFilename(), | ||
$this->describeMapping($file), | ||
$primary->getFilename(), | ||
$this->describeMapping($primary), | ||
); | ||
parent::__construct($message, previous: $previous); | ||
} | ||
|
||
|
||
private function describeMapping(ApplicationMappingCheckFile $file): string | ||
{ | ||
$result = []; | ||
foreach ($file->getMapping() as $key => $value) { | ||
$result[] = "{$key}: {$value}"; | ||
} | ||
return implode('; ', $result); | ||
} | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
...p/Application/MappingCheck/Exceptions/ApplicationMappingMultiplePrimaryFilesException.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
|
||
namespace MichalSpacekCz\Application\MappingCheck\Exceptions; | ||
|
||
use MichalSpacekCz\Application\MappingCheck\Files\ApplicationMappingCheckFile; | ||
use Throwable; | ||
|
||
class ApplicationMappingMultiplePrimaryFilesException extends ApplicationMappingException | ||
{ | ||
|
||
public function __construct(ApplicationMappingCheckFile $primary, ApplicationMappingCheckFile $other, ?Throwable $previous = null) | ||
{ | ||
parent::__construct("Application mapping has multiple primary files: '{$primary->getFilename()}' & '{$other->getFilename()}'", previous: $previous); | ||
} | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
site/app/Application/MappingCheck/Exceptions/ApplicationMappingNoOtherFilesException.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
|
||
namespace MichalSpacekCz\Application\MappingCheck\Exceptions; | ||
|
||
use MichalSpacekCz\Application\MappingCheck\Files\ApplicationMappingCheckFile; | ||
use Throwable; | ||
|
||
class ApplicationMappingNoOtherFilesException extends ApplicationMappingException | ||
{ | ||
|
||
public function __construct(ApplicationMappingCheckFile $file, ?Throwable $previous = null) | ||
{ | ||
parent::__construct("No other files with application mapping, just the primary one: '{$file->getFilename()}'", previous: $previous); | ||
} | ||
|
||
} |
19 changes: 19 additions & 0 deletions
19
site/app/Application/MappingCheck/Exceptions/ApplicationMappingNoPrimaryFileException.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
|
||
namespace MichalSpacekCz\Application\MappingCheck\Exceptions; | ||
|
||
use Throwable; | ||
|
||
class ApplicationMappingNoPrimaryFileException extends ApplicationMappingException | ||
{ | ||
|
||
/** | ||
* @param list<string> $files | ||
*/ | ||
public function __construct(array $files, ?Throwable $previous = null) | ||
{ | ||
parent::__construct("Application mapping has no primary file: '" . implode("', '", $files) . "'", previous: $previous); | ||
} | ||
|
||
} |
80 changes: 80 additions & 0 deletions
80
site/app/Application/MappingCheck/Files/ApplicationMappingCheckCommonNeon.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
|
||
namespace MichalSpacekCz\Application\MappingCheck\Files; | ||
|
||
use MichalSpacekCz\Application\MappingCheck\Exceptions\ApplicationMappingFileNotFoundException; | ||
use MichalSpacekCz\Application\MappingCheck\Exceptions\ApplicationMappingInvalidConfigException; | ||
use MichalSpacekCz\ShouldNotHappenException; | ||
use Nette\Neon\Exception; | ||
use Nette\Neon\Neon; | ||
use Override; | ||
|
||
readonly class ApplicationMappingCheckCommonNeon implements ApplicationMappingCheckFile | ||
{ | ||
|
||
private string $filename; | ||
|
||
|
||
/** | ||
* @throws ApplicationMappingFileNotFoundException | ||
*/ | ||
public function __construct(string $filename) | ||
{ | ||
if (!file_exists($filename)) { | ||
throw new ApplicationMappingFileNotFoundException($filename); | ||
} | ||
$realpath = realpath($filename); | ||
$this->filename = $realpath !== false ? $realpath : $filename; | ||
} | ||
|
||
|
||
#[Override] | ||
public function getFilename(): string | ||
{ | ||
return $this->filename; | ||
} | ||
|
||
|
||
#[Override] | ||
public function isPrimaryFile(): bool | ||
{ | ||
return true; | ||
} | ||
|
||
|
||
/** | ||
* @return array<string, string> | ||
* @throws ApplicationMappingInvalidConfigException | ||
* @throws Exception | ||
*/ | ||
#[Override] | ||
public function getMapping(): array | ||
{ | ||
$decoded = Neon::decodeFile($this->filename); | ||
if (!is_array($decoded)) { | ||
throw new ApplicationMappingInvalidConfigException($this->filename, "Should be an array, but it's " . get_debug_type($decoded)); | ||
} | ||
if (!isset($decoded['application'])) { | ||
throw new ApplicationMappingInvalidConfigException($this->filename, "Missing 'application' key"); | ||
} | ||
if (!is_array($decoded['application'])) { | ||
throw new ApplicationMappingInvalidConfigException($this->filename, "The 'application' key should be an array, but it's " . get_debug_type($decoded['application'])); | ||
} | ||
if (!isset($decoded['application']['mapping'])) { | ||
throw new ApplicationMappingInvalidConfigException($this->filename, "Missing 'application.mapping' key"); | ||
} | ||
if (!is_array($decoded['application']['mapping'])) { | ||
throw new ApplicationMappingInvalidConfigException($this->filename, "The 'application.mapping' should be an array, but it's " . get_debug_type($decoded['application']['mapping'])); | ||
} | ||
$mapping = []; | ||
foreach ($decoded['application']['mapping'] as $key => $value) { | ||
if (!is_string($key) || !is_string($value)) { | ||
throw new ShouldNotHappenException(sprintf('Both key and value should be an array, but they are %s => %s', get_debug_type($key), get_debug_type($value))); | ||
} | ||
$mapping[$key] = $value; | ||
} | ||
return $mapping; | ||
} | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
site/app/Application/MappingCheck/Files/ApplicationMappingCheckFile.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
|
||
namespace MichalSpacekCz\Application\MappingCheck\Files; | ||
|
||
interface ApplicationMappingCheckFile | ||
{ | ||
|
||
public function getFilename(): string; | ||
|
||
|
||
public function isPrimaryFile(): bool; | ||
|
||
|
||
/** | ||
* @return array<string, string> | ||
*/ | ||
public function getMapping(): array; | ||
|
||
} |
Oops, something went wrong.