Skip to content

Conversation

kilya11
Copy link
Contributor

@kilya11 kilya11 commented Sep 18, 2025

@property[<-read|-write>] [Type] [name] [<description>]

This is the full syntax for @property, see https://docs.phpdoc.org/guide/references/phpdoc/tags/property.html
Here is a fix to support all of them:

/**
 * @property bool $alpha
 * @property-read array $beta
 * @property-write Test $gamma
 */

* @property-read array $beta
* @property-write Test $gamma
* @property bool $alpha
*/
Copy link
Owner

Choose a reason for hiding this comment

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

So, will it break a groups of read and write? Can you add a test case with this as input:

/**
 * @property-write string $charlie
 * @property-write string $foxtrot
 * @property-write string $bravo
 * @property-read string $echo
 * @property-read string $delta
 * @property-read string $alfa
 */

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The test is in place. Yes, it will break these groups. To keep the groups intact, you should add a blank line between them:

/**
 * @property-write string $charlie
 * @property-write string $foxtrot
 * @property-write string $bravo
 *
 * @property-read string $echo
 * @property-read string $delta
 * @property-read string $alfa
 */

# Conflicts:
#	src/Fixer/PhpdocPropertySortedFixer.php
#	tests/Fixer/PhpdocPropertySortedFixerTest.php
@kilya11 kilya11 force-pushed the phpdoc-sorter-property branch from 8375152 to c922594 Compare September 22, 2025 14:44
@kilya11 kilya11 changed the title Extend PhpDocPropertySorterFixer to support @property-read and -write Extend PhpdocPropertySortedFixer to support @property-read and -write Sep 22, 2025
@kubawerlos kubawerlos merged commit ecc688e into kubawerlos:main Sep 27, 2025
18 checks passed
@kubawerlos
Copy link
Owner

Thank you @kilya11

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants