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

[TypeInfo] Add documentation #19554

Merged
merged 1 commit into from
Jul 2, 2024

Conversation

Korbeil
Copy link
Contributor

@Korbeil Korbeil commented Feb 14, 2024

Q A
Doc fix? no
New docs? yes (symfony/symfony#52510)
Applies to 7.1
Fixed tickets #19497

@carsonbot carsonbot added this to the 7.1 milestone Feb 14, 2024
@Korbeil Korbeil force-pushed the feature/type-info-component branch from 0e9ac79 to d4d6b78 Compare February 14, 2024 08:17
Copy link
Member

@javiereguiluz javiereguiluz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Baptiste, thanks for bootstrapping these docs.

I left some comments in some sections that I found a bit confusing or lacking so we can iterate over them. Thanks!

components/type_info.rst Outdated Show resolved Hide resolved
components/type_info.rst Outdated Show resolved Hide resolved

use Symfony\Component\TypeInfo\Type;

Type::int();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the examples of this block. What are we building? Is this to create something? To check something? How can I use this in a Symfony app? Thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a component you will use in a Symfony app. This is a component made for other components or for libraries to use.


// Then resolve types for any subject
$typeResolver->resolve(new \ReflectionProperty(Dummy::class, 'id')); // returns an "int" Type instance
$typeResolver->resolve('bool'); // returns a "bool" Type instance
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The example is not very clear because some reader won't make the connection and don't know that 'bool' here refers to a boolean property of some class.

I think we need to create a simple class first with the needed properties ... and then show the code needed to introspect the type information.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's kinda complex because it's not something designed to use "as it is" or only for very specific cases.
I tried to explain a bit better how raw string resolving works and what it is used for (basically phpDoc).
Does it help more to understand ?


.. note::

To support raw string resolving, you need to install ``phpstan/phpdoc-parser`` package.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't fully understand what "raw string resolving" means here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see #19554 (comment) for more details, but "raw string resolving" means you're using the resolver with a string. It is mostly designed to handle phpDoc

@carsonbot carsonbot changed the title Add base TypeInfo documentation [TypeInfo] Add base TypeInfo documentation Feb 22, 2024
@OskarStark OskarStark changed the title [TypeInfo] Add base TypeInfo documentation [TypeInfo] Add documentation Feb 22, 2024
@OskarStark
Copy link
Contributor

OskarStark commented May 15, 2024

Open for finishing the first docs?

cc @mtarld

@Korbeil
Copy link
Contributor Author

Korbeil commented May 15, 2024

Open for finishing the first docs?

Sorry for the delay, I made some changes and will try to find time to fix the remaining parts.

@Korbeil
Copy link
Contributor Author

Korbeil commented Jun 23, 2024

Hey there, @javiereguiluz any news ?

@javiereguiluz javiereguiluz force-pushed the feature/type-info-component branch from 7766204 to b6ffad3 Compare July 2, 2024 14:44
@javiereguiluz javiereguiluz merged commit 3631834 into symfony:7.1 Jul 2, 2024
2 of 3 checks passed
@javiereguiluz
Copy link
Member

Baptiste, this is now merged. Thanks a lot!

I'll open a new issue with some questions related to this doc to see if we can improve it. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants