Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions src/Makefile.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
class Makefile
{

/**
* @var array
*/
private $makeInfo;

/**
* @param string $data Content from makefile.
*/
Expand All @@ -21,7 +26,7 @@ public function __construct($data)
*
* @param string[] $path Array of keys to retrieve value from.
*
* @return array|bool
* @return string|array|false
*/
public function getMakeInfo($path = array())
{
Expand All @@ -45,8 +50,10 @@ public function getMakeInfo($path = array())
*/
public function getDrupalProjects()
{
$projects = $this->getMakeInfo('projects');
$projects = is_array($projects) ? $projects : [];
$drupalProjects = [];
foreach ($this->getMakeInfo('projects') ?: [] as $projectName => $project) {
foreach ($projects as $projectName => $project) {
$url = $this->getMakeInfo(
['projects', $projectName, 'download', 'url']
);
Expand Down Expand Up @@ -148,23 +155,22 @@ public function getConstraint($project)
*
* @param array $path Nested keys to retrieve value from.
*
* @return bool|AbstractVersion|string
* @return false|string
*
* @todo Specify return type
*/
private function getVersionFromPath(array $path)
{
if ($versionString = $this->getMakeInfo($path)) {
return $this->makeVersion($versionString, $path[1]);
if (is_string($version = $this->getMakeInfo($path))) {
return $this->makeVersion($version, $path[1]);
}

return false;
}

/**
* Creates a SemVer string
* @param string $versionString
* @param string $name
* @return AbstractVersion|string
* @return string|null
*
* @todo: Better description.
* @todo Specify return type
Expand Down
5 changes: 3 additions & 2 deletions src/VersionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
class VersionFactory
{
/**
* Creates a version object from version information.
* Creates a version object from version information. Returns null if the
* given inforation is nonsense.
*
* @param string|array $versionInfo Either a version string or an array of
* core version and rest of version string.
* @param bool $isCore Indicator if version is core.
*
* @return AbstractVersion
* @return VersionInterface|null
*
* @todo Replace array syntax with constraint?
*/
Expand Down