Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.6k
[TypeInfo] Introduce component#52510
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
[TypeInfo] Introduce component
Co-authored-by: Baptiste Leduc <baptiste.leduc@gmail.com>
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
There are no files selected for viewing
1 change: 1 addition & 0 deletionscomposer.json
This file contains hidden or 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
14 changes: 14 additions & 0 deletionssrc/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
This file contains hidden or 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 |
---|---|---|
@@ -44,6 +44,7 @@ | ||
use Symfony\Component\Serializer\Encoder\JsonDecode; | ||
use Symfony\Component\Serializer\Serializer; | ||
use Symfony\Component\Translation\Translator; | ||
use Symfony\Component\TypeInfo\Type; | ||
use Symfony\Component\Uid\Factory\UuidFactory; | ||
use Symfony\Component\Validator\Validation; | ||
use Symfony\Component\Webhook\Controller\WebhookController; | ||
@@ -164,6 +165,7 @@ public function getConfigTreeBuilder(): TreeBuilder | ||
$this->addAnnotationsSection($rootNode); | ||
$this->addSerializerSection($rootNode, $enableIfStandalone); | ||
$this->addPropertyAccessSection($rootNode, $willBeAvailable); | ||
$this->addTypeInfoSection($rootNode, $enableIfStandalone); | ||
$this->addPropertyInfoSection($rootNode, $enableIfStandalone); | ||
$this->addCacheSection($rootNode, $willBeAvailable); | ||
$this->addPhpErrorsSection($rootNode); | ||
@@ -1162,6 +1164,18 @@ private function addPropertyInfoSection(ArrayNodeDefinition $rootNode, callable | ||
; | ||
} | ||
private function addTypeInfoSection(ArrayNodeDefinition $rootNode, callable $enableIfStandalone): void | ||
{ | ||
$rootNode | ||
->children() | ||
->arrayNode('type_info') | ||
->info('Type info configuration') | ||
->{$enableIfStandalone('symfony/type-info', Type::class)}() | ||
mtarld marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
->end() | ||
->end() | ||
; | ||
} | ||
private function addCacheSection(ArrayNodeDefinition $rootNode, callable $willBeAvailable): void | ||
{ | ||
$rootNode | ||
26 changes: 26 additions & 0 deletionssrc/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
This file contains hidden or 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
5 changes: 5 additions & 0 deletionssrc/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd
This file contains hidden or 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
50 changes: 50 additions & 0 deletionssrc/Symfony/Bundle/FrameworkBundle/Resources/config/type_info.php
This file contains hidden or 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,50 @@ | ||
<?php | ||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
namespace Symfony\Component\DependencyInjection\Loader\Configurator; | ||
use Symfony\Component\TypeInfo\TypeContext\TypeContextFactory; | ||
use Symfony\Component\TypeInfo\TypeResolver\ReflectionParameterTypeResolver; | ||
use Symfony\Component\TypeInfo\TypeResolver\ReflectionPropertyTypeResolver; | ||
use Symfony\Component\TypeInfo\TypeResolver\ReflectionReturnTypeResolver; | ||
use Symfony\Component\TypeInfo\TypeResolver\ReflectionTypeResolver; | ||
use Symfony\Component\TypeInfo\TypeResolver\TypeResolver; | ||
use Symfony\Component\TypeInfo\TypeResolver\TypeResolverInterface; | ||
return static function (ContainerConfigurator $container) { | ||
$container->services() | ||
// type context | ||
->set('type_info.type_context_factory', TypeContextFactory::class) | ||
->args([service('type_info.resolver.string')->nullOnInvalid()]) | ||
// type resolvers | ||
->set('type_info.resolver', TypeResolver::class) | ||
->args([service_locator([ | ||
\ReflectionType::class => service('type_info.resolver.reflection_type'), | ||
\ReflectionParameter::class => service('type_info.resolver.reflection_parameter'), | ||
\ReflectionProperty::class => service('type_info.resolver.reflection_property'), | ||
\ReflectionFunctionAbstract::class => service('type_info.resolver.reflection_return'), | ||
])]) | ||
->alias(TypeResolverInterface::class, 'type_info.resolver') | ||
->set('type_info.resolver.reflection_type', ReflectionTypeResolver::class) | ||
->args([service('type_info.type_context_factory')]) | ||
->set('type_info.resolver.reflection_parameter', ReflectionParameterTypeResolver::class) | ||
->args([service('type_info.resolver.reflection_type'), service('type_info.type_context_factory')]) | ||
->set('type_info.resolver.reflection_property', ReflectionPropertyTypeResolver::class) | ||
->args([service('type_info.resolver.reflection_type'), service('type_info.type_context_factory')]) | ||
->set('type_info.resolver.reflection_return', ReflectionReturnTypeResolver::class) | ||
->args([service('type_info.resolver.reflection_type'), service('type_info.type_context_factory')]) | ||
; | ||
}; |
4 changes: 4 additions & 0 deletionssrc/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php
This file contains hidden or 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
1 change: 1 addition & 0 deletionssrc/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/full.php
This file contains hidden or 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
11 changes: 11 additions & 0 deletionssrc/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/type_info.php
This file contains hidden or 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,11 @@ | ||
<?php | ||
$container->loadFromExtension('framework', [ | ||
'annotations' => false, | ||
'http_method_override' => false, | ||
'handle_all_throwables' => true, | ||
'php_errors' => ['log' => true], | ||
'type_info' => [ | ||
'enabled' => true, | ||
], | ||
]); |
1 change: 1 addition & 0 deletionssrc/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/full.xml
This file contains hidden or 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
13 changes: 13 additions & 0 deletionssrc/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/type_info.xml
This file contains hidden or 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,13 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<container xmlns="http://symfony.com/schema/dic/services" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns:framework="http://symfony.com/schema/dic/symfony" | ||
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd | ||
http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> | ||
<framework:config http-method-override="false" handle-all-throwables="true"> | ||
<framework:annotations enabled="false" /> | ||
<framework:php-errors log="true" /> | ||
<framework:type-info enabled="true" /> | ||
</framework:config> | ||
</container> |
1 change: 1 addition & 0 deletionssrc/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/full.yml
This file contains hidden or 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
8 changes: 8 additions & 0 deletionssrc/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/type_info.yml
This file contains hidden or 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 @@ | ||
framework: | ||
annotations: false | ||
http_method_override: false | ||
handle_all_throwables: true | ||
php_errors: | ||
log: true | ||
type_info: | ||
enabled: true |
6 changes: 6 additions & 0 deletionssrc/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTestCase.php
This file contains hidden or 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
32 changes: 32 additions & 0 deletionssrc/Symfony/Bundle/FrameworkBundle/Tests/Functional/TypeInfoTest.php
This file contains hidden or 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 | ||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
namespace Symfony\Bundle\FrameworkBundle\Tests\Functional; | ||
use PHPStan\PhpDocParser\Parser\PhpDocParser; | ||
use Symfony\Bundle\FrameworkBundle\Tests\Functional\app\TypeInfo\Dummy; | ||
use Symfony\Component\TypeInfo\Type; | ||
class TypeInfoTest extends AbstractWebTestCase | ||
{ | ||
public function testComponent() | ||
{ | ||
static::bootKernel(['test_case' => 'TypeInfo']); | ||
$this->assertEquals(Type::string(), static::getContainer()->get('type_info.resolver')->resolve(new \ReflectionProperty(Dummy::class, 'name'))); | ||
if (!class_exists(PhpDocParser::class)) { | ||
$this->markTestSkipped('"phpstan/phpdoc-parser" dependency is required.'); | ||
} | ||
$this->assertEquals(Type::int(), static::getContainer()->get('type_info.resolver')->resolve('int')); | ||
} | ||
} |
21 changes: 21 additions & 0 deletionssrc/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/TypeInfo/Dummy.php
This file contains hidden or 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,21 @@ | ||
<?php | ||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
namespace Symfony\Bundle\FrameworkBundle\Tests\Functional\app\TypeInfo; | ||
/** | ||
* @author Mathias Arlaud <mathias.arlaud@gmail.com> | ||
* @author Baptiste Leduc <baptiste.leduc@gmail.com> | ||
*/ | ||
class Dummy | ||
{ | ||
public string $name; | ||
} |
18 changes: 18 additions & 0 deletionssrc/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/TypeInfo/bundles.php
This file contains hidden or 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,18 @@ | ||
<?php | ||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
use Symfony\Bundle\FrameworkBundle\FrameworkBundle; | ||
use Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\TestBundle; | ||
return [ | ||
new FrameworkBundle(), | ||
new TestBundle(), | ||
]; |
11 changes: 11 additions & 0 deletionssrc/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/TypeInfo/config.yml
This file contains hidden or 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,11 @@ | ||
imports: | ||
- { resource: ../config/default.yml } | ||
framework: | ||
http_method_override: false | ||
type_info: true | ||
services: | ||
type_info.resolver.alias: | ||
alias: type_info.resolver | ||
public: true |
1 change: 1 addition & 0 deletionssrc/Symfony/Bundle/FrameworkBundle/composer.json
This file contains hidden or 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
4 changes: 4 additions & 0 deletionssrc/Symfony/Component/TypeInfo/.gitattributes
This file contains hidden or 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,4 @@ | ||
/Testsexport-ignore | ||
/phpunit.xml.distexport-ignore | ||
/.gitattributesexport-ignore | ||
/.gitignoreexport-ignore |
3 changes: 3 additions & 0 deletionssrc/Symfony/Component/TypeInfo/.gitignore
This file contains hidden or 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,3 @@ | ||
vendor/ | ||
composer.lock | ||
phpunit.xml |
7 changes: 7 additions & 0 deletionssrc/Symfony/Component/TypeInfo/CHANGELOG.md
This file contains hidden or 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,7 @@ | ||
CHANGELOG | ||
========= | ||
7.1 | ||
--- | ||
* Add the component |
20 changes: 20 additions & 0 deletionssrc/Symfony/Component/TypeInfo/Exception/ExceptionInterface.php
This file contains hidden or 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 | ||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
namespace Symfony\Component\TypeInfo\Exception; | ||
/** | ||
* @author Mathias Arlaud <mathias.arlaud@gmail.com> | ||
* @author Baptiste Leduc <baptiste.leduc@gmail.com> | ||
*/ | ||
interface ExceptionInterface extends \Throwable | ||
{ | ||
} |
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.