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

Incorrect use of @property tags throughout the codebase #926

Open
00dani opened this issue Aug 1, 2024 · 2 comments
Open

Incorrect use of @property tags throughout the codebase #926

00dani opened this issue Aug 1, 2024 · 2 comments

Comments

@00dani
Copy link

00dani commented Aug 1, 2024

xero-php declares the available fields on its models using the syntax @property Type Name inside the body of the class. For example, the Invoiceclass declares many fields using this pattern:

class Invoice extends Remote\Model
{
    use PDFTrait;
    use AttachmentTrait;
    use SendEmailTrait;
    use HistoryTrait;

    /**
     * See Invoice Types.
     *
     * @property string Type
     */

    /**
     * See Contacts.
     *
     * @property Contact Contact
     */

    /**
     * See LineItems.
     *
     * @property LineItem[] LineItems
     */

Unfortunately this is not the correct way to use the @property PHPDoc tag, and tools such as PHPStan and Psalm cannot understand it, which makes using xero-php models significantly more difficult than necessary.

According to the PHPDoc documentation, property tags must tag the entire class (or trait), and must be written in the form @property Type $Name. For example, this is the correct way to declare the above properties on an invoice:

/**
 * @property string $Type
 * @property Contact $Contact
 * @property LineItem[] $LineItems
 */
class Invoice extends Remote\Model

Could this mistake please be fixed?

@calcinai
Copy link
Owner

calcinai commented Aug 4, 2024

Hi @00dani, thanks for pointing this out. I'm not sure why it was implemented like this to begin with, but I'm wondering if a decade ago when this was written, maybe the standard was less prescriptive. Just a guess!

Unfortunately, xero-php is no longer programatically generated, so it'll be a reasonable amount of work to go and swap these out, possibly even warrants writing a script to do so. If you've got time/capacity to do this an open a PR, I'd be happy to merge this in.

@00dani
Copy link
Author

00dani commented Aug 5, 2024

On it! I'm not sure why GitHub didn't link it automatically when I mentioned this issue number, but my PR is up: #927

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

No branches or pull requests

2 participants