Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Symfony 6.4 and attributes #5

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
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
23 changes: 12 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,23 @@
}
},
"require": {
"php": "8.0.*|8.1.*",
"jms/serializer-bundle": "~4.0",
"symfony/config": "~5.0",
"symfony/dependency-injection": "~5.0",
"symfony/http-kernel": "~5.0",
"symfony/routing": "~5.0",
"symfony/yaml": "~5.0",
"php": "^8.0",
"jms/serializer-bundle": "^5.4",
"symfony/config": "6.4.*",
"symfony/dependency-injection": "6.4.*",
"symfony/http-kernel": "6.4.*",
"symfony/routing": "6.4.*",
"symfony/yaml": "6.4.*",
"teqneers/ext-direct": "^5.0",
"twig/twig": "~3.3"
},
"require-dev": {
"koriym/attributes": "^1.0",
"phpunit/phpunit": "^9.5",
"symfony/framework-bundle": "~5.0",
"symfony/phpunit-bridge": "~5.0",
"symfony/security-bundle": "~5.0",
"symfony/templating": "~5.0"
"symfony/framework-bundle": "6.4.*",
"symfony/phpunit-bridge": "6.4.*",
"symfony/security-bundle": "6.4.*",
"symfony/templating": "6.4.*"
},
"extra": {
"branch-alias": {
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/RouterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function __construct(EndpointManager $endpointManager)
*/
public function routerAction($endpoint, Request $request)
{
$request->setRequestFormat($request->getContentType());
$request->setRequestFormat($request->getContentTypeFormat());

if ($request->getMethod() !== Request::METHOD_POST) {
throw new MethodNotAllowedHttpException(array(Request::METHOD_POST));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class AddExtDirectServicePass implements CompilerPassInterface
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container)
public function process(ContainerBuilder $container): void
{
$tagName = 'tq_extdirect.service';
$defaultEndpoint = $container->getParameter('tq_extdirect.endpoint.default');
Expand Down
2 changes: 1 addition & 1 deletion src/DependencyInjection/Compiler/ValidateSecurityPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class ValidateSecurityPass implements CompilerPassInterface
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container)
public function process(ContainerBuilder $container): void
{
if (!$container->hasDefinition('tq_extdirect.router.authorization_checker')) {
// authorization listener not enabled or expression language not available
Expand Down
2 changes: 1 addition & 1 deletion src/DependencyInjection/TQExtDirectExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class TQExtDirectExtension extends Extension
/**
* {@inheritdoc}
*/
public function load(array $config, ContainerBuilder $container)
public function load(array $config, ContainerBuilder $container): void
{
$loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('extdirect.yml');
Expand Down
2 changes: 1 addition & 1 deletion src/TQExtDirectBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class TQExtDirectBundle extends Bundle
/**
* {@inheritdoc}
*/
public function build(ContainerBuilder $container)
public function build(ContainerBuilder $container): void
{
parent::build($container);

Expand Down
8 changes: 4 additions & 4 deletions tests/Services/Service1.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@
*
* @Direct\Action()
*/
#[Direct\Action()]
class Service1
{
/**
* @Direct\Method()
* @Direct\Parameter("a", { @Assert\NotNull(), @Assert\Type("string") })
*
* @param string $a
* @return string
*/
public function methodA($a)
#[Direct\Method()]
#[Direct\Parameter("a", [ new Assert\NotNull(), new Assert\Type("string") ])]
public function methodA(string $a): string
{
return $a;
}
Expand Down
8 changes: 4 additions & 4 deletions tests/Services/Sub/Service1.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@
*
* @Direct\Action("app.direct.test1")
*/
#[Direct\Action("app.direct.test1")]
class Service1
{
/**
* @Direct\Method()
* @Direct\Parameter("a", { @Assert\NotNull(), @Assert\Type("string") })
*
* @param string $a
* @return string
*/
public function methodA($a)
#[Direct\Method()]
#[Direct\Parameter("a", [ new Assert\NotNull(), new Assert\Type("string") ])]
public function methodA(string $a): string
{
return $a;
}
Expand Down
17 changes: 4 additions & 13 deletions tests/TQExtDirectBundleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,7 @@ protected function clearTempDir()

class AppKernel extends Kernel
{
/**
* @return iterable<mixed, BundleInterface>
*/
public function registerBundles()
public function registerBundles(): \Traversable|array
{
return array(
new FrameworkBundle(),
Expand All @@ -188,23 +185,17 @@ public function registerBundles()
/**
* {@inheritdoc}
*/
public function registerContainerConfiguration(LoaderInterface $loader)
public function registerContainerConfiguration(LoaderInterface $loader): void
{
$loader->load(__DIR__ . '/TQExtDirectBundleTestConfig.yml');
}

/**
* @return string
*/
public function getCacheDir()
public function getCacheDir(): string
{
return sys_get_temp_dir() . '/ext-direct-bundle/cache';
}

/**
* @return string
*/
public function getLogDir()
public function getLogDir(): string
{
return sys_get_temp_dir() . '/ext-direct-bundle/log';
}
Expand Down
13 changes: 13 additions & 0 deletions tests/TQExtDirectBundleTestConfig.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,21 @@ framework:
secret: "Three can keep a secret, if two of them are dead."
validation:
enabled: true
email_validation_mode: html5
router:
resource: "%kernel.project_dir%/tests/TQExtDirectBundleTestRouting.yml"
strict_requirements: ~
utf8: true

http_method_override: false
handle_all_throwables: true

php_errors:
log: true

annotations:
enabled: false

tq_ext_direct:
endpoints:
api:
Expand All @@ -20,3 +30,6 @@ services:
class: TQ\Bundle\ExtDirectBundle\Tests\Services\Service1
tags:
- { name: tq_extdirect.service, endpoint: api }

Doctrine\Common\Annotations\AnnotationReader:
annotation_reader: '@Doctrine\Common\Annotations\AnnotationReader'
4 changes: 3 additions & 1 deletion tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@

$loader = require __DIR__ . '/../vendor/autoload.php';

AnnotationRegistry::registerLoader(array($loader, 'loadClass'));
if (method_exists(AnnotationRegistry::class, 'registerLoader')) {
AnnotationRegistry::registerLoader([$loader, 'loadClass']);
}