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

Adds check for correct parameter type to prevent possible php error #12786

Merged
merged 1 commit into from May 1, 2018

Conversation

sgiehl
Copy link
Member

@sgiehl sgiehl commented Apr 29, 2018

prevents error described in #12734

fixes #12734

@sgiehl sgiehl added not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org. Needs Review PRs that need a code review labels Apr 29, 2018
@sgiehl sgiehl added this to the 3.5.0 milestone Apr 29, 2018
@@ -84,8 +83,14 @@ class RowEvolution
*/
public function __construct($idSite, $date, $graphType = 'graphEvolution')
{
if (!($date instanceof Date)) {
throw new Exception("Expected date to be an instance of \\Piwik\\Date");
}
Copy link
Member

Choose a reason for hiding this comment

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

Would it be better or worse to use a typehint, ie, __construct($idSite, Date $date, $graphType = '...')?

Copy link
Member Author

Choose a reason for hiding this comment

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

Thought about that, but wouldn't it throw a PHP error if a non Date parameter is given then?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, that's unfortunate we can't use the language feature here... oh well.

@diosmosis diosmosis merged commit 993bfa6 into 3.x-dev May 1, 2018
@diosmosis diosmosis deleted the 12734-fix branch May 1, 2018 15:18
InfinityVoid pushed a commit to InfinityVoid/matomo that referenced this pull request Oct 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Review PRs that need a code review not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

In Row evolution popover may return "Call to a member function toString() on null"
2 participants