Skip to content

Commit 65a453b

Browse files
committed
mongo removed xml php config
1 parent 55f53db commit 65a453b

File tree

16 files changed

+163
-134
lines changed

16 files changed

+163
-134
lines changed

.php-cs-fixer.dist.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
'docs/var',
2323
'src/Doctrine/Orm/Tests/var',
2424
'src/Doctrine/Odm/Tests/var',
25-
'tests/Fixtures/app/config/reference.php'
2625
])
26+
->notPath('tests/Fixtures/app/config/reference.php')
2727
->notPath('src/Symfony/Bundle/DependencyInjection/Configuration.php')
2828
->append([
2929
'tests/Fixtures/app/console',

src/Hydra/Tests/Serializer/ConstraintViolationNormalizerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public static function nameConverterAndPayloadFieldsProvider(): iterable
9090

9191
$advancedNameConverterFactory = function (self $that) {
9292
$advancedNameConverterProphecy = $that->prophesize(NameConverterInterface::class);
93-
$advancedNameConverterProphecy->normalize(Argument::type('string'), null, Argument::type('string'))->will(fn ($args): string => '_'.$args[0]);
93+
$advancedNameConverterProphecy->normalize(Argument::cetera())->will(fn ($args): string => '_'.$args[0]);
9494

9595
return $advancedNameConverterProphecy->reveal();
9696
};

src/Laravel/Eloquent/Serializer/EloquentNameConverter.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ public function __construct(private readonly NameConverterInterface $nameConvert
2828
public function normalize(string $propertyName, ?string $class = null, ?string $format = null, array $context = []): string
2929
{
3030
try {
31-
return $this->nameConverter->normalize($propertyName, $class, $format, $context); // @phpstan-ignore-line
31+
return $this->nameConverter->normalize($propertyName, $class, $format, $context);
3232
} catch (UnexpectedPropertyException $e) {
33-
return $this->nameConverter->denormalize($propertyName, $class, $format, $context); // @phpstan-ignore-line
33+
return $this->nameConverter->denormalize($propertyName, $class, $format, $context);
3434
}
3535
}
3636

@@ -40,9 +40,9 @@ public function normalize(string $propertyName, ?string $class = null, ?string $
4040
public function denormalize(string $propertyName, ?string $class = null, ?string $format = null, array $context = []): string
4141
{
4242
try {
43-
return $this->nameConverter->denormalize($propertyName, $class, $format, $context); // @phpstan-ignore-line
43+
return $this->nameConverter->denormalize($propertyName, $class, $format, $context);
4444
} catch (UnexpectedPropertyException $e) {
45-
return $this->nameConverter->normalize($propertyName, $class, $format, $context); // @phpstan-ignore-line
45+
return $this->nameConverter->normalize($propertyName, $class, $format, $context);
4646
}
4747
}
4848
}

src/Laravel/Eloquent/Serializer/Mapping/Loader/RelationMetadataLoader.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ public function loadClassMetadata(ClassMetadataInterface $classMetadata): bool
6666
$attribute = $a->newInstance();
6767

6868
match (true) {
69-
$attribute instanceof Groups => array_map([$attributeMetadata, 'addGroup'], $attribute->getGroups()),
70-
$attribute instanceof MaxDepth => $attributeMetadata->setMaxDepth($attribute->getMaxDepth()),
71-
$attribute instanceof SerializedName => $attributeMetadata->setSerializedName($attribute->getSerializedName()),
72-
$attribute instanceof SerializedPath => $attributeMetadata->setSerializedPath($attribute->getSerializedPath()),
69+
$attribute instanceof Groups => array_map([$attributeMetadata, 'addGroup'], $attribute->groups),
70+
$attribute instanceof MaxDepth => $attributeMetadata->setMaxDepth($attribute->maxDepth),
71+
$attribute instanceof SerializedName => $attributeMetadata->setSerializedName($attribute->serializedName),
72+
$attribute instanceof SerializedPath => $attributeMetadata->setSerializedPath($attribute->serializedPath),
7373
$attribute instanceof Ignore => $attributeMetadata->setIgnore(true),
7474
$attribute instanceof Context => $this->setAttributeContextsForGroups($attribute, $attributeMetadata),
7575
default => null,
@@ -82,10 +82,11 @@ public function loadClassMetadata(ClassMetadataInterface $classMetadata): bool
8282

8383
private function setAttributeContextsForGroups(Context $annotation, AttributeMetadataInterface $attributeMetadata): void
8484
{
85-
$context = $annotation->getContext();
86-
$groups = $annotation->getGroups();
87-
$normalizationContext = $annotation->getNormalizationContext();
88-
$denormalizationContext = $annotation->getDenormalizationContext();
85+
$context = $annotation->context;
86+
$groups = $annotation->groups;
87+
$normalizationContext = $annotation->normalizationContext;
88+
$denormalizationContext = $annotation->denormalizationContext;
89+
8990
if ($normalizationContext || $context) {
9091
$attributeMetadata->setNormalizationContextForGroups($normalizationContext ?: $context, $groups);
9192
}

src/Metadata/ApiProperty.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ public function __construct(
236236
if ($this->builtinTypes) {
237237
trigger_deprecation('api_platform/metadata', '4.2', \sprintf('The "builtinTypes" argument of "%s" is deprecated, use "nativeType" instead.', __CLASS__));
238238
$this->nativeType ??= PropertyInfoToTypeInfoHelper::convertLegacyTypesToType($this->builtinTypes);
239-
} elseif ($this->nativeType) {
239+
} elseif ($this->nativeType && class_exists(LegacyType::class)) {
240240
$this->builtinTypes = PropertyInfoToTypeInfoHelper::convertTypeToLegacyTypes($this->nativeType) ?? [];
241241
}
242242
}

src/Metadata/Tests/Util/PropertyInfoToTypeInfoHelperTest.php

Lines changed: 59 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -30,86 +30,75 @@
3030

3131
class PropertyInfoToTypeInfoHelperTest extends TestCase
3232
{
33-
/**
34-
* @param list<LegacyType>|null $legacyTypes
35-
*/
36-
#[\PHPUnit\Framework\Attributes\DataProvider('convertLegacyTypesToTypeDataProvider')]
37-
public function testConvertLegacyTypesToType(?Type $type, ?array $legacyTypes): void
33+
public function testConvertLegacyTypesToType(): void
3834
{
39-
$this->assertEquals($type, PropertyInfoToTypeInfoHelper::convertLegacyTypesToType($legacyTypes));
40-
}
41-
42-
/**
43-
* @return iterable<array{0: ?Type, 1: list<LegacyType>|null}>
44-
*/
45-
public static function convertLegacyTypesToTypeDataProvider(): iterable
46-
{
47-
yield [null, null];
48-
yield [Type::null(), [new LegacyType('null')]];
49-
// yield [Type::void(), [new LegacyType('void')]];
50-
yield [Type::int(), [new LegacyType('int')]];
51-
yield [Type::object(\stdClass::class), [new LegacyType('object', false, \stdClass::class)]];
52-
yield [
53-
Type::generic(Type::object(\stdClass::class), Type::string(), Type::int()),
54-
[new LegacyType('object', false, 'stdClass', false, [new LegacyType('string')], new LegacyType('int'))],
55-
];
56-
yield [Type::nullable(Type::int()), [new LegacyType('int', true)]];
57-
yield [Type::union(Type::int(), Type::string()), [new LegacyType('int'), new LegacyType('string')]];
58-
yield [
59-
Type::union(Type::int(), Type::string(), Type::null()),
60-
[new LegacyType('int', true), new LegacyType('string', true)],
61-
];
35+
if (!class_exists(LegacyType::class)) {
36+
$this->markTestSkipped();
37+
}
6238

6339
$type = Type::collection(Type::builtin(TypeIdentifier::ARRAY), Type::int(), Type::string()); // @phpstan-ignore-line
64-
yield [$type, [new LegacyType('array', false, null, true, [new LegacyType('string')], new LegacyType('int'))]];
65-
}
66-
67-
/**
68-
* @param list<LegacyType>|null $legacyTypes
69-
*/
70-
#[\PHPUnit\Framework\Attributes\DataProvider('convertTypeToLegacyTypesDataProvider')]
71-
public function testConvertTypeToLegacyTypes(?array $legacyTypes, ?Type $type): void
72-
{
73-
$this->assertEquals($legacyTypes, PropertyInfoToTypeInfoHelper::convertTypeToLegacyTypes($type));
74-
}
7540

76-
/**
77-
* @return iterable<array{0: list<LegacyType>|null, 1: ?Type, 2?: bool}>
78-
*/
79-
public static function convertTypeToLegacyTypesDataProvider(): iterable
80-
{
81-
yield [null, null];
82-
yield [null, Type::mixed()];
83-
yield [null, Type::never()];
84-
yield [[new LegacyType('null')], Type::null()];
85-
yield [[new LegacyType('null')], Type::void()];
86-
yield [[new LegacyType('int')], Type::int()];
87-
yield [[new LegacyType('object', false, \stdClass::class)], Type::object(\stdClass::class)];
88-
yield [
89-
[new LegacyType('object', false, \Traversable::class, true, null, new LegacyType('int'))],
90-
Type::generic(Type::object(\Traversable::class), Type::int()),
91-
];
92-
yield [
93-
[new LegacyType('array', false, null, true, new LegacyType('int'), new LegacyType('string'))],
94-
Type::generic(Type::builtin(TypeIdentifier::ARRAY), Type::int(), Type::string()), // @phpstan-ignore-line
41+
$tests = [
42+
[null, null],
43+
[Type::null(), [new LegacyType('null')]],
44+
// [Type::void(), [new LegacyType('void')]],
45+
[Type::int(), [new LegacyType('int')]],
46+
[Type::object(\stdClass::class), [new LegacyType('object', false, \stdClass::class)]],
47+
[
48+
Type::generic(Type::object(\stdClass::class), Type::string(), Type::int()),
49+
[new LegacyType('object', false, 'stdClass', false, [new LegacyType('string')], new LegacyType('int'))],
50+
],
51+
[Type::nullable(Type::int()), [new LegacyType('int', true)]],
52+
[Type::union(Type::int(), Type::string()), [new LegacyType('int'), new LegacyType('string')]],
53+
[
54+
Type::union(Type::int(), Type::string(), Type::null()),
55+
[new LegacyType('int', true), new LegacyType('string', true)],
56+
],
57+
[$type, [new LegacyType('array', false, null, true, [new LegacyType('string')], new LegacyType('int'))]],
9558
];
96-
yield [
97-
[new LegacyType('array', false, null, true, new LegacyType('int'), new LegacyType('string'))],
98-
Type::collection(Type::builtin(TypeIdentifier::ARRAY), Type::string(), Type::int()), // @phpstan-ignore-line
99-
];
100-
yield [[new LegacyType('int', true)], Type::nullable(Type::int())];
101-
yield [[new LegacyType('int'), new LegacyType('string')], Type::union(Type::int(), Type::string())];
102-
yield [
103-
[new LegacyType('int', true), new LegacyType('string', true)],
104-
Type::union(Type::int(), Type::string(), Type::null()),
105-
];
106-
yield [[new LegacyType('object', false, \Stringable::class), new LegacyType('object', false, \Traversable::class)], Type::intersection(Type::object(\Traversable::class), Type::object(\Stringable::class))];
59+
60+
foreach ($tests as [$expected, $legacyTypes]) {
61+
$this->assertEquals($expected, PropertyInfoToTypeInfoHelper::convertLegacyTypesToType($legacyTypes));
62+
}
10763
}
10864

109-
protected function setUp(): void
65+
public function testConvertTypeToLegacyTypes(): void
11066
{
11167
if (!class_exists(LegacyType::class)) {
11268
$this->markTestSkipped();
11369
}
70+
71+
$tests = [
72+
[null, null],
73+
[null, Type::mixed()],
74+
[null, Type::never()],
75+
[[new LegacyType('null')], Type::null()],
76+
[[new LegacyType('null')], Type::void()],
77+
[[new LegacyType('int')], Type::int()],
78+
[[new LegacyType('object', false, \stdClass::class)], Type::object(\stdClass::class)],
79+
[
80+
[new LegacyType('object', false, \Traversable::class, true, null, new LegacyType('int'))],
81+
Type::generic(Type::object(\Traversable::class), Type::int()),
82+
],
83+
[
84+
[new LegacyType('array', false, null, true, new LegacyType('int'), new LegacyType('string'))],
85+
Type::generic(Type::builtin(TypeIdentifier::ARRAY), Type::int(), Type::string()), // @phpstan-ignore-line
86+
],
87+
[
88+
[new LegacyType('array', false, null, true, new LegacyType('int'), new LegacyType('string'))],
89+
Type::collection(Type::builtin(TypeIdentifier::ARRAY), Type::string(), Type::int()), // @phpstan-ignore-line
90+
],
91+
[[new LegacyType('int', true)], Type::nullable(Type::int())],
92+
[[new LegacyType('int'), new LegacyType('string')], Type::union(Type::int(), Type::string())],
93+
[
94+
[new LegacyType('int', true), new LegacyType('string', true)],
95+
Type::union(Type::int(), Type::string(), Type::null()),
96+
],
97+
[[new LegacyType('object', false, \Stringable::class), new LegacyType('object', false, \Traversable::class)], Type::intersection(Type::object(\Traversable::class), Type::object(\Stringable::class))],
98+
];
99+
100+
foreach ($tests as [$expected, $type]) {
101+
$this->assertEquals($expected, PropertyInfoToTypeInfoHelper::convertTypeToLegacyTypes($type));
102+
}
114103
}
115104
}

tests/Fixtures/app/config/reference.php

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,5 @@
11
<?php
22

3-
/*
4-
* This file is part of the API Platform project.
5-
*
6-
* (c) Kévin Dunglas <[email protected]>
7-
*
8-
* For the full copyright and license information, please view the LICENSE
9-
* file that was distributed with this source code.
10-
*/
11-
12-
declare(strict_types=1);
13-
143
// This file is auto-generated and is for apps only. Bundles SHOULD NOT rely on its content.
154

165
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
@@ -464,8 +453,8 @@
464453
* platform_service?: scalar|null, // Deprecated: The "platform_service" configuration key is deprecated since doctrine-bundle 2.9. DBAL 4 will not support setting a custom platform via connection params anymore.
465454
* auto_commit?: bool,
466455
* schema_filter?: scalar|null,
467-
* logging?: bool, // Default: true
468-
* profiling?: bool, // Default: true
456+
* logging?: bool, // Default: false
457+
* profiling?: bool, // Default: false
469458
* profiling_collect_backtrace?: bool, // Enables collecting backtraces when profiling is enabled // Default: false
470459
* profiling_collect_schema_errors?: bool, // Enables collecting schema errors when profiling is enabled // Default: true
471460
* disable_type_comments?: bool,
@@ -604,7 +593,7 @@
604593
* pool?: scalar|null,
605594
* },
606595
* region_lock_lifetime?: scalar|null, // Default: 60
607-
* log_enabled?: bool, // Default: true
596+
* log_enabled?: bool, // Default: false
608597
* region_lifetime?: scalar|null, // Default: 3600
609598
* enabled?: bool, // Default: true
610599
* factory?: scalar|null,
@@ -997,7 +986,7 @@
997986
* http_method_override?: bool, // Set true to enable support for the '_method' request parameter to determine the intended HTTP method on POST requests. // Default: false
998987
* allowed_http_method_override?: list<string>|null,
999988
* trust_x_sendfile_type_header?: scalar|null, // Set true to enable support for xsendfile in binary file responses. // Default: "%env(bool:default::SYMFONY_TRUST_X_SENDFILE_TYPE_HEADER)%"
1000-
* ide?: scalar|null, // Default: "%env(default::SYMFONY_IDE)%"
989+
* ide?: scalar|null, // Default: null
1001990
* test?: bool,
1002991
* default_locale?: scalar|null, // Default: "en"
1003992
* set_locale_from_accept_language?: bool, // Whether to use the Accept-Language HTTP header to set the Request locale (only when the "_locale" request attribute is not passed). // Default: false
@@ -1154,7 +1143,7 @@
11541143
* paths?: array<string, scalar|null>,
11551144
* excluded_patterns?: list<scalar|null>,
11561145
* exclude_dotfiles?: bool, // If true, any files starting with "." will be excluded from the asset mapper. // Default: true
1157-
* server?: bool, // If true, a "dev server" will return the assets from the public directory (true in "debug" mode only by default). // Default: true
1146+
* server?: bool, // If true, a "dev server" will return the assets from the public directory (true in "debug" mode only by default). // Default: false
11581147
* public_prefix?: scalar|null, // The public path where the assets will be written to (and served from when "server" is true). // Default: "/assets/"
11591148
* missing_import_mode?: "strict"|"warn"|"ignore", // Behavior if an asset cannot be found when imported from JavaScript or CSS files - e.g. "import './non-existent.js'". "strict" means an exception is thrown, "warn" means a warning is logged, "ignore" means the import is left as-is. // Default: "warn"
11601149
* extensions?: array<string, scalar|null>,
@@ -1274,7 +1263,7 @@
12741263
* },
12751264
* php_errors?: array{ // PHP errors handling configuration
12761265
* log?: mixed, // Use the application logger instead of the PHP logger for logging PHP errors. // Default: true
1277-
* throw?: bool, // Throw PHP errors as \ErrorException instances. // Default: true
1266+
* throw?: bool, // Throw PHP errors as \ErrorException instances. // Default: false
12781267
* },
12791268
* exceptions?: array<string, array{ // Default: []
12801269
* log_level?: scalar|null, // The level of log message. Null to let Symfony decide. // Default: null
@@ -1337,7 +1326,7 @@
13371326
* scheduler?: bool|array{ // Scheduler configuration
13381327
* enabled?: bool, // Default: false
13391328
* },
1340-
* disallow_search_engine_index?: bool, // Enabled by default when debug is enabled. // Default: true
1329+
* disallow_search_engine_index?: bool, // Enabled by default when debug is enabled. // Default: false
13411330
* http_client?: bool|array{ // HTTP Client configuration
13421331
* enabled?: bool, // Default: true
13431332
* max_host_connections?: int, // The maximum number of connections to a single host.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
_main:
2-
resource: routing_test.yml
2+
resource: routing_test.php
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the API Platform project.
5+
*
6+
* (c) Kévin Dunglas <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
declare(strict_types=1);
13+
14+
use Symfony\Bundle\WebProfilerBundle\WebProfilerBundle;
15+
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
16+
17+
return function (RoutingConfigurator $routes) {
18+
$routes->import('routing_common.yml');
19+
$routes->import('@TestBundle/Controller/MongoDbOdm', 'attribute');
20+
21+
if (class_exists(WebProfilerBundle::class)) {
22+
// 2. Resolve the actual directory of the bundle
23+
$reflection = new ReflectionClass(WebProfilerBundle::class);
24+
$bundleDir = dirname($reflection->getFileName());
25+
26+
// 3. Check if the PHP config exists on the filesystem
27+
$usePhp = file_exists($bundleDir.'/Resources/config/routing/wdt.php');
28+
$ext = $usePhp ? 'php' : 'xml';
29+
30+
// 4. Import dynamically based on the extension found
31+
$routes->import("@WebProfilerBundle/Resources/config/routing/wdt.$ext")
32+
->prefix('/_wdt');
33+
34+
$routes->import("@WebProfilerBundle/Resources/config/routing/profiler.$ext")
35+
->prefix('/_profiler');
36+
}
37+
};
Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,2 @@
11
_main:
2-
resource: routing_common.yml
3-
4-
controller:
5-
resource: '@TestBundle/Controller/MongoDbOdm'
6-
type: attribute
7-
8-
web_profiler_wdt:
9-
resource: '@WebProfilerBundle/Resources/config/routing/wdt.php'
10-
prefix: /_wdt
11-
12-
web_profiler_profiler:
13-
resource: '@WebProfilerBundle/Resources/config/routing/profiler.php'
14-
prefix: /_profiler
2+
resource: routing_mongodb.php

0 commit comments

Comments
 (0)