Skip to content
This repository has been archived by the owner on Mar 15, 2020. It is now read-only.

Update API doc and deprecations #19

Merged
merged 3 commits into from
Jun 1, 2017

Conversation

theofidry
Copy link
Member

@theofidry theofidry commented May 28, 2017

  • Move the functions from the global namespace to the Humbug namespace
  • Add missing phpdoc to make the code more self-documented and laying the path for a PHP7 upgrade where we will be able to add typehints
  • Try to make things private or final whenever possible

@theofidry theofidry changed the title Update API doc and deprecations [WIP] Update API doc and deprecations May 28, 2017
@theofidry theofidry changed the title [WIP] Update API doc and deprecations Update API doc and deprecations May 28, 2017
@@ -31,36 +41,68 @@ public function __construct()
$this->options = array_replace_recursive($this->options, $options);
}

/**
* @param string $filename Name of the file to read.
Copy link
Member Author

Choose a reason for hiding this comment

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

should $filename be actually renamed to $url?

Copy link
Collaborator

Choose a reason for hiding this comment

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

It just reflects the docs: http://php.net/file_get_contents.

public static function hasNextRequestHeaders()
{
return !empty(self::$nextRequestHeaders);
return null !== self::$nextRequestHeaders;
Copy link
Member Author

Choose a reason for hiding this comment

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

Actually probably not acceptable for a minor version as technically it's a BC break: empty request headers would have returned true before.

Tell me if the change of behaviour is wanted as IMO empty request headers still means there's headers, just no actual value, as opposed to no request headers set yet. If yes, then I'll update the code to add deprecations to reflect on that.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we're fine if the original behaviour was incorrect.

$headers
);

if (empty($headers)) {
Copy link
Member Author

Choose a reason for hiding this comment

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

the changes are due to that line, i.e. doing an early return to avoid a 2 deep nested statements

@@ -198,6 +266,8 @@ protected function getTlsStreamContextDefaults($cafile)
* @throws \RuntimeException If https proxy required and OpenSSL uninstalled
*
* @return resource Default context
*
* @final since 1.1.0
*/
protected function getMergedStreamContext($url)
Copy link
Member Author

Choose a reason for hiding this comment

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

the function has changed since this has been pasted, see https://github.com/composer/composer/blob/master/src/Composer/Util/StreamContextFactory.php, so maybe we should update the code to reflect on that?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Assuming there's no changes in its behaviour, but sure it's probably no harm to stay close to the original source.

Copy link
Member Author

Choose a reason for hiding this comment

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

I really don't feel comfortable enough with that part to really assess if there's any problematic change that occurred right now so I'll leave it there for now. Might check again later

return CaBundle::getSystemCaRootBundlePath();
}

/**
* @deprecated
* @deprecated since 1.1.0 and will be removed in 2.0.0.
*/
protected static function validateCaFile($contents)
Copy link
Member Author

Choose a reason for hiding this comment

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

I would like a more helpful deprecation message here like the one just above, but I can't find any. There's actually no use of that method in our codebase so should this be exposed in a function or this shouldn't exist in the first place?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I probably left it out of caution, but would remove if no longer used.

@theofidry theofidry requested a review from padraic May 28, 2017 15:47
@@ -31,36 +41,68 @@ public function __construct()
$this->options = array_replace_recursive($this->options, $options);
}

/**
* @param string $filename Name of the file to read.
Copy link
Collaborator

Choose a reason for hiding this comment

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

It just reflects the docs: http://php.net/file_get_contents.

public static function hasNextRequestHeaders()
{
return !empty(self::$nextRequestHeaders);
return null !== self::$nextRequestHeaders;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we're fine if the original behaviour was incorrect.

@@ -198,6 +266,8 @@ protected function getTlsStreamContextDefaults($cafile)
* @throws \RuntimeException If https proxy required and OpenSSL uninstalled
*
* @return resource Default context
*
* @final since 1.1.0
*/
protected function getMergedStreamContext($url)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Assuming there's no changes in its behaviour, but sure it's probably no harm to stay close to the original source.

return CaBundle::getSystemCaRootBundlePath();
}

/**
* @deprecated
* @deprecated since 1.1.0 and will be removed in 2.0.0.
*/
protected static function validateCaFile($contents)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I probably left it out of caution, but would remove if no longer used.

@theofidry
Copy link
Member Author

Ready for a new review

@theofidry
Copy link
Member Author

@Nyholm you might want to take a look

@theofidry theofidry merged commit 3aa2239 into humbug:master Jun 1, 2017
@theofidry theofidry deleted the feature/update-api branch June 1, 2017 21:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants