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

Enhanced contracts PHPDoc #463

Open
wants to merge 92 commits into
base: 4.6
Choose a base branch
from
Open

Enhanced contracts PHPDoc #463

wants to merge 92 commits into from

Conversation

adriendupuis
Copy link
Contributor

@adriendupuis adriendupuis commented Dec 12, 2024

🎫 Issue IBX-XXXXX

Related PRs:

Description:

  • Add missing summaries (discovered during Enhance PHP API REF metadata documentation-developer#2575). A summary is the first line of a docblock. It can't have advanced formatting as it won't be rendered. Fix several not-rendered inline {@see tags
  • Type array keys to avoid generic array<string|int, rendering.
  • Type array values
    • It fixes several "no value type specified in iterable type array" so PHPStan file is updated.
  • Use triple-backticks to have code blocks instead of <code> rendered as a single line.
  • Fix some @see syntax to have a working link.
  • Use class name instead of self to have a link (to the current page, debatable, it could also be $this).
  • Reword some descriptions.
  • ValueObject: Replace @ignore This method is for internal use with the dedicated @internal, fix some @uses tags.
Preview

Preview is build on top of ibexa/documentation-developer#2584.
But the following comparisons focus on the improvements brought by the packages' PRs.

  • Ibexa\Contracts\Core\FieldType\FieldType
    • Before has code examples on one line, and with old school array() syntax.
    • After has code examples in blocks with preserved new lines, and with a more modern [] syntax.
  • Ibexa\Contracts\Core\FieldType\Generic\Type
    • Before has code examples on one line, checkValueType() makes a not-clickable reference to acceptValue().
    • After has code example blocks with preserved new lines, and checkValueType() a working link to acceptValue().
  • Ibexa\Contracts\Core\FieldType\Generic\ValidationError\ConstraintViolationAdapter
    • Before has not rendered @see tags in its introduction and <meta name="description" because the summary line can't have advanced format.
    • After has a simple summary then a short description with @see rendered as links to references.
  • Ibexa\Contracts\Core\Limitation\Target\Builder\VersionBuilder
    • Before has not rendered @see tags in its introduction, and some string|int untyped array keys.
    • After has more links, and typed array keys.
  • Ibexa\Contracts\Core\Limitation\Type
    • Before has a description for ACCESS_GRANTED which, in fact, is a description for the three ACCESS_ constants (grouped docblock doesn't exist and because of alphabetic order, the description ends after what it introduces), about the same for VALUE_SCHEMA_ constants, a not-rendered @see, and a not typed array key.
    • After has a description for each constants, links, and typed array keys.
  • Ibexa\Contracts\Core\Repository\LocationService
    • Before has a not-rendered @see, and untyped array keys.
    • After has a new summary for count(), a working link in its description, typed keys on several arrays.
  • Ibexa\Contracts\Core\Repository\SearchService
    • Before has several not-rendered @see.
    • After has a more readable description CAPABILITY_CUSTOM_FIELDS, new summaries, and more links.
  • Ibexa\Contracts\Core\Repository\Values\Content\Location
    • Before has some @deprecated not rendered because wrongly nested.
      • Nota bene: This happens in other classes. It's on my todo list for another PR.
    • After has the read-only properties' summaries rewritten. Nota bene: The way a property is declared being both protected and magically publicly read-only (@property-read) creates duplicates: it's declared twice in the PHP code, and documented twice in the reference. This is an issue I'll come back to later.
  • Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion
    • Before, has a not-rendered @see, misses links to properties and constants, and has an example rendered as a single line.
    • After has links and a proper code block.
  • Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\DateMetadata
    • Before has an example rendered as a single line.
    • After has well rendered example, more readable descriptions, a link from DateMetadata::TRASHED to TrashService::findTrashItems(), and more links in general.
  • Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\UserMetadata
    • Before has two one-line examples, a typo in a quoted constant, a lack of links.
    • After has code blocks, enhanced descriptions, more links.
  • Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Operator\Specifications
    • Before's description quotes Criterion::getSpecifications() without a link.
    • After: description is reworded, a link to Criterion::getSpecifications() is added with an inline tag instead of a separated tag below.
  • Ibexa\Contracts\Core\Repository\Values\ValueObject
  • Ibexa\Contracts\Core\Search\Capable
    • Before has a not rendered @see in its summary.
    • After has a new summary, the link is in its description, and a link to SearchService helps to see the CAPABILITY_ constants.

For QA:

Documentation:

@@ -53,12 +55,12 @@ class DateMetadata extends Criterion implements TrashCriterion, FilteringCriteri
];

/**
* Creates a new DateMetadata criterion on $metadata.
* Creates a new DateMetadata criterion.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't find such property in the contracts namespace. (I may haven't look well enough in the namespace.) It might not be in this contracts namespace, and hidden by abstraction. If no link can be made to it, it probably don't worth being mentioned.

@adamwojs
Copy link
Member

@adriendupuis Rebase is needed here

Copy link

sonarqubecloud bot commented Feb 6, 2025

@adriendupuis adriendupuis marked this pull request as ready for review February 6, 2025 08:20
@adriendupuis adriendupuis requested a review from a team February 6, 2025 08:29
* allow you on some search criteria to specify this custom field to rather query on that instead of the default
* field generated by the system.
* Custom fields is the capability for search engines to:
* - Allow you to extend the search index via plugins to
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* - Allow you to extend the search index via plugins to
* - allow you to extend the search index via plugins to

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* - Allow you to extend the search index via plugins to
* - allow you to extend the search index via plugins to

Doesn't that depend on how we finish the sentence in bullet point? Meaning, if it ends with:

  • Dot = capital letters for bullet points.
  • Comma = small letters.

But don't quote me on that, maybe English grammar rules are different?

* Custom fields is the capability for search engines to:
* - Allow you to extend the search index via plugins to
* generate custom fields, like a different representation (format, ...) of an existing field or similar.
* - Allow you on some search criteria to specify this custom field to rather query on that instead of the default
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* - Allow you on some search criteria to specify this custom field to rather query on that instead of the default
* - allow you on some search criteria to specify this custom field to rather query on that instead of the default

* @property-read int $depth @deprecated 4.6.7 accessing magic getter is deprecated and will be removed in 5.0.0. Use {@see Location::getDepth()} instead.
* @property-read string $remoteId A global unique ID of the content object
* @property-read int $parentLocationId The ID of the parent location
* @property-read string $pathString Since 4.6.7, accessing magic getter is deprecated and will be removed in 5.0.0. Use {@see Location::getPathString()} instead.
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't @deprecated tag be left untouched?

Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't @deprecated tag be left untouched?

This is actually quite significant issue. We need the ability to mark those as deprecated @adriendupuis

*/
public function getPathString(): string
{
return $this->pathString;
}

/**
* Same as {@see Location::getPathString()} but as array, e.g.: <code>[ '1', '2', '4', '23' ]</code>.
* The list of ancestor Locations' IDs, ordered in increasing depths,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* The list of ancestor Locations' IDs, ordered in increasing depths,
* The list of ancestor locations' IDs, ordered by increasing depth,

*
* @var string
*/
protected $pathString;

/**
* Same as {@see Location::$pathString} but as array, e.g.: <code>[ '1', '2', '4', '23' ]</code>.
* The list of ancestor Locations' IDs, ordered in increasing depths,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* The list of ancestor Locations' IDs, ordered in increasing depths,
* The list of ancestor locations' IDs, ordered by increasing depth,

Comment on lines +103 to +116
* ```
* [
* 'stringLength' => [
* 'minStringLength' => [
* 'type' => 'int',
* 'default' => 0,
* ],
* 'maxStringLength' => [
* 'type' => 'int'
* 'default' => null,
* ],
* ],
* ];
* ```
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 mind it much, maybe even simpler and it renders well in PHPStorm, but don't you think we need a bit of consistency? There's 249 occurrences of <code> in this repository. Wouldn't it be better to handle it separately in another PR? Meaning: just replace <code> with ```?

*
* Note: In future version constant values might change to 1, 0 and -1 as used in Symfony.
*
* @since 5.3.2
Copy link
Member

Choose a reason for hiding this comment

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

We probably need to drop these as it references eZ Publish and there's version number mismatch.

* allow you on some search criteria to specify this custom field to rather query on that instead of the default
* field generated by the system.
* Custom fields is the capability for search engines to:
* - Allow you to extend the search index via plugins to
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* - Allow you to extend the search index via plugins to
* - allow you to extend the search index via plugins to

Doesn't that depend on how we finish the sentence in bullet point? Meaning, if it ends with:

  • Dot = capital letters for bullet points.
  • Comma = small letters.

But don't quote me on that, maybe English grammar rules are different?

Comment on lines +143 to +144
* - `['languages' => [<language_code_string>,…], 'useAlwaysAvailable' => <bool>]`
* - `[<language_code_string>,…]` where `useAlwaysAvailable` defaults to `true` to avoid exceptions on missing translations.
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't render well in PHPStorm.
image

Comment on lines -18 to +27
* @property-read \Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo $contentInfo calls getContentInfo()
* @property-read int $contentId @deprecated 4.6.7 accessing magic getter is deprecated and will be removed in 5.0.0. Use {@see Location::getContentId()} instead.
* @property-read int $id @deprecated 4.6.7 accessing magic getter is deprecated and will be removed in 5.0.0. Use {@see Location::getId()} instead.
* @property-read \Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo $contentInfo Calls {@see Location::getContentInfo()}
* @property-read int $contentId Since 4.6.7, accessing magic getter is deprecated and will be removed in 5.0.0. Use {@see Location::getContentId()} instead.
* @property-read int $id Since 4.6.7, accessing magic getter is deprecated and will be removed in 5.0.0. Use {@see Location::getId()} instead.
* @property-read int $priority Position of the Location among its siblings when sorted using priority
* @property-read bool $hidden @deprecated 4.6.7 accessing magic getter is deprecated and will be removed in 5.0.0. Use {@see Location::isHidden()} instead.
* @property-read bool $invisible @deprecated 4.6.7 accessing magic getter is deprecated and will be removed in 5.0.0. Use {@see Location::isInvisible()} instead.
* @property-read bool $hidden Since 4.6.7, accessing magic getter is deprecated and will be removed in 5.0.0. Use {@see Location::isHidden()} instead.
* @property-read bool $invisible Since 4.6.7, accessing magic getter is deprecated and will be removed in 5.0.0. Use {@see Location::isInvisible()} instead.
* @property-read bool $explicitlyHidden Indicates that the Location entity has been explicitly marked as hidden.
* @property-read string $remoteId a global unique id of the content object
* @property-read int $parentLocationId the id of the parent location
* @property-read string $pathString @deprecated 4.6.7 accessing magic getter is deprecated and will be removed in 5.0.0. Use {@see Location::getPathString()} instead.
* @property-read array $path @deprecated 4.6.7 accessing magic getter is deprecated and will be removed in 5.0.0. Use {@see Location::getPath()} instead.
* @property-read int $depth @deprecated 4.6.7 accessing magic getter is deprecated and will be removed in 5.0.0. Use {@see Location::getDepth()} instead.
* @property-read string $remoteId A global unique ID of the content object
* @property-read int $parentLocationId The ID of the parent location
* @property-read string $pathString Since 4.6.7, accessing magic getter is deprecated and will be removed in 5.0.0. Use {@see Location::getPathString()} instead.
Copy link
Member

Choose a reason for hiding this comment

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

Getting more detailed overview now, this is entirely incorrect, sorry.
This is deprecated since 4.6.7, using "since" alone indicates that it's available since then.

Comment on lines 89 to 93
/**
* Location ID.
*
* @var int Location ID.
* @var int
*/
Copy link
Member

Choose a reason for hiding this comment

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

Given this is Location object, it could be even as simple as:

/** @var int */

as this code block doesn't carry any extra information that can't be inferred (I mean Location::$id is a Location ID).

* @var string[]
* Same as {@see Location::$pathString} but as array, e.g.: `['1', '2', '4', '23']`.
*
* @var array <int, string>
Copy link
Member

Choose a reason for hiding this comment

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

CS

Suggested change
* @var array <int, string>
* @var array<int, string>

@alongosz alongosz changed the title Enhance PHPDoc Enhanced contracts PHPDoc Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants