Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Codestyle: don't require multiline signature * DI: support overloading loaders and localResolvers as services * Loader: typo * Tests: better test structure * Tests: skip database tests * Tests: cover loaders as service * Tests: fix neon loader * Composer: upgrade dev dependencies to run on PHP 8.1 * Phpstan: errors on lowest * CI: phpstan php 8.1
- Loading branch information
Showing
17 changed files
with
330 additions
and
30 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace Contributte\Translation\DI; | ||
|
||
use Contributte\Translation\Exceptions\InvalidState; | ||
use Nette\DI\Definitions\Definition; | ||
use Nette\DI\Definitions\Reference; | ||
use Nette\DI\Definitions\Statement; | ||
|
||
class Helpers | ||
{ | ||
|
||
/** | ||
* @param Statement|class-string $input | ||
* @return class-string | ||
*/ | ||
public static function unwrapEntity(Statement|string $input): string | ||
{ | ||
if ($input instanceof Statement) { | ||
/** @var class-string|Reference|Definition|mixed[] $entity */ | ||
$entity = $input->getEntity(); | ||
if (is_string($entity)) { | ||
return $entity; | ||
} | ||
|
||
throw new InvalidState('Only string statements allowed'); | ||
} | ||
|
||
return $input; | ||
} | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Folders - recursive | ||
*.expected | ||
*.actual | ||
|
||
# Folders | ||
/tmp | ||
|
||
# Files | ||
/*.log | ||
/*.html |
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 Tests\Fixtures; | ||
|
||
use Symfony\Component\Translation\Loader\ArrayLoader; | ||
use Symfony\Component\Translation\Loader\LoaderInterface; | ||
use Symfony\Component\Translation\MessageCatalogue; | ||
|
||
class DummyLoader extends ArrayLoader implements LoaderInterface | ||
{ | ||
|
||
public function load(mixed $resource, string $locale, string $domain = 'messages'): MessageCatalogue | ||
{ | ||
return parent::load([], $locale, $domain); | ||
} | ||
|
||
} |
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,8 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace Tests\Fixtures; | ||
|
||
class DummyService | ||
{ | ||
|
||
} |
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,12 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace Tests\Fixtures; | ||
|
||
class DummyServiceLoader extends DummyLoader | ||
{ | ||
|
||
public function __construct(public DummyService $service) | ||
{ | ||
} | ||
|
||
} |
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
Oops, something went wrong.