-
Notifications
You must be signed in to change notification settings - Fork 93
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
Conversation
b4bf2b4
to
8ef24dc
Compare
There was a problem hiding this 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.
@@ -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. |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
lib/recurly/base.php
Outdated
* @throws Recurly_NotFoundError | ||
* @throws Recurly_ApiRateLimitError | ||
* @throws Recurly_ServerError | ||
* @throws Recurly_RequestError |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
8ef24dc
to
41375f1
Compare
There was a problem hiding this 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.
lib/recurly/invoice.php
Outdated
* Retrieve the PDF version of this invoice | ||
* | ||
* @param string $locale | ||
* @return string |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
lib/recurly/invoice.php
Outdated
* @param $invoiceNumber | ||
* @param string $locale | ||
* @param Recurly_Client $client The recurly client | ||
* @return string |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops, good catch.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
lib/recurly/subscription.php
Outdated
*/ | ||
public function terminateWithoutRefund() { | ||
$this->terminate('none'); | ||
} | ||
|
||
/** | ||
* @param $refundType |
There was a problem hiding this comment.
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.
41375f1
to
0b929b8
Compare
0b929b8
to
e6a1e8e
Compare
@@ -6,6 +6,8 @@ | |||
protected $_type; | |||
protected $_client; | |||
protected $_links; | |||
protected $_values; | |||
protected $_errors; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
recurly-client-php/lib/recurly/base.php
Line 146 in e6a1e8e
ksort($this->_values); |
Parsing XML to object assumes the presence of an $_errors
array
recurly-client-php/lib/recurly/base.php
Line 300 in e6a1e8e
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@aaron-suarez thanks for taking the time to do this. I think it's a nice improvement to the dev experience. |
Fixes #277 and fixes #358.
This PR addresses all of the errors specified by PHPStorm.