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

Added public setter/getter to reference object. #830

Merged
merged 1 commit into from
Jan 1, 2018
Merged
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
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;
}
}