-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
…tedTransformation`
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of rekalogika/mapper package. | ||
* | ||
* (c) Priyadi Iman Nurcahyo <https://rekalogika.dev> | ||
* | ||
* For the full copyright and license information, please view the LICENSE file | ||
* that was distributed with this source code. | ||
*/ | ||
|
||
namespace Rekalogika\Mapper\Exception; | ||
|
||
class InvalidClassException extends InvalidArgumentException | ||
{ | ||
public function __construct( | ||
private string $class, | ||
int $code = 0, | ||
?\Throwable $previous = null | ||
) { | ||
$message = sprintf('Class "%s" does not exist.', $class); | ||
|
||
parent::__construct($message, $code, $previous); | ||
} | ||
|
||
public function getClass(): string | ||
{ | ||
return $this->class; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of rekalogika/mapper package. | ||
* | ||
* (c) Priyadi Iman Nurcahyo <https://rekalogika.dev> | ||
* | ||
* For the full copyright and license information, please view the LICENSE file | ||
* that was distributed with this source code. | ||
*/ | ||
|
||
namespace Rekalogika\Mapper\Tests\Fixtures\InvalidTransformer; | ||
|
||
use Rekalogika\Mapper\Context\Context; | ||
use Rekalogika\Mapper\Exception\InvalidArgumentException; | ||
use Rekalogika\Mapper\Transformer\TransformerInterface; | ||
use Rekalogika\Mapper\Transformer\TypeMapping; | ||
use Rekalogika\Mapper\Util\TypeFactory; | ||
use Symfony\Component\PropertyInfo\Type; | ||
|
||
class InvalidTransformer implements TransformerInterface | ||
{ | ||
public function getSupportedTransformation(): iterable | ||
{ | ||
/** | ||
* @psalm-suppress InvalidClass | ||
* @psalm-suppress UndefinedClass | ||
* @psalm-suppress MixedArgument | ||
*/ | ||
yield new TypeMapping( | ||
// @phpstan-ignore-next-line | ||
TypeFactory::objectOfClass(InvalidClass::class), | ||
// @phpstan-ignore-next-line | ||
TypeFactory::objectOfClass(AnotherInvalidClass::class) | ||
); | ||
} | ||
|
||
public function transform( | ||
mixed $source, | ||
mixed $target, | ||
?Type $sourceType, | ||
?Type $targetType, | ||
Context $context | ||
): mixed { | ||
throw new InvalidArgumentException('Should never reach here'); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of rekalogika/mapper package. | ||
* | ||
* (c) Priyadi Iman Nurcahyo <https://rekalogika.dev> | ||
* | ||
* For the full copyright and license information, please view the LICENSE file | ||
* that was distributed with this source code. | ||
*/ | ||
|
||
namespace Rekalogika\Mapper\Tests\Service; | ||
|
||
use Psr\Log\LoggerInterface; | ||
|
||
class TestLogger implements LoggerInterface | ||
{ | ||
public function __construct(private LoggerInterface $logger) | ||
{ | ||
} | ||
|
||
private function isSuppressed(string|\Stringable $message): bool | ||
{ | ||
return str_contains((string)$message, 'has a mapping involving an invalid class'); | ||
} | ||
|
||
public function emergency(string|\Stringable $message, array $context = []): void | ||
Check failure on line 29 in tests/Service/TestLogger.php GitHub Actions / Symfony 6.4.*, lowest deps, PHP 8.2, ubuntu-latestMethodSignatureMismatch
Check failure on line 29 in tests/Service/TestLogger.php GitHub Actions / Symfony 7.*, lowest deps, PHP 8.2, ubuntu-latestMethodSignatureMismatch
Check failure on line 29 in tests/Service/TestLogger.php GitHub Actions / Symfony 6.4.*, lowest deps, PHP 8.3, ubuntu-latestMethodSignatureMismatch
Check failure on line 29 in tests/Service/TestLogger.php GitHub Actions / Symfony 7.*, lowest deps, PHP 8.3, ubuntu-latestMethodSignatureMismatch
|
||
{ | ||
if (!$this->isSuppressed($message)) { | ||
$this->logger->emergency($message, $context); | ||
} | ||
} | ||
|
||
public function alert(string|\Stringable $message, array $context = []): void | ||
Check failure on line 36 in tests/Service/TestLogger.php GitHub Actions / Symfony 6.4.*, lowest deps, PHP 8.2, ubuntu-latestMethodSignatureMismatch
Check failure on line 36 in tests/Service/TestLogger.php GitHub Actions / Symfony 7.*, lowest deps, PHP 8.2, ubuntu-latestMethodSignatureMismatch
Check failure on line 36 in tests/Service/TestLogger.php GitHub Actions / Symfony 6.4.*, lowest deps, PHP 8.3, ubuntu-latestMethodSignatureMismatch
Check failure on line 36 in tests/Service/TestLogger.php GitHub Actions / Symfony 7.*, lowest deps, PHP 8.3, ubuntu-latestMethodSignatureMismatch
|
||
{ | ||
if (!$this->isSuppressed($message)) { | ||
$this->logger->alert($message, $context); | ||
} | ||
} | ||
|
||
public function critical(string|\Stringable $message, array $context = []): void | ||
Check failure on line 43 in tests/Service/TestLogger.php GitHub Actions / Symfony 6.4.*, lowest deps, PHP 8.2, ubuntu-latestMethodSignatureMismatch
Check failure on line 43 in tests/Service/TestLogger.php GitHub Actions / Symfony 7.*, lowest deps, PHP 8.2, ubuntu-latestMethodSignatureMismatch
Check failure on line 43 in tests/Service/TestLogger.php GitHub Actions / Symfony 6.4.*, lowest deps, PHP 8.3, ubuntu-latestMethodSignatureMismatch
Check failure on line 43 in tests/Service/TestLogger.php GitHub Actions / Symfony 7.*, lowest deps, PHP 8.3, ubuntu-latestMethodSignatureMismatch
|
||
{ | ||
if (!$this->isSuppressed($message)) { | ||
$this->logger->critical($message, $context); | ||
} | ||
} | ||
|
||
public function error(string|\Stringable $message, array $context = []): void | ||
Check failure on line 50 in tests/Service/TestLogger.php GitHub Actions / Symfony 6.4.*, lowest deps, PHP 8.2, ubuntu-latestMethodSignatureMismatch
Check failure on line 50 in tests/Service/TestLogger.php GitHub Actions / Symfony 7.*, lowest deps, PHP 8.2, ubuntu-latestMethodSignatureMismatch
Check failure on line 50 in tests/Service/TestLogger.php GitHub Actions / Symfony 6.4.*, lowest deps, PHP 8.3, ubuntu-latestMethodSignatureMismatch
Check failure on line 50 in tests/Service/TestLogger.php GitHub Actions / Symfony 7.*, lowest deps, PHP 8.3, ubuntu-latestMethodSignatureMismatch
|
||
{ | ||
if (!$this->isSuppressed($message)) { | ||
$this->logger->error($message, $context); | ||
} | ||
} | ||
|
||
public function warning(string|\Stringable $message, array $context = []): void | ||
Check failure on line 57 in tests/Service/TestLogger.php GitHub Actions / Symfony 6.4.*, lowest deps, PHP 8.2, ubuntu-latestMethodSignatureMismatch
Check failure on line 57 in tests/Service/TestLogger.php GitHub Actions / Symfony 7.*, lowest deps, PHP 8.2, ubuntu-latestMethodSignatureMismatch
Check failure on line 57 in tests/Service/TestLogger.php GitHub Actions / Symfony 6.4.*, lowest deps, PHP 8.3, ubuntu-latestMethodSignatureMismatch
Check failure on line 57 in tests/Service/TestLogger.php GitHub Actions / Symfony 7.*, lowest deps, PHP 8.3, ubuntu-latestMethodSignatureMismatch
|
||
{ | ||
if (!$this->isSuppressed($message)) { | ||
$this->logger->warning($message, $context); | ||
} | ||
} | ||
|
||
public function notice(string|\Stringable $message, array $context = []): void | ||
Check failure on line 64 in tests/Service/TestLogger.php GitHub Actions / Symfony 6.4.*, lowest deps, PHP 8.2, ubuntu-latestMethodSignatureMismatch
Check failure on line 64 in tests/Service/TestLogger.php GitHub Actions / Symfony 7.*, lowest deps, PHP 8.2, ubuntu-latestMethodSignatureMismatch
Check failure on line 64 in tests/Service/TestLogger.php GitHub Actions / Symfony 6.4.*, lowest deps, PHP 8.3, ubuntu-latestMethodSignatureMismatch
Check failure on line 64 in tests/Service/TestLogger.php GitHub Actions / Symfony 7.*, lowest deps, PHP 8.3, ubuntu-latestMethodSignatureMismatch
|
||
{ | ||
if (!$this->isSuppressed($message)) { | ||
$this->logger->notice($message, $context); | ||
} | ||
} | ||
|
||
public function info(string|\Stringable $message, array $context = []): void | ||
Check failure on line 71 in tests/Service/TestLogger.php GitHub Actions / Symfony 6.4.*, lowest deps, PHP 8.2, ubuntu-latestMethodSignatureMismatch
Check failure on line 71 in tests/Service/TestLogger.php GitHub Actions / Symfony 7.*, lowest deps, PHP 8.2, ubuntu-latestMethodSignatureMismatch
Check failure on line 71 in tests/Service/TestLogger.php GitHub Actions / Symfony 6.4.*, lowest deps, PHP 8.3, ubuntu-latestMethodSignatureMismatch
Check failure on line 71 in tests/Service/TestLogger.php GitHub Actions / Symfony 7.*, lowest deps, PHP 8.3, ubuntu-latestMethodSignatureMismatch
|
||
{ | ||
if (!$this->isSuppressed($message)) { | ||
$this->logger->info($message, $context); | ||
} | ||
} | ||
|
||
public function debug(string|\Stringable $message, array $context = []): void | ||
Check failure on line 78 in tests/Service/TestLogger.php GitHub Actions / Symfony 6.4.*, lowest deps, PHP 8.2, ubuntu-latestMethodSignatureMismatch
Check failure on line 78 in tests/Service/TestLogger.php GitHub Actions / Symfony 7.*, lowest deps, PHP 8.2, ubuntu-latestMethodSignatureMismatch
Check failure on line 78 in tests/Service/TestLogger.php GitHub Actions / Symfony 6.4.*, lowest deps, PHP 8.3, ubuntu-latestMethodSignatureMismatch
Check failure on line 78 in tests/Service/TestLogger.php GitHub Actions / Symfony 7.*, lowest deps, PHP 8.3, ubuntu-latestMethodSignatureMismatch
|
||
{ | ||
if (!$this->isSuppressed($message)) { | ||
$this->logger->debug($message, $context); | ||
} | ||
} | ||
|
||
public function log($level, string|\Stringable $message, array $context = []): void | ||
Check failure on line 85 in tests/Service/TestLogger.php GitHub Actions / Symfony 6.4.*, lowest deps, PHP 8.2, ubuntu-latestMethodSignatureMismatch
Check failure on line 85 in tests/Service/TestLogger.php GitHub Actions / Symfony 7.*, lowest deps, PHP 8.2, ubuntu-latestMethodSignatureMismatch
Check failure on line 85 in tests/Service/TestLogger.php GitHub Actions / Symfony 6.4.*, lowest deps, PHP 8.3, ubuntu-latestMethodSignatureMismatch
Check failure on line 85 in tests/Service/TestLogger.php GitHub Actions / Symfony 7.*, lowest deps, PHP 8.3, ubuntu-latestMethodSignatureMismatch
|
||
{ | ||
if (!$this->isSuppressed($message)) { | ||
$this->logger->log($level, $message, $context); | ||
} | ||
} | ||
} |