Skip to content

Commit

Permalink
Update Reference.php (#830)
Browse files Browse the repository at this point in the history
  • Loading branch information
siad007 authored and mrook committed Jan 1, 2018
1 parent 16be52e commit 4f9195a
Showing 1 changed file with 21 additions and 16 deletions.
37 changes: 21 additions & 16 deletions classes/phing/types/Reference.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,26 +55,36 @@ public function getRefId()
return $this->refid;
}

public function setProject(Project $project)
{
$this->project = $project;
}

/**
* Get the associated project, if any; may be null.
* @return Project the associated project
*/
public function getProject(): \Project
{
return $this->project;
}

/**
* returns reference to object in references container of project
*
* @param Project $project
* @param Project|null $fallback
*
* @throws BuildException
*
* @return Reference
* @return object
*/
public function getReferencedObject(Project $project = null)
public function getReferencedObject(Project $fallback = null)
{
if ($project !== null) {
$this->project = $project;
}
$project = $fallback ?? $this->project;

if ($this->refid === null) {
throw new BuildException("No reference specified");
}
$refs = $project->getReferences();
$o = @$refs[$this->refid];
if (!is_object($o)) {
$o = $project->getReference($this->refid);
if ($o === null) {
throw new BuildException("Reference {$this->refid} not found.");
}

Expand All @@ -85,9 +95,4 @@ public function __toString()
{
return $this->refid;
}

private function setProject($project)
{
$this->project = $project;
}
}

0 comments on commit 4f9195a

Please sign in to comment.