Skip to content

Conversation

@johnsaigle
Copy link
Contributor

See #3878 for background

@johnsaigle johnsaigle added Category: Cleanup PR or issue introducing/requiring at least one clean-up operation [branch] major labels Nov 20, 2018
'While attempting to get Subproject config settings, caught ' .
"DatabaseException: `$e`"
);
return array();
Copy link
Collaborator

Choose a reason for hiding this comment

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

This return is unreachable.. but other than that, what's the point of this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll remove the unreachable return.

I thought it would be better not to silence the DB exception because it probably means something went wrong. Returning null to me makes it seem like there was no entry for $subprojectID in the table -- but in that case there shouldn't be an exception thrown; pselectRow should just return null.

Copy link
Collaborator

Choose a reason for hiding this comment

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

In that case why not just remove the try/catch? If the database throws an exception and it isn't caught the stack trace will tell you where it came from.

Copy link
Collaborator

@HenriRabalais HenriRabalais left a comment

Choose a reason for hiding this comment

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

A few questions

* @return mixed The value from the database, or null if nothing found.
*/
function getSettingFromDB($name, $id=null)
function getSettingFromDB(string $name, ?int $id = null)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Given the description in the return doc, couldn't the return type be stated as ?array ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can't remember when I added the FIXME above but no, this can return array, string or null

Copy link
Collaborator

Choose a reason for hiding this comment

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

the doc block can be updated to indicate a sum type even if the function signature can't, phan might be able to use the slightly tighter bounds to track down a few more bugs from the doc than "mixed".. but I'll merge this as is, since it's relatively minor.

* @return NDB_Config object
*/
static function &singleton($configFile = null)
static function &singleton(?string $configFile = null)
Copy link
Collaborator

Choose a reason for hiding this comment

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

is there a NDB_Config object class that can be declared in the function declared type here? e.g. : \NDB_Config

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes I think so

* @param string $name The name of the XML node to retrieve.
*
* @return string The value from the config.xml
* @return mixed The value from the config.xml
Copy link
Collaborator

Choose a reason for hiding this comment

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

instead of mixed, would it be better to state the potential types that can be returned?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep!

@johnsaigle johnsaigle added the State: Needs work PR awaiting additional work by the author to proceed label Nov 27, 2018
@johnsaigle johnsaigle removed the State: Needs work PR awaiting additional work by the author to proceed label Nov 27, 2018
@johnsaigle johnsaigle dismissed HenriRabalais’s stale review November 29, 2018 17:33

Resolved all points

@driusan driusan merged commit b14aafd into aces:major Dec 12, 2018
@ridz1208 ridz1208 added this to the 21.0.0 milestone Dec 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Category: Cleanup PR or issue introducing/requiring at least one clean-up operation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants