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

Fix errors specified by PHPStorm #375

Merged
merged 1 commit into from
Oct 12, 2018
Merged

Conversation

aaron-junot
Copy link

@aaron-junot aaron-junot commented Oct 11, 2018

Fixes #277 and fixes #358.

This PR addresses all of the errors specified by PHPStorm.

@aaron-junot aaron-junot force-pushed the aaron-suarez/fix-phpstorm-warnings branch 2 times, most recently from b4bf2b4 to 8ef24dc Compare October 11, 2018 22:25
Copy link

@drewish drewish left a comment

Choose a reason for hiding this comment

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

Just got part of the way through this.

lib/recurly/base.php Show resolved Hide resolved
@@ -18,6 +18,7 @@
* @property string $revenue_schedule_type Optional field for setting a revenue schedule type. This will determine how revenue for the associated Plan should be recognized. When creating a Plan, if you supply an end_date and end_date available schedule types are never, evenly, at_range_start, or at_range_end.
* @property DateTime $created_at The date and time the add-on was created.
* @property DateTime $updated_at The date and time the add-on was last updated.
* @property string $plan_code Unique code to identify the plan.
Copy link

Choose a reason for hiding this comment

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

Not a strong preference but do we want to sort these at all? Maybe float it up above the $add_on_code?

Copy link
Author

Choose a reason for hiding this comment

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

I wasn't trying to change them all around, but I figure if we do care about sorting them, then either alphabetically or the same order as the dev docs makes the most sense.

My only problem with matching the docs is that it could get out of date quickly if the docs change and this doesn't get updated. For that reason, I think maybe we should sort them alphabetically even if that's not the order of importance to the reader. The whole purpose of these is for the IDE to recognize these props, right? Not for humans reading the top of the file.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is a decision that should be made at a higher level and not in this PR. I've personally gone back and forth on how to sort attributes and it would be nice to decide on a strategy for that globally but I think it's too big to tackle here.

* @throws Recurly_NotFoundError
* @throws Recurly_ApiRateLimitError
* @throws Recurly_ServerError
* @throws Recurly_RequestError
Copy link

Choose a reason for hiding this comment

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

All of these inherit from Recurly_Error should we just say we throw that? The only reason I wonder is, if we're this specific, if we add a new error we'd want to update all of these.

Copy link
Author

Choose a reason for hiding this comment

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

Yeah, that might be a better idea. PHPStorm automatically populated this list for me. I'll change this so that they all just document Recurly_Error

@aaron-junot aaron-junot force-pushed the aaron-suarez/fix-phpstorm-warnings branch from 8ef24dc to 41375f1 Compare October 12, 2018 15:41
Copy link

@drewish drewish left a comment

Choose a reason for hiding this comment

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

This is looking good to me. Few little things that we could change or ignore. I'll let @bhelx weigh in and do the final honors.

* Retrieve the PDF version of this invoice
*
* @param string $locale
* @return string
Copy link

Choose a reason for hiding this comment

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

I suspect this is actually binary data but maybe string is the right name for it?

Copy link
Author

Choose a reason for hiding this comment

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

Right, in the same way that pack also returns a "string", but it's actually binary data. I could call out that it's actually a binary string if that helps for clarity

* @param $invoiceNumber
* @param string $locale
* @param Recurly_Client $client The recurly client
* @return string
Copy link

Choose a reason for hiding this comment

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

Same concern here.

@@ -21,7 +27,7 @@ protected function uri() {
if (!empty($this->_href))
return $this->getHref();
else
return Recurly_Addon::uriForMeasuredUnit($this->id);
return Recurly_MeasuredUnit::uriForMeasuredUnit($this->id);
Copy link

Choose a reason for hiding this comment

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

Whoops, good catch.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah thanks, looks like a copy-pasta mistake from me.

* @param RecurlyClient Optional client for the request, useful for mocking the client
* @return Recurly_InvoiceCollection
* @param $purchase Recurly_Purchase Our purchase data.
* @param Recurly_Client $client Optional client for the request, useful for mocking the client
Copy link

Choose a reason for hiding this comment

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

If we were looking for a message to copy pasta for all these @param Recurly_Client lines this one is a pretty good one.

Copy link
Author

Choose a reason for hiding this comment

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

Agreed, I'm going to change these out throughout the project

Copy link
Author

Choose a reason for hiding this comment

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

I made them all this message, we should be good on this particular note

*/
public function terminateWithoutRefund() {
$this->terminate('none');
}

/**
* @param $refundType
Copy link

Choose a reason for hiding this comment

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

Would be nice to add the acceptable values here.

@aaron-junot aaron-junot force-pushed the aaron-suarez/fix-phpstorm-warnings branch from 41375f1 to 0b929b8 Compare October 12, 2018 16:11
@aaron-junot aaron-junot force-pushed the aaron-suarez/fix-phpstorm-warnings branch from 0b929b8 to e6a1e8e Compare October 12, 2018 16:39
@@ -6,6 +6,8 @@
protected $_type;
protected $_client;
protected $_links;
protected $_values;
protected $_errors;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you describe what issue this is meant to prevent?

Copy link
Author

Choose a reason for hiding this comment

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

Converting this class to a string assumes the presence of a $_values array

ksort($this->_values);

Parsing XML to object assumes the presence of an $_errors array

Recurly_Resource::__parseXmlToObject($rootNode->firstChild, $this->_errors);

To be honest, I don't think this is the very best solution. I think a possibly better solution would be to move the functions that reference $_values and $_errors into the class (Recurly_Resource) that defines their existence, but I'm concerned about breaking things. There's a bit of twisted logic and I didn't dig into it enough to determine whether there's ever a situation where something else that is not a Recurly_Resource would end up calling these functions that reference $_values and $_errors. So the idea was to declare them as existing, but it's up to the subclasses to define exactly what they are and assign them values.

Copy link
Contributor

@bhelx bhelx left a comment

Choose a reason for hiding this comment

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

👍

@bhelx bhelx merged commit 1962582 into master Oct 12, 2018
@bhelx bhelx deleted the aaron-suarez/fix-phpstorm-warnings branch October 12, 2018 17:22
@bhelx
Copy link
Contributor

bhelx commented Oct 12, 2018

@aaron-suarez thanks for taking the time to do this. I think it's a nice improvement to the dev experience.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
V2 V2 Client
Projects
None yet
3 participants