repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1 value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
phingofficial/phing | classes/phing/tasks/ext/ManifestTask.php | ManifestTask.setChecksum | public function setChecksum($mixed)
{
if (is_string($mixed)) {
$data = [strtolower($mixed)];
if (strpos($data[0], ',')) {
$data = explode(',', $mixed);
}
$this->checksum = $data;
} elseif ($mixed === true) {
$this->checksum = ['md5'];
}
} | php | public function setChecksum($mixed)
{
if (is_string($mixed)) {
$data = [strtolower($mixed)];
if (strpos($data[0], ',')) {
$data = explode(',', $mixed);
}
$this->checksum = $data;
} elseif ($mixed === true) {
$this->checksum = ['md5'];
}
} | [
"public",
"function",
"setChecksum",
"(",
"$",
"mixed",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"mixed",
")",
")",
"{",
"$",
"data",
"=",
"[",
"strtolower",
"(",
"$",
"mixed",
")",
"]",
";",
"if",
"(",
"strpos",
"(",
"$",
"data",
"[",
"0",
... | The setter for the attribute "checksum"
@param mixed $mixed
@return void | [
"The",
"setter",
"for",
"the",
"attribute",
"checksum"
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/tasks/ext/ManifestTask.php#L118-L131 | train |
phingofficial/phing | classes/phing/tasks/ext/ManifestTask.php | ManifestTask.main | public function main()
{
$this->validateAttributes();
if ($this->action == 'w') {
$this->write();
} elseif ($this->action == 'r') {
$this->read();
}
} | php | public function main()
{
$this->validateAttributes();
if ($this->action == 'w') {
$this->write();
} elseif ($this->action == 'r') {
$this->read();
}
} | [
"public",
"function",
"main",
"(",
")",
"{",
"$",
"this",
"->",
"validateAttributes",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"action",
"==",
"'w'",
")",
"{",
"$",
"this",
"->",
"write",
"(",
")",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
... | Delegate the work.
{@inheritdoc} | [
"Delegate",
"the",
"work",
"."
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/tasks/ext/ManifestTask.php#L161-L170 | train |
phingofficial/phing | classes/phing/tasks/ext/ManifestTask.php | ManifestTask.hash | private function hash($msg, $algo)
{
if (extension_loaded('hash')) {
$algo = strtolower($algo);
if (in_array($algo, hash_algos())) {
return hash($algo, $this->salt . $msg);
}
}
if (extension_loaded('mhash')) {
$algo = strtoupper($algo);
if (defined('MHASH_' . $algo)) {
return mhash('MHASH_' . $algo, $this->salt . $msg);
}
}
switch (strtolower($algo)) {
case 'md5':
return md5($this->salt . $msg);
case 'crc32':
return abs(crc32($this->salt . $msg));
}
return false;
} | php | private function hash($msg, $algo)
{
if (extension_loaded('hash')) {
$algo = strtolower($algo);
if (in_array($algo, hash_algos())) {
return hash($algo, $this->salt . $msg);
}
}
if (extension_loaded('mhash')) {
$algo = strtoupper($algo);
if (defined('MHASH_' . $algo)) {
return mhash('MHASH_' . $algo, $this->salt . $msg);
}
}
switch (strtolower($algo)) {
case 'md5':
return md5($this->salt . $msg);
case 'crc32':
return abs(crc32($this->salt . $msg));
}
return false;
} | [
"private",
"function",
"hash",
"(",
"$",
"msg",
",",
"$",
"algo",
")",
"{",
"if",
"(",
"extension_loaded",
"(",
"'hash'",
")",
")",
"{",
"$",
"algo",
"=",
"strtolower",
"(",
"$",
"algo",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"algo",
",",
"ha... | Wrapper method for hash generation
Automatically selects extension
Falls back to built-in functions
@link http://www.php.net/mhash
@link http://www.php.net/hash
@param string $msg The string that should be hashed
@param string $algo Algorithm
@return mixed String on success, false if $algo is not available | [
"Wrapper",
"method",
"for",
"hash",
"generation",
"Automatically",
"selects",
"extension",
"Falls",
"back",
"to",
"built",
"-",
"in",
"functions"
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/tasks/ext/ManifestTask.php#L248-L274 | train |
phingofficial/phing | classes/phing/tasks/ext/ManifestTask.php | ManifestTask.hashFile | private function hashFile($file, $algo)
{
if (!file_exists($file)) {
return false;
}
$msg = file_get_contents($file);
return $this->hash($msg, $algo);
} | php | private function hashFile($file, $algo)
{
if (!file_exists($file)) {
return false;
}
$msg = file_get_contents($file);
return $this->hash($msg, $algo);
} | [
"private",
"function",
"hashFile",
"(",
"$",
"file",
",",
"$",
"algo",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"file",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"msg",
"=",
"file_get_contents",
"(",
"$",
"file",
")",
";",
"return"... | Hash a file's contents
@param string $file
@param string $algo
@return mixed String on success, false if $algo is not available | [
"Hash",
"a",
"file",
"s",
"contents"
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/tasks/ext/ManifestTask.php#L284-L293 | train |
phingofficial/phing | classes/phing/tasks/ext/WikiPublishTask.php | WikiPublishTask.init | public function init()
{
$this->cookiesFile = tempnam(sys_get_temp_dir(), 'WikiPublish.' . uniqid('', true) . '.cookies');
$this->curl = curl_init();
if (false === is_resource($this->curl)) {
throw new BuildException('Curl init failed (' . $this->apiUrl . ')');
}
curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($this->curl, CURLOPT_COOKIEJAR, $this->cookiesFile);
curl_setopt($this->curl, CURLOPT_COOKIEFILE, $this->cookiesFile);
} | php | public function init()
{
$this->cookiesFile = tempnam(sys_get_temp_dir(), 'WikiPublish.' . uniqid('', true) . '.cookies');
$this->curl = curl_init();
if (false === is_resource($this->curl)) {
throw new BuildException('Curl init failed (' . $this->apiUrl . ')');
}
curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($this->curl, CURLOPT_COOKIEJAR, $this->cookiesFile);
curl_setopt($this->curl, CURLOPT_COOKIEFILE, $this->cookiesFile);
} | [
"public",
"function",
"init",
"(",
")",
"{",
"$",
"this",
"->",
"cookiesFile",
"=",
"tempnam",
"(",
"sys_get_temp_dir",
"(",
")",
",",
"'WikiPublish.'",
".",
"uniqid",
"(",
"''",
",",
"true",
")",
".",
"'.cookies'",
")",
";",
"$",
"this",
"->",
"curl",... | Prepare CURL object
@throws BuildException | [
"Prepare",
"CURL",
"object"
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/tasks/ext/WikiPublishTask.php#L226-L238 | train |
phingofficial/phing | classes/phing/tasks/ext/WikiPublishTask.php | WikiPublishTask.callApiLogin | private function callApiLogin($token = null)
{
$postData = ['lgname' => $this->apiUser, 'lgpassword' => $this->apiPassword];
if (null !== $token) {
$postData['lgtoken'] = $token;
}
$result = $this->callApi('action=login', $postData);
try {
$this->checkApiResponseResult('login', $result);
} catch (BuildException $e) {
if (null !== $token) {
throw $e;
}
// if token is required then call login again with token
$this->checkApiResponseResult('login', $result, 'NeedToken');
if (isset($result['login']) && isset($result['login']['token'])) {
$this->callApiLogin($result['login']['token']);
} else {
throw $e;
}
}
} | php | private function callApiLogin($token = null)
{
$postData = ['lgname' => $this->apiUser, 'lgpassword' => $this->apiPassword];
if (null !== $token) {
$postData['lgtoken'] = $token;
}
$result = $this->callApi('action=login', $postData);
try {
$this->checkApiResponseResult('login', $result);
} catch (BuildException $e) {
if (null !== $token) {
throw $e;
}
// if token is required then call login again with token
$this->checkApiResponseResult('login', $result, 'NeedToken');
if (isset($result['login']) && isset($result['login']['token'])) {
$this->callApiLogin($result['login']['token']);
} else {
throw $e;
}
}
} | [
"private",
"function",
"callApiLogin",
"(",
"$",
"token",
"=",
"null",
")",
"{",
"$",
"postData",
"=",
"[",
"'lgname'",
"=>",
"$",
"this",
"->",
"apiUser",
",",
"'lgpassword'",
"=>",
"$",
"this",
"->",
"apiPassword",
"]",
";",
"if",
"(",
"null",
"!==",... | Call Wiki webapi login action
@param string|null $token
@throws BuildException | [
"Call",
"Wiki",
"webapi",
"login",
"action"
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/tasks/ext/WikiPublishTask.php#L286-L308 | train |
phingofficial/phing | classes/phing/tasks/ext/WikiPublishTask.php | WikiPublishTask.callApiEdit | private function callApiEdit()
{
$this->callApiTokens();
$result = $this->callApi('action=edit&token=' . urlencode($this->apiEditToken), $this->getApiEditData());
$this->checkApiResponseResult('edit', $result);
} | php | private function callApiEdit()
{
$this->callApiTokens();
$result = $this->callApi('action=edit&token=' . urlencode($this->apiEditToken), $this->getApiEditData());
$this->checkApiResponseResult('edit', $result);
} | [
"private",
"function",
"callApiEdit",
"(",
")",
"{",
"$",
"this",
"->",
"callApiTokens",
"(",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"callApi",
"(",
"'action=edit&token='",
".",
"urlencode",
"(",
"$",
"this",
"->",
"apiEditToken",
")",
",",
"$"... | Call Wiki webapi edit action | [
"Call",
"Wiki",
"webapi",
"edit",
"action"
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/tasks/ext/WikiPublishTask.php#L313-L318 | train |
phingofficial/phing | classes/phing/tasks/ext/WikiPublishTask.php | WikiPublishTask.getApiEditData | private function getApiEditData()
{
$result = [
'minor' => '',
];
if (null !== $this->title) {
$result['title'] = $this->title;
}
if (null !== $this->id) {
$result['pageid'] = $this->id;
}
$result[$this->modeMap[$this->mode]] = $this->content;
return $result;
} | php | private function getApiEditData()
{
$result = [
'minor' => '',
];
if (null !== $this->title) {
$result['title'] = $this->title;
}
if (null !== $this->id) {
$result['pageid'] = $this->id;
}
$result[$this->modeMap[$this->mode]] = $this->content;
return $result;
} | [
"private",
"function",
"getApiEditData",
"(",
")",
"{",
"$",
"result",
"=",
"[",
"'minor'",
"=>",
"''",
",",
"]",
";",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"title",
")",
"{",
"$",
"result",
"[",
"'title'",
"]",
"=",
"$",
"this",
"->",
"ti... | Return prepared data for Wiki webapi edit action
@return array | [
"Return",
"prepared",
"data",
"for",
"Wiki",
"webapi",
"edit",
"action"
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/tasks/ext/WikiPublishTask.php#L325-L339 | train |
phingofficial/phing | classes/phing/tasks/ext/WikiPublishTask.php | WikiPublishTask.callApiTokens | private function callApiTokens()
{
$result = $this->callApi('action=tokens&type=edit');
if (false == isset($result['tokens']) || false == isset($result['tokens']['edittoken'])) {
throw new BuildException('Wiki token not found');
}
$this->apiEditToken = $result['tokens']['edittoken'];
} | php | private function callApiTokens()
{
$result = $this->callApi('action=tokens&type=edit');
if (false == isset($result['tokens']) || false == isset($result['tokens']['edittoken'])) {
throw new BuildException('Wiki token not found');
}
$this->apiEditToken = $result['tokens']['edittoken'];
} | [
"private",
"function",
"callApiTokens",
"(",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"callApi",
"(",
"'action=tokens&type=edit'",
")",
";",
"if",
"(",
"false",
"==",
"isset",
"(",
"$",
"result",
"[",
"'tokens'",
"]",
")",
"||",
"false",
"==",
... | Call Wiki webapi tokens action
@throws BuildException | [
"Call",
"Wiki",
"webapi",
"tokens",
"action"
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/tasks/ext/WikiPublishTask.php#L346-L354 | train |
phingofficial/phing | classes/phing/tasks/ext/WikiPublishTask.php | WikiPublishTask.callApi | protected function callApi($queryString, $postData = null)
{
$this->setPostData($postData);
$url = $this->apiUrl . '?' . $queryString . '&format=php';
curl_setopt($this->curl, CURLOPT_URL, $url);
$response = curl_exec($this->curl);
$responseCode = curl_getinfo($this->curl, CURLINFO_HTTP_CODE);
if (200 !== $responseCode) {
throw new BuildException('Wiki webapi call failed (http response ' . $responseCode . ')');
}
$result = @unserialize($response);
if (false === $result) {
throw new BuildException('Couldn\'t unserialize Wiki webapi response');
}
return $result;
} | php | protected function callApi($queryString, $postData = null)
{
$this->setPostData($postData);
$url = $this->apiUrl . '?' . $queryString . '&format=php';
curl_setopt($this->curl, CURLOPT_URL, $url);
$response = curl_exec($this->curl);
$responseCode = curl_getinfo($this->curl, CURLINFO_HTTP_CODE);
if (200 !== $responseCode) {
throw new BuildException('Wiki webapi call failed (http response ' . $responseCode . ')');
}
$result = @unserialize($response);
if (false === $result) {
throw new BuildException('Couldn\'t unserialize Wiki webapi response');
}
return $result;
} | [
"protected",
"function",
"callApi",
"(",
"$",
"queryString",
",",
"$",
"postData",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"setPostData",
"(",
"$",
"postData",
")",
";",
"$",
"url",
"=",
"$",
"this",
"->",
"apiUrl",
".",
"'?'",
".",
"$",
"queryStri... | Call Wiki webapi
@param string $queryString
@param array|null $postData
@return array
@throws BuildException | [
"Call",
"Wiki",
"webapi"
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/tasks/ext/WikiPublishTask.php#L365-L386 | train |
phingofficial/phing | classes/phing/tasks/ext/WikiPublishTask.php | WikiPublishTask.setPostData | private function setPostData($data = null)
{
if (null === $data) {
curl_setopt($this->curl, CURLOPT_POST, false);
return;
}
$postData = '';
foreach ($data as $key => $value) {
$postData .= urlencode($key) . '=' . urlencode($value) . '&';
}
if ($postData != '') {
curl_setopt($this->curl, CURLOPT_POST, true);
curl_setopt($this->curl, CURLOPT_POSTFIELDS, substr($postData, 0, -1));
}
} | php | private function setPostData($data = null)
{
if (null === $data) {
curl_setopt($this->curl, CURLOPT_POST, false);
return;
}
$postData = '';
foreach ($data as $key => $value) {
$postData .= urlencode($key) . '=' . urlencode($value) . '&';
}
if ($postData != '') {
curl_setopt($this->curl, CURLOPT_POST, true);
curl_setopt($this->curl, CURLOPT_POSTFIELDS, substr($postData, 0, -1));
}
} | [
"private",
"function",
"setPostData",
"(",
"$",
"data",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"data",
")",
"{",
"curl_setopt",
"(",
"$",
"this",
"->",
"curl",
",",
"CURLOPT_POST",
",",
"false",
")",
";",
"return",
";",
"}",
"$",
"po... | Set POST data for curl call
@param array|null $data | [
"Set",
"POST",
"data",
"for",
"curl",
"call"
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/tasks/ext/WikiPublishTask.php#L393-L408 | train |
phingofficial/phing | classes/phing/tasks/ext/WikiPublishTask.php | WikiPublishTask.checkApiResponseResult | private function checkApiResponseResult($action, $response, $expect = 'Success')
{
if (isset($response['error'])) {
throw new BuildException(
'Wiki response error (action: ' . $action . ', error code: ' . $response['error']['code'] . ')'
);
}
if (false == isset($response[$action]) || false == isset($response[$action]['result'])) {
throw new BuildException('Wiki response result not found (action: ' . $action . ')');
}
if ($response[$action]['result'] !== $expect) {
throw new BuildException(
'Unexpected Wiki response result ' . $response[$action]['result'] . ' (expected: ' . $expect . ')'
);
}
} | php | private function checkApiResponseResult($action, $response, $expect = 'Success')
{
if (isset($response['error'])) {
throw new BuildException(
'Wiki response error (action: ' . $action . ', error code: ' . $response['error']['code'] . ')'
);
}
if (false == isset($response[$action]) || false == isset($response[$action]['result'])) {
throw new BuildException('Wiki response result not found (action: ' . $action . ')');
}
if ($response[$action]['result'] !== $expect) {
throw new BuildException(
'Unexpected Wiki response result ' . $response[$action]['result'] . ' (expected: ' . $expect . ')'
);
}
} | [
"private",
"function",
"checkApiResponseResult",
"(",
"$",
"action",
",",
"$",
"response",
",",
"$",
"expect",
"=",
"'Success'",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"response",
"[",
"'error'",
"]",
")",
")",
"{",
"throw",
"new",
"BuildException",
"("... | Validate Wiki webapi response
@param string $action
@param array $response
@param string $expect
@throws BuildException | [
"Validate",
"Wiki",
"webapi",
"response"
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/tasks/ext/WikiPublishTask.php#L419-L434 | train |
phingofficial/phing | classes/phing/util/StringHelper.php | StringHelper.unqualify | public static function unqualify($qualifiedName, $separator = '.')
{
// if false, then will be 0
$pos = strrpos($qualifiedName, $separator);
if ($pos === false) {
return $qualifiedName; // there is no '.' in the qualifed name
} else {
return substr($qualifiedName, $pos + 1); // start just after '.'
}
} | php | public static function unqualify($qualifiedName, $separator = '.')
{
// if false, then will be 0
$pos = strrpos($qualifiedName, $separator);
if ($pos === false) {
return $qualifiedName; // there is no '.' in the qualifed name
} else {
return substr($qualifiedName, $pos + 1); // start just after '.'
}
} | [
"public",
"static",
"function",
"unqualify",
"(",
"$",
"qualifiedName",
",",
"$",
"separator",
"=",
"'.'",
")",
"{",
"// if false, then will be 0",
"$",
"pos",
"=",
"strrpos",
"(",
"$",
"qualifiedName",
",",
"$",
"separator",
")",
";",
"if",
"(",
"$",
"pos... | Remove qualification to name.
E.g. eg.Cat -> Cat
@param string $qualifiedName
@param string $separator Character used to separate.
@return string | [
"Remove",
"qualification",
"to",
"name",
".",
"E",
".",
"g",
".",
"eg",
".",
"Cat",
"-",
">",
"Cat"
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/util/StringHelper.php#L52-L61 | train |
phingofficial/phing | classes/phing/util/StringHelper.php | StringHelper.isBoolean | public static function isBoolean($s)
{
if (is_bool($s)) {
return true; // it already is boolean
}
if ($s === "" || $s === null || !is_string($s)) {
return false; // not a valid string for testing
}
$test = strtolower(trim($s));
return in_array($test, array_merge(self::$FALSE_VALUES, self::$TRUE_VALUES), true);
} | php | public static function isBoolean($s)
{
if (is_bool($s)) {
return true; // it already is boolean
}
if ($s === "" || $s === null || !is_string($s)) {
return false; // not a valid string for testing
}
$test = strtolower(trim($s));
return in_array($test, array_merge(self::$FALSE_VALUES, self::$TRUE_VALUES), true);
} | [
"public",
"static",
"function",
"isBoolean",
"(",
"$",
"s",
")",
"{",
"if",
"(",
"is_bool",
"(",
"$",
"s",
")",
")",
"{",
"return",
"true",
";",
"// it already is boolean",
"}",
"if",
"(",
"$",
"s",
"===",
"\"\"",
"||",
"$",
"s",
"===",
"null",
"||... | tests if a string is a representative of a boolean
@param bool|string $s
@return bool | [
"tests",
"if",
"a",
"string",
"is",
"a",
"representative",
"of",
"a",
"boolean"
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/util/StringHelper.php#L86-L99 | train |
phingofficial/phing | classes/phing/util/StringHelper.php | StringHelper.startsWith | public static function startsWith($check, $string)
{
if ($check === "" || $check === $string) {
return true;
} else {
return strpos($string, $check) === 0;
}
} | php | public static function startsWith($check, $string)
{
if ($check === "" || $check === $string) {
return true;
} else {
return strpos($string, $check) === 0;
}
} | [
"public",
"static",
"function",
"startsWith",
"(",
"$",
"check",
",",
"$",
"string",
")",
"{",
"if",
"(",
"$",
"check",
"===",
"\"\"",
"||",
"$",
"check",
"===",
"$",
"string",
")",
"{",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"strpos",
... | tests if a string starts with a given string
@param $check
@param $string
@return bool | [
"tests",
"if",
"a",
"string",
"starts",
"with",
"a",
"given",
"string"
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/util/StringHelper.php#L109-L116 | train |
phingofficial/phing | classes/phing/util/StringHelper.php | StringHelper.substring | public static function substring($string, $startpos, $endpos = -1)
{
$len = strlen($string);
$endpos = (int) (($endpos === -1) ? $len - 1 : $endpos);
if ($startpos > $len - 1 || $startpos < 0) {
trigger_error("substring(), Startindex out of bounds must be 0<n<$len", E_USER_ERROR);
}
if ($endpos > $len - 1 || $endpos < $startpos) {
trigger_error("substring(), Endindex out of bounds must be $startpos<n<" . ($len - 1), E_USER_ERROR);
}
if ($startpos === $endpos) {
return (string) $string{$startpos};
} else {
$len = $endpos - $startpos;
}
return substr($string, $startpos, $len + 1);
} | php | public static function substring($string, $startpos, $endpos = -1)
{
$len = strlen($string);
$endpos = (int) (($endpos === -1) ? $len - 1 : $endpos);
if ($startpos > $len - 1 || $startpos < 0) {
trigger_error("substring(), Startindex out of bounds must be 0<n<$len", E_USER_ERROR);
}
if ($endpos > $len - 1 || $endpos < $startpos) {
trigger_error("substring(), Endindex out of bounds must be $startpos<n<" . ($len - 1), E_USER_ERROR);
}
if ($startpos === $endpos) {
return (string) $string{$startpos};
} else {
$len = $endpos - $startpos;
}
return substr($string, $startpos, $len + 1);
} | [
"public",
"static",
"function",
"substring",
"(",
"$",
"string",
",",
"$",
"startpos",
",",
"$",
"endpos",
"=",
"-",
"1",
")",
"{",
"$",
"len",
"=",
"strlen",
"(",
"$",
"string",
")",
";",
"$",
"endpos",
"=",
"(",
"int",
")",
"(",
"(",
"$",
"en... | a natural way of getting a subtring, php's circular string buffer and strange
return values suck if you want to program strict as of C or friends
@param string $string
@param int $startpos
@param int $endpos
@return string | [
"a",
"natural",
"way",
"of",
"getting",
"a",
"subtring",
"php",
"s",
"circular",
"string",
"buffer",
"and",
"strange",
"return",
"values",
"suck",
"if",
"you",
"want",
"to",
"program",
"strict",
"as",
"of",
"C",
"or",
"friends"
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/util/StringHelper.php#L145-L162 | train |
phingofficial/phing | classes/phing/tasks/ext/pdo/XMLPDOResultFormatter.php | XMLPDOResultFormatter.close | public function close()
{
$this->out->write($this->doc->saveXML());
$this->rootNode = null;
$this->doc = null;
parent::close();
} | php | public function close()
{
$this->out->write($this->doc->saveXML());
$this->rootNode = null;
$this->doc = null;
parent::close();
} | [
"public",
"function",
"close",
"(",
")",
"{",
"$",
"this",
"->",
"out",
"->",
"write",
"(",
"$",
"this",
"->",
"doc",
"->",
"saveXML",
"(",
")",
")",
";",
"$",
"this",
"->",
"rootNode",
"=",
"null",
";",
"$",
"this",
"->",
"doc",
"=",
"null",
"... | Write XML to file and free the DOM objects. | [
"Write",
"XML",
"to",
"file",
"and",
"free",
"the",
"DOM",
"objects",
"."
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/tasks/ext/pdo/XMLPDOResultFormatter.php#L137-L143 | train |
phingofficial/phing | classes/phing/tasks/ext/FileSyncTask.php | FileSyncTask.executeCommand | public function executeCommand()
{
if ($this->rsyncPath === null) {
throw new BuildException('The "rsyncPath" attribute is missing or undefined.');
}
if ($this->sourceDir === null) {
throw new BuildException('The "sourcedir" attribute is missing or undefined.');
} else {
if ($this->destinationDir === null) {
throw new BuildException('The "destinationdir" attribute is missing or undefined.');
}
}
if (strpos($this->destinationDir, ':')) {
$this->setIsRemoteConnection(true);
}
if (strpos($this->sourceDir, ':')) {
if ($this->isRemoteConnection) {
throw new BuildException('The source and destination cannot both be remote.');
}
$this->setIsRemoteConnection(true);
} else {
if (!(is_dir($this->sourceDir) && is_readable($this->sourceDir))) {
throw new BuildException('No such file or directory: ' . $this->sourceDir);
}
}
if ($this->backupDir !== null && $this->backupDir == $this->destinationDir) {
throw new BuildException("Invalid backup directory: " . $this->backupDir);
}
$command = $this->getCommand();
$output = [];
$return = null;
exec($command, $output, $return);
$lines = '';
foreach ($output as $line) {
if (!empty($line)) {
$lines .= "\r\n" . "\t\t\t" . $line;
}
}
$this->log($command);
if ($return != 0) {
$this->log('Task exited with code: ' . $return, Project::MSG_ERR);
$this->log(
'Task exited with message: (' . $return . ') ' . $this->getErrorMessage($return),
Project::MSG_ERR
);
throw new BuildException($return . ': ' . $this->getErrorMessage($return));
} else {
$this->log($lines, Project::MSG_INFO);
}
return $return;
} | php | public function executeCommand()
{
if ($this->rsyncPath === null) {
throw new BuildException('The "rsyncPath" attribute is missing or undefined.');
}
if ($this->sourceDir === null) {
throw new BuildException('The "sourcedir" attribute is missing or undefined.');
} else {
if ($this->destinationDir === null) {
throw new BuildException('The "destinationdir" attribute is missing or undefined.');
}
}
if (strpos($this->destinationDir, ':')) {
$this->setIsRemoteConnection(true);
}
if (strpos($this->sourceDir, ':')) {
if ($this->isRemoteConnection) {
throw new BuildException('The source and destination cannot both be remote.');
}
$this->setIsRemoteConnection(true);
} else {
if (!(is_dir($this->sourceDir) && is_readable($this->sourceDir))) {
throw new BuildException('No such file or directory: ' . $this->sourceDir);
}
}
if ($this->backupDir !== null && $this->backupDir == $this->destinationDir) {
throw new BuildException("Invalid backup directory: " . $this->backupDir);
}
$command = $this->getCommand();
$output = [];
$return = null;
exec($command, $output, $return);
$lines = '';
foreach ($output as $line) {
if (!empty($line)) {
$lines .= "\r\n" . "\t\t\t" . $line;
}
}
$this->log($command);
if ($return != 0) {
$this->log('Task exited with code: ' . $return, Project::MSG_ERR);
$this->log(
'Task exited with message: (' . $return . ') ' . $this->getErrorMessage($return),
Project::MSG_ERR
);
throw new BuildException($return . ': ' . $this->getErrorMessage($return));
} else {
$this->log($lines, Project::MSG_INFO);
}
return $return;
} | [
"public",
"function",
"executeCommand",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"rsyncPath",
"===",
"null",
")",
"{",
"throw",
"new",
"BuildException",
"(",
"'The \"rsyncPath\" attribute is missing or undefined.'",
")",
";",
"}",
"if",
"(",
"$",
"this",
"... | Executes the rsync command and returns the exit code.
@return int Return code from execution.
@throws BuildException | [
"Executes",
"the",
"rsync",
"command",
"and",
"returns",
"the",
"exit",
"code",
"."
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/tasks/ext/FileSyncTask.php#L216-L276 | train |
phingofficial/phing | classes/phing/tasks/ext/FileSyncTask.php | FileSyncTask.getCommand | public function getCommand()
{
$options = $this->defaultOptions;
if ($this->options !== null) {
$options = $this->options;
}
if ($this->verbose === true) {
$options .= ' --verbose';
}
if ($this->checksum === true) {
$options .= ' --checksum';
}
if ($this->identityFile !== null) {
$options .= ' -e "ssh -i ' . $this->identityFile . ' -p' . $this->remotePort . '"';
} else {
if ($this->remoteShell !== null) {
$options .= ' -e "' . $this->remoteShell . '"';
}
}
if ($this->dryRun === true) {
$options .= ' --dry-run';
}
if ($this->delete === true) {
$options .= ' --delete-after --ignore-errors --force';
}
if ($this->itemizeChanges === true) {
$options .= ' --itemize-changes';
}
if ($this->backupDir !== null) {
$options .= ' -b --backup-dir="' . $this->backupDir . '"';
}
if ($this->exclude !== null) {
//remove trailing comma if any
$this->exclude = trim($this->exclude, ',');
$options .= ' --exclude="' . str_replace(',', '" --exclude="', $this->exclude) . '"';
}
if ($this->excludeFile !== null) {
$options .= ' --exclude-from="' . $this->excludeFile . '"';
}
$this->setOptions($options);
$options .= ' "' . $this->sourceDir . '" "' . $this->destinationDir . '"';
escapeshellcmd($options);
$options .= ' 2>&1';
return $this->rsyncPath . ' ' . $options;
} | php | public function getCommand()
{
$options = $this->defaultOptions;
if ($this->options !== null) {
$options = $this->options;
}
if ($this->verbose === true) {
$options .= ' --verbose';
}
if ($this->checksum === true) {
$options .= ' --checksum';
}
if ($this->identityFile !== null) {
$options .= ' -e "ssh -i ' . $this->identityFile . ' -p' . $this->remotePort . '"';
} else {
if ($this->remoteShell !== null) {
$options .= ' -e "' . $this->remoteShell . '"';
}
}
if ($this->dryRun === true) {
$options .= ' --dry-run';
}
if ($this->delete === true) {
$options .= ' --delete-after --ignore-errors --force';
}
if ($this->itemizeChanges === true) {
$options .= ' --itemize-changes';
}
if ($this->backupDir !== null) {
$options .= ' -b --backup-dir="' . $this->backupDir . '"';
}
if ($this->exclude !== null) {
//remove trailing comma if any
$this->exclude = trim($this->exclude, ',');
$options .= ' --exclude="' . str_replace(',', '" --exclude="', $this->exclude) . '"';
}
if ($this->excludeFile !== null) {
$options .= ' --exclude-from="' . $this->excludeFile . '"';
}
$this->setOptions($options);
$options .= ' "' . $this->sourceDir . '" "' . $this->destinationDir . '"';
escapeshellcmd($options);
$options .= ' 2>&1';
return $this->rsyncPath . ' ' . $options;
} | [
"public",
"function",
"getCommand",
"(",
")",
"{",
"$",
"options",
"=",
"$",
"this",
"->",
"defaultOptions",
";",
"if",
"(",
"$",
"this",
"->",
"options",
"!==",
"null",
")",
"{",
"$",
"options",
"=",
"$",
"this",
"->",
"options",
";",
"}",
"if",
"... | Returns the rsync command line options.
@return string | [
"Returns",
"the",
"rsync",
"command",
"line",
"options",
"."
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/tasks/ext/FileSyncTask.php#L283-L340 | train |
phingofficial/phing | classes/phing/tasks/ext/FileSyncTask.php | FileSyncTask.getErrorMessage | public function getErrorMessage($code)
{
$error[0] = 'Success';
$error[1] = 'Syntax or usage error';
$error[2] = 'Protocol incompatibility';
$error[3] = 'Errors selecting input/output files, dirs';
$error[4] = 'Requested action not supported: an attempt was made to manipulate '
. '64-bit files on a platform that cannot support them; or an option '
. 'was specified that is supported by the client and not by the server';
$error[5] = 'Error starting client-server protocol';
$error[10] = 'Error in socket I/O';
$error[11] = 'Error in file I/O';
$error[12] = 'Error in rsync protocol data stream';
$error[13] = 'Errors with program diagnostics';
$error[14] = 'Error in IPC code';
$error[20] = 'Received SIGUSR1 or SIGINT';
$error[21] = 'Some error returned by waitpid()';
$error[22] = 'Error allocating core memory buffers';
$error[23] = 'Partial transfer due to error';
$error[24] = 'Partial transfer due to vanished source files';
$error[30] = 'Timeout in data send/receive';
if (array_key_exists($code, $error)) {
return $error[$code];
}
return null;
} | php | public function getErrorMessage($code)
{
$error[0] = 'Success';
$error[1] = 'Syntax or usage error';
$error[2] = 'Protocol incompatibility';
$error[3] = 'Errors selecting input/output files, dirs';
$error[4] = 'Requested action not supported: an attempt was made to manipulate '
. '64-bit files on a platform that cannot support them; or an option '
. 'was specified that is supported by the client and not by the server';
$error[5] = 'Error starting client-server protocol';
$error[10] = 'Error in socket I/O';
$error[11] = 'Error in file I/O';
$error[12] = 'Error in rsync protocol data stream';
$error[13] = 'Errors with program diagnostics';
$error[14] = 'Error in IPC code';
$error[20] = 'Received SIGUSR1 or SIGINT';
$error[21] = 'Some error returned by waitpid()';
$error[22] = 'Error allocating core memory buffers';
$error[23] = 'Partial transfer due to error';
$error[24] = 'Partial transfer due to vanished source files';
$error[30] = 'Timeout in data send/receive';
if (array_key_exists($code, $error)) {
return $error[$code];
}
return null;
} | [
"public",
"function",
"getErrorMessage",
"(",
"$",
"code",
")",
"{",
"$",
"error",
"[",
"0",
"]",
"=",
"'Success'",
";",
"$",
"error",
"[",
"1",
"]",
"=",
"'Syntax or usage error'",
";",
"$",
"error",
"[",
"2",
"]",
"=",
"'Protocol incompatibility'",
";"... | Returns an error message based on a given error code.
@param int $code Error code
@return null|string | [
"Returns",
"an",
"error",
"message",
"based",
"on",
"a",
"given",
"error",
"code",
"."
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/tasks/ext/FileSyncTask.php#L348-L375 | train |
phingofficial/phing | classes/phing/util/FileUtils.php | FileUtils.getChainedReader | public static function getChainedReader(Reader $in, &$filterChains, Project $project)
{
if (!empty($filterChains)) {
$crh = new ChainReaderHelper();
$crh->setBufferSize(65536); // 64k buffer, but isn't being used (yet?)
$crh->setPrimaryReader($in);
$crh->setFilterChains($filterChains);
$crh->setProject($project);
$rdr = $crh->getAssembledReader();
return $rdr;
} else {
return $in;
}
} | php | public static function getChainedReader(Reader $in, &$filterChains, Project $project)
{
if (!empty($filterChains)) {
$crh = new ChainReaderHelper();
$crh->setBufferSize(65536); // 64k buffer, but isn't being used (yet?)
$crh->setPrimaryReader($in);
$crh->setFilterChains($filterChains);
$crh->setProject($project);
$rdr = $crh->getAssembledReader();
return $rdr;
} else {
return $in;
}
} | [
"public",
"static",
"function",
"getChainedReader",
"(",
"Reader",
"$",
"in",
",",
"&",
"$",
"filterChains",
",",
"Project",
"$",
"project",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"filterChains",
")",
")",
"{",
"$",
"crh",
"=",
"new",
"ChainReade... | Returns a new Reader with filterchains applied. If filterchains are empty,
simply returns passed reader.
@param Reader $in Reader to modify (if appropriate).
@param array &$filterChains filter chains to apply.
@param Project $project
@return Reader Assembled Reader (w/ filter chains). | [
"Returns",
"a",
"new",
"Reader",
"with",
"filterchains",
"applied",
".",
"If",
"filterchains",
"are",
"empty",
"simply",
"returns",
"passed",
"reader",
"."
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/util/FileUtils.php#L59-L73 | train |
phingofficial/phing | classes/phing/util/FileUtils.php | FileUtils.copyFile | public function copyFile(
PhingFile $sourceFile,
PhingFile $destFile,
Project $project,
$overwrite = false,
$preserveLastModified = true,
&$filterChains = null,
$mode = 0755,
$preservePermissions = true
) {
if ($overwrite || !$destFile->exists() || $destFile->lastModified() < $sourceFile->lastModified()) {
if ($destFile->exists() && ($destFile->isFile() || $destFile->isLink())) {
$destFile->delete();
}
// ensure that parent dir of dest file exists!
$parent = $destFile->getParentFile();
if ($parent !== null && !$parent->exists()) {
// Setting source directory permissions to target
// (On permissions preservation, the target directory permissions
// will be inherited from the source directory, otherwise the 'mode'
// will be used)
$dirMode = ($preservePermissions ? $sourceFile->getParentFile()->getMode() : $mode);
$parent->mkdirs($dirMode);
}
if ((is_array($filterChains)) && (!empty($filterChains))) {
$in = self::getChainedReader(new BufferedReader(new FileReader($sourceFile)), $filterChains, $project);
$out = new BufferedWriter(new FileWriter($destFile));
// New read() methods returns a big buffer.
while (-1 !== ($buffer = $in->read())) { // -1 indicates EOF
$out->write($buffer);
}
if ($in !== null) {
$in->close();
}
if ($out !== null) {
$out->close();
}
// Set/Copy the permissions on the target
if ($preservePermissions === true) {
$destFile->setMode($sourceFile->getMode());
}
} else {
// simple copy (no filtering)
$sourceFile->copyTo($destFile);
// By default, PHP::Copy also copies the file permissions. Therefore,
// re-setting the mode with the "user file-creation mask" information.
if ($preservePermissions === false) {
$destFile->setMode(FileUtils::getDefaultFileCreationMask(false));
}
}
if ($preserveLastModified && !$destFile->isLink()) {
$destFile->setLastModified($sourceFile->lastModified());
}
}
} | php | public function copyFile(
PhingFile $sourceFile,
PhingFile $destFile,
Project $project,
$overwrite = false,
$preserveLastModified = true,
&$filterChains = null,
$mode = 0755,
$preservePermissions = true
) {
if ($overwrite || !$destFile->exists() || $destFile->lastModified() < $sourceFile->lastModified()) {
if ($destFile->exists() && ($destFile->isFile() || $destFile->isLink())) {
$destFile->delete();
}
// ensure that parent dir of dest file exists!
$parent = $destFile->getParentFile();
if ($parent !== null && !$parent->exists()) {
// Setting source directory permissions to target
// (On permissions preservation, the target directory permissions
// will be inherited from the source directory, otherwise the 'mode'
// will be used)
$dirMode = ($preservePermissions ? $sourceFile->getParentFile()->getMode() : $mode);
$parent->mkdirs($dirMode);
}
if ((is_array($filterChains)) && (!empty($filterChains))) {
$in = self::getChainedReader(new BufferedReader(new FileReader($sourceFile)), $filterChains, $project);
$out = new BufferedWriter(new FileWriter($destFile));
// New read() methods returns a big buffer.
while (-1 !== ($buffer = $in->read())) { // -1 indicates EOF
$out->write($buffer);
}
if ($in !== null) {
$in->close();
}
if ($out !== null) {
$out->close();
}
// Set/Copy the permissions on the target
if ($preservePermissions === true) {
$destFile->setMode($sourceFile->getMode());
}
} else {
// simple copy (no filtering)
$sourceFile->copyTo($destFile);
// By default, PHP::Copy also copies the file permissions. Therefore,
// re-setting the mode with the "user file-creation mask" information.
if ($preservePermissions === false) {
$destFile->setMode(FileUtils::getDefaultFileCreationMask(false));
}
}
if ($preserveLastModified && !$destFile->isLink()) {
$destFile->setLastModified($sourceFile->lastModified());
}
}
} | [
"public",
"function",
"copyFile",
"(",
"PhingFile",
"$",
"sourceFile",
",",
"PhingFile",
"$",
"destFile",
",",
"Project",
"$",
"project",
",",
"$",
"overwrite",
"=",
"false",
",",
"$",
"preserveLastModified",
"=",
"true",
",",
"&",
"$",
"filterChains",
"=",
... | Copies a file using filter chains.
@param PhingFile $sourceFile
@param PhingFile $destFile
@param boolean $overwrite
@param boolean $preserveLastModified
@param array $filterChains
@param Project $project
@param integer $mode
@param bool $preservePermissions
@throws Exception
@throws IOException
@return void | [
"Copies",
"a",
"file",
"using",
"filter",
"chains",
"."
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/util/FileUtils.php#L90-L152 | train |
phingofficial/phing | classes/phing/util/FileUtils.php | FileUtils.renameFile | public function renameFile(PhingFile $sourceFile, PhingFile $destFile, $overwrite = false)
{
// ensure that parent dir of dest file exists!
$parent = $destFile->getParentFile();
if ($parent !== null) {
if (!$parent->exists()) {
$parent->mkdirs();
}
}
if ($overwrite || !$destFile->exists() || $destFile->lastModified() < $sourceFile->lastModified()) {
if ($destFile->exists()) {
try {
$destFile->delete();
} catch (Exception $e) {
throw new BuildException(
"Unable to remove existing file " . $destFile->__toString() . ": " . $e->getMessage()
);
}
}
}
$sourceFile->renameTo($destFile);
} | php | public function renameFile(PhingFile $sourceFile, PhingFile $destFile, $overwrite = false)
{
// ensure that parent dir of dest file exists!
$parent = $destFile->getParentFile();
if ($parent !== null) {
if (!$parent->exists()) {
$parent->mkdirs();
}
}
if ($overwrite || !$destFile->exists() || $destFile->lastModified() < $sourceFile->lastModified()) {
if ($destFile->exists()) {
try {
$destFile->delete();
} catch (Exception $e) {
throw new BuildException(
"Unable to remove existing file " . $destFile->__toString() . ": " . $e->getMessage()
);
}
}
}
$sourceFile->renameTo($destFile);
} | [
"public",
"function",
"renameFile",
"(",
"PhingFile",
"$",
"sourceFile",
",",
"PhingFile",
"$",
"destFile",
",",
"$",
"overwrite",
"=",
"false",
")",
"{",
"// ensure that parent dir of dest file exists!",
"$",
"parent",
"=",
"$",
"destFile",
"->",
"getParentFile",
... | Attempts to rename a file from a source to a destination.
If overwrite is set to true, this method overwrites existing file even if the destination file is newer.
Otherwise, the source file is renamed only if the destination file is older than it.
@param PhingFile $sourceFile
@param PhingFile $destFile
@return boolean | [
"Attempts",
"to",
"rename",
"a",
"file",
"from",
"a",
"source",
"to",
"a",
"destination",
".",
"If",
"overwrite",
"is",
"set",
"to",
"true",
"this",
"method",
"overwrites",
"existing",
"file",
"even",
"if",
"the",
"destination",
"file",
"is",
"newer",
".",... | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/util/FileUtils.php#L164-L187 | train |
phingofficial/phing | classes/phing/util/FileUtils.php | FileUtils.resolveFile | public function resolveFile($file, $filename)
{
// remove this and use the static class constant File::separator
// as soon as ZE2 is ready
$fs = FileSystem::getFileSystem();
$filename = str_replace(array('\\', '/'), $fs->getSeparator(), $filename);
// deal with absolute files
if (StringHelper::startsWith($fs->getSeparator(), $filename)
|| (strlen($filename) >= 2 && Character::isLetter($filename{0}) && $filename{1} === ':')
) {
return new PhingFile($this->normalize($filename));
}
if (strlen($filename) >= 2 && Character::isLetter($filename{0}) && $filename{1} === ':') {
return new PhingFile($this->normalize($filename));
}
$helpFile = new PhingFile($file->getAbsolutePath());
$tok = strtok($filename, $fs->getSeparator());
while ($tok !== false) {
$part = $tok;
if ($part === '..') {
$parentFile = $helpFile->getParent();
if ($parentFile === null) {
$msg = "The file or path you specified ($filename) is invalid relative to " . $file->getPath();
throw new IOException($msg);
}
$helpFile = new PhingFile($parentFile);
} else {
if ($part === '.') {
// Do nothing here
} else {
$helpFile = new PhingFile($helpFile, $part);
}
}
$tok = strtok($fs->getSeparator());
}
return new PhingFile($helpFile->getAbsolutePath());
} | php | public function resolveFile($file, $filename)
{
// remove this and use the static class constant File::separator
// as soon as ZE2 is ready
$fs = FileSystem::getFileSystem();
$filename = str_replace(array('\\', '/'), $fs->getSeparator(), $filename);
// deal with absolute files
if (StringHelper::startsWith($fs->getSeparator(), $filename)
|| (strlen($filename) >= 2 && Character::isLetter($filename{0}) && $filename{1} === ':')
) {
return new PhingFile($this->normalize($filename));
}
if (strlen($filename) >= 2 && Character::isLetter($filename{0}) && $filename{1} === ':') {
return new PhingFile($this->normalize($filename));
}
$helpFile = new PhingFile($file->getAbsolutePath());
$tok = strtok($filename, $fs->getSeparator());
while ($tok !== false) {
$part = $tok;
if ($part === '..') {
$parentFile = $helpFile->getParent();
if ($parentFile === null) {
$msg = "The file or path you specified ($filename) is invalid relative to " . $file->getPath();
throw new IOException($msg);
}
$helpFile = new PhingFile($parentFile);
} else {
if ($part === '.') {
// Do nothing here
} else {
$helpFile = new PhingFile($helpFile, $part);
}
}
$tok = strtok($fs->getSeparator());
}
return new PhingFile($helpFile->getAbsolutePath());
} | [
"public",
"function",
"resolveFile",
"(",
"$",
"file",
",",
"$",
"filename",
")",
"{",
"// remove this and use the static class constant File::separator",
"// as soon as ZE2 is ready",
"$",
"fs",
"=",
"FileSystem",
"::",
"getFileSystem",
"(",
")",
";",
"$",
"filename",
... | Interpret the filename as a file relative to the given file -
unless the filename already represents an absolute filename.
@param PhingFile $file the "reference" file for relative paths. This
instance must be an absolute file and must
not contain ./ or ../ sequences (same for \
instead of /).
@param string $filename a file name
@throws IOException
@return PhingFile A PhingFile object pointing to an absolute file that doesn't contain ./ or ../ sequences
and uses the correct separator for the current platform. | [
"Interpret",
"the",
"filename",
"as",
"a",
"file",
"relative",
"to",
"the",
"given",
"file",
"-",
"unless",
"the",
"filename",
"already",
"represents",
"an",
"absolute",
"filename",
"."
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/util/FileUtils.php#L204-L246 | train |
phingofficial/phing | classes/phing/util/FileUtils.php | FileUtils.createTempFile | public function createTempFile(
$prefix,
$suffix,
PhingFile $parentDir = null,
$deleteOnExit = false,
$createFile = false
) {
$result = null;
$parent = ($parentDir === null) ? sys_get_temp_dir() : $parentDir->getPath();
if ($createFile) {
try {
$result = PhingFile::createTempFile($prefix, $suffix, new PhingFile($parent));
} catch (IOException $e) {
throw new BuildException("Could not create tempfile in " . $parent, $e);
}
} else {
do {
$result = new PhingFile($parent, $prefix . substr(md5((string) time()), 0, 8) . $suffix);
} while ($result->exists());
}
if ($deleteOnExit) {
$result->deleteOnExit();
}
return $result;
} | php | public function createTempFile(
$prefix,
$suffix,
PhingFile $parentDir = null,
$deleteOnExit = false,
$createFile = false
) {
$result = null;
$parent = ($parentDir === null) ? sys_get_temp_dir() : $parentDir->getPath();
if ($createFile) {
try {
$result = PhingFile::createTempFile($prefix, $suffix, new PhingFile($parent));
} catch (IOException $e) {
throw new BuildException("Could not create tempfile in " . $parent, $e);
}
} else {
do {
$result = new PhingFile($parent, $prefix . substr(md5((string) time()), 0, 8) . $suffix);
} while ($result->exists());
}
if ($deleteOnExit) {
$result->deleteOnExit();
}
return $result;
} | [
"public",
"function",
"createTempFile",
"(",
"$",
"prefix",
",",
"$",
"suffix",
",",
"PhingFile",
"$",
"parentDir",
"=",
"null",
",",
"$",
"deleteOnExit",
"=",
"false",
",",
"$",
"createFile",
"=",
"false",
")",
"{",
"$",
"result",
"=",
"null",
";",
"$... | Create a temporary file in a given directory.
<p>The file denoted by the returned abstract pathname did not
exist before this method was invoked, any subsequent invocation
of this method will yield a different file name.</p>
@param string $prefix prefix before the random number.
@param string $suffix file extension; include the '.'.
@param PhingFile $parentDir Directory to create the temporary file in;
sys_get_temp_dir() used if not specified.
@param boolean $deleteOnExit whether to set the tempfile for deletion on
normal exit.
@param boolean $createFile true if the file must actually be created. If false
chances exist that a file with the same name is
created in the time between invoking this method
and the moment the file is actually created. If
possible set to true.
@return PhingFile a File reference to the new temporary file.
@throws BuildException | [
"Create",
"a",
"temporary",
"file",
"in",
"a",
"given",
"directory",
"."
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/util/FileUtils.php#L384-L411 | train |
phingofficial/phing | classes/phing/dispatch/DispatchUtils.php | DispatchUtils.main | public static function main($task)
{
$methodName = "main";
$dispatchable = null;
try {
if ($task instanceof Dispatchable) {
$dispatchable = $task;
} elseif ($task instanceof UnknownElement) {
$ue = $task;
$realThing = $ue->getRealThing();
if ($realThing != null && $realThing instanceof Dispatchable && $realThing instanceof Task) {
$dispatchable = $realThing;
}
}
if ($dispatchable != null) {
$mName = null;
$name = trim($dispatchable->getActionParameterName());
if (empty($name)) {
throw new BuildException(
"Action Parameter Name must not be empty for Dispatchable Task."
);
}
$mName = "get" . ucfirst($name);
try {
$c = new ReflectionClass($dispatchable);
$actionM = $c->getMethod($mName);
$o = $actionM->invoke($dispatchable);
$methodName = trim((string) $o);
if (empty($methodName)) {
throw new ReflectionException();
}
} catch (ReflectionException $re) {
throw new BuildException(
"Dispatchable Task attribute '" . $name . "' not set or value is empty."
);
}
$executeM = $c->getMethod($methodName);
$executeM->invoke($dispatchable);
if ($task instanceof UnknownElement) {
$task->setRealThing(null);
}
} else {
try {
$refl = new ReflectionClass($task);
$executeM = $refl->getMethod($methodName);
} catch (ReflectionException $re) {
throw new BuildException("No public " . $methodName . "() in " . get_class($task));
}
$executeM->invoke($task);
if ($task instanceof UnknownElement) {
$task->setRealThing(null);
}
}
} catch (ReflectionException $e) {
throw new BuildException($e);
}
} | php | public static function main($task)
{
$methodName = "main";
$dispatchable = null;
try {
if ($task instanceof Dispatchable) {
$dispatchable = $task;
} elseif ($task instanceof UnknownElement) {
$ue = $task;
$realThing = $ue->getRealThing();
if ($realThing != null && $realThing instanceof Dispatchable && $realThing instanceof Task) {
$dispatchable = $realThing;
}
}
if ($dispatchable != null) {
$mName = null;
$name = trim($dispatchable->getActionParameterName());
if (empty($name)) {
throw new BuildException(
"Action Parameter Name must not be empty for Dispatchable Task."
);
}
$mName = "get" . ucfirst($name);
try {
$c = new ReflectionClass($dispatchable);
$actionM = $c->getMethod($mName);
$o = $actionM->invoke($dispatchable);
$methodName = trim((string) $o);
if (empty($methodName)) {
throw new ReflectionException();
}
} catch (ReflectionException $re) {
throw new BuildException(
"Dispatchable Task attribute '" . $name . "' not set or value is empty."
);
}
$executeM = $c->getMethod($methodName);
$executeM->invoke($dispatchable);
if ($task instanceof UnknownElement) {
$task->setRealThing(null);
}
} else {
try {
$refl = new ReflectionClass($task);
$executeM = $refl->getMethod($methodName);
} catch (ReflectionException $re) {
throw new BuildException("No public " . $methodName . "() in " . get_class($task));
}
$executeM->invoke($task);
if ($task instanceof UnknownElement) {
$task->setRealThing(null);
}
}
} catch (ReflectionException $e) {
throw new BuildException($e);
}
} | [
"public",
"static",
"function",
"main",
"(",
"$",
"task",
")",
"{",
"$",
"methodName",
"=",
"\"main\"",
";",
"$",
"dispatchable",
"=",
"null",
";",
"try",
"{",
"if",
"(",
"$",
"task",
"instanceof",
"Dispatchable",
")",
"{",
"$",
"dispatchable",
"=",
"$... | Determines and Executes the action method for the task.
@param object $task the task to execute.
@throws BuildException on error. | [
"Determines",
"and",
"Executes",
"the",
"action",
"method",
"for",
"the",
"task",
"."
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/dispatch/DispatchUtils.php#L34-L92 | train |
phingofficial/phing | classes/phing/tasks/ext/phpunit/FormatterElement.php | FormatterElement.setToDir | public function setToDir($toDir)
{
if (!is_dir($toDir)) {
$toDir = new PhingFile($toDir);
$toDir->mkdirs();
}
$this->toDir = $toDir;
} | php | public function setToDir($toDir)
{
if (!is_dir($toDir)) {
$toDir = new PhingFile($toDir);
$toDir->mkdirs();
}
$this->toDir = $toDir;
} | [
"public",
"function",
"setToDir",
"(",
"$",
"toDir",
")",
"{",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"toDir",
")",
")",
"{",
"$",
"toDir",
"=",
"new",
"PhingFile",
"(",
"$",
"toDir",
")",
";",
"$",
"toDir",
"->",
"mkdirs",
"(",
")",
";",
"}",
"$"... | Sets output directory
@param string $toDir | [
"Sets",
"output",
"directory"
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/tasks/ext/phpunit/FormatterElement.php#L99-L107 | train |
phingofficial/phing | classes/phing/tasks/ext/phpunit/FormatterElement.php | FormatterElement.getOutfile | public function getOutfile()
{
if ($this->outfile) {
return $this->outfile;
} else {
return $this->formatter->getPreferredOutfile() . $this->getExtension();
}
} | php | public function getOutfile()
{
if ($this->outfile) {
return $this->outfile;
} else {
return $this->formatter->getPreferredOutfile() . $this->getExtension();
}
} | [
"public",
"function",
"getOutfile",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"outfile",
")",
"{",
"return",
"$",
"this",
"->",
"outfile",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"formatter",
"->",
"getPreferredOutfile",
"(",
")",
".",
... | Returns output filename
@return string | [
"Returns",
"output",
"filename"
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/tasks/ext/phpunit/FormatterElement.php#L134-L141 | train |
phingofficial/phing | classes/phing/tasks/ext/SymlinkTask.php | SymlinkTask.symlink | protected function symlink($target, $link)
{
$fs = FileSystem::getFileSystem();
if ($this->isRelative()) {
$link = (new PhingFile($link))->getAbsolutePath();
$target = rtrim($this->makePathRelative($target, dirname($link)), '/');
}
if (is_link($link) && @readlink($link) == $target) {
$this->log('Link exists: ' . $link, Project::MSG_INFO);
return true;
}
if (file_exists($link) || is_link($link)) {
if (!$this->getOverwrite()) {
$this->log('Not overwriting existing link ' . $link, Project::MSG_ERR);
return false;
}
if (is_link($link) || is_file($link)) {
$fs->unlink($link);
$this->log('Link removed: ' . $link, Project::MSG_INFO);
} else {
$fs->rmdir($link, true);
$this->log('Directory removed: ' . $link, Project::MSG_INFO);
}
}
$this->log('Linking: ' . $target . ' to ' . $link, Project::MSG_INFO);
return $fs->symlink($target, $link);
} | php | protected function symlink($target, $link)
{
$fs = FileSystem::getFileSystem();
if ($this->isRelative()) {
$link = (new PhingFile($link))->getAbsolutePath();
$target = rtrim($this->makePathRelative($target, dirname($link)), '/');
}
if (is_link($link) && @readlink($link) == $target) {
$this->log('Link exists: ' . $link, Project::MSG_INFO);
return true;
}
if (file_exists($link) || is_link($link)) {
if (!$this->getOverwrite()) {
$this->log('Not overwriting existing link ' . $link, Project::MSG_ERR);
return false;
}
if (is_link($link) || is_file($link)) {
$fs->unlink($link);
$this->log('Link removed: ' . $link, Project::MSG_INFO);
} else {
$fs->rmdir($link, true);
$this->log('Directory removed: ' . $link, Project::MSG_INFO);
}
}
$this->log('Linking: ' . $target . ' to ' . $link, Project::MSG_INFO);
return $fs->symlink($target, $link);
} | [
"protected",
"function",
"symlink",
"(",
"$",
"target",
",",
"$",
"link",
")",
"{",
"$",
"fs",
"=",
"FileSystem",
"::",
"getFileSystem",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isRelative",
"(",
")",
")",
"{",
"$",
"link",
"=",
"(",
"new",
... | Create the actual link
@param string $target
@param string $link
@return bool | [
"Create",
"the",
"actual",
"link"
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/tasks/ext/SymlinkTask.php#L330-L364 | train |
phingofficial/phing | classes/phing/tasks/ext/PhpCodeSnifferTask.php | PhpCodeSnifferTask.setStandard | public function setStandard($standards)
{
$this->standards = [];
$token = ' ,;';
$ext = strtok($standards, $token);
while ($ext !== false) {
$this->standards[] = $ext;
$ext = strtok($token);
}
} | php | public function setStandard($standards)
{
$this->standards = [];
$token = ' ,;';
$ext = strtok($standards, $token);
while ($ext !== false) {
$this->standards[] = $ext;
$ext = strtok($token);
}
} | [
"public",
"function",
"setStandard",
"(",
"$",
"standards",
")",
"{",
"$",
"this",
"->",
"standards",
"=",
"[",
"]",
";",
"$",
"token",
"=",
"' ,;'",
";",
"$",
"ext",
"=",
"strtok",
"(",
"$",
"standards",
",",
"$",
"token",
")",
";",
"while",
"(",
... | Sets the coding standard to test for
@param string $standards The coding standards
@return void | [
"Sets",
"the",
"coding",
"standard",
"to",
"test",
"for"
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/tasks/ext/PhpCodeSnifferTask.php#L114-L123 | train |
phingofficial/phing | classes/phing/tasks/ext/PhpCodeSnifferTask.php | PhpCodeSnifferTask.setSniffs | public function setSniffs($sniffs)
{
$token = ' ,;';
$sniff = strtok($sniffs, $token);
while ($sniff !== false) {
$this->sniffs[] = $sniff;
$sniff = strtok($token);
}
} | php | public function setSniffs($sniffs)
{
$token = ' ,;';
$sniff = strtok($sniffs, $token);
while ($sniff !== false) {
$this->sniffs[] = $sniff;
$sniff = strtok($token);
}
} | [
"public",
"function",
"setSniffs",
"(",
"$",
"sniffs",
")",
"{",
"$",
"token",
"=",
"' ,;'",
";",
"$",
"sniff",
"=",
"strtok",
"(",
"$",
"sniffs",
",",
"$",
"token",
")",
";",
"while",
"(",
"$",
"sniff",
"!==",
"false",
")",
"{",
"$",
"this",
"->... | Sets the sniffs which the standard should be restricted to
@param string $sniffs | [
"Sets",
"the",
"sniffs",
"which",
"the",
"standard",
"should",
"be",
"restricted",
"to"
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/tasks/ext/PhpCodeSnifferTask.php#L130-L138 | train |
phingofficial/phing | classes/phing/tasks/ext/PhpCodeSnifferTask.php | PhpCodeSnifferTask.setAllowedFileExtensions | public function setAllowedFileExtensions($extensions)
{
$this->allowedFileExtensions = [];
$token = ' ,;';
$ext = strtok($extensions, $token);
while ($ext !== false) {
$this->allowedFileExtensions[] = $ext;
$ext = strtok($token);
}
} | php | public function setAllowedFileExtensions($extensions)
{
$this->allowedFileExtensions = [];
$token = ' ,;';
$ext = strtok($extensions, $token);
while ($ext !== false) {
$this->allowedFileExtensions[] = $ext;
$ext = strtok($token);
}
} | [
"public",
"function",
"setAllowedFileExtensions",
"(",
"$",
"extensions",
")",
"{",
"$",
"this",
"->",
"allowedFileExtensions",
"=",
"[",
"]",
";",
"$",
"token",
"=",
"' ,;'",
";",
"$",
"ext",
"=",
"strtok",
"(",
"$",
"extensions",
",",
"$",
"token",
")"... | Sets the allowed file extensions when using directories instead of specific files
@param array $extensions | [
"Sets",
"the",
"allowed",
"file",
"extensions",
"when",
"using",
"directories",
"instead",
"of",
"specific",
"files"
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/tasks/ext/PhpCodeSnifferTask.php#L233-L242 | train |
phingofficial/phing | classes/phing/tasks/ext/PhpCodeSnifferTask.php | PhpCodeSnifferTask.getFilesToParse | protected function getFilesToParse()
{
$filesToParse = [];
if ($this->file instanceof PhingFile) {
$filesToParse[] = $this->file->getPath();
} else {
// append any files in filesets
foreach ($this->filesets as $fs) {
$dir = $fs->getDir($this->project)->getAbsolutePath();
foreach ($fs->getDirectoryScanner($this->project)->getIncludedFiles() as $filename) {
$fileAbsolutePath = $dir . DIRECTORY_SEPARATOR . $filename;
if ($this->cache) {
$lastMTime = $this->cache->get($fileAbsolutePath);
$currentMTime = filemtime($fileAbsolutePath);
if ($lastMTime >= $currentMTime) {
continue;
} else {
$this->cache->put($fileAbsolutePath, $currentMTime);
}
}
$filesToParse[] = $fileAbsolutePath;
}
}
}
return $filesToParse;
} | php | protected function getFilesToParse()
{
$filesToParse = [];
if ($this->file instanceof PhingFile) {
$filesToParse[] = $this->file->getPath();
} else {
// append any files in filesets
foreach ($this->filesets as $fs) {
$dir = $fs->getDir($this->project)->getAbsolutePath();
foreach ($fs->getDirectoryScanner($this->project)->getIncludedFiles() as $filename) {
$fileAbsolutePath = $dir . DIRECTORY_SEPARATOR . $filename;
if ($this->cache) {
$lastMTime = $this->cache->get($fileAbsolutePath);
$currentMTime = filemtime($fileAbsolutePath);
if ($lastMTime >= $currentMTime) {
continue;
} else {
$this->cache->put($fileAbsolutePath, $currentMTime);
}
}
$filesToParse[] = $fileAbsolutePath;
}
}
}
return $filesToParse;
} | [
"protected",
"function",
"getFilesToParse",
"(",
")",
"{",
"$",
"filesToParse",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"file",
"instanceof",
"PhingFile",
")",
"{",
"$",
"filesToParse",
"[",
"]",
"=",
"$",
"this",
"->",
"file",
"->",
"getPath... | Return the list of files to parse
@return string[] list of absolute files to parse | [
"Return",
"the",
"list",
"of",
"files",
"to",
"parse"
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/tasks/ext/PhpCodeSnifferTask.php#L397-L423 | train |
phingofficial/phing | classes/phing/tasks/ext/PhpCodeSnifferTask.php | PhpCodeSnifferTask.printErrorReport | protected function printErrorReport($phpcs)
{
$sniffs = $phpcs->getSniffs();
$sniffStr = '';
foreach ($sniffs as $sniff) {
if (is_string($sniff)) {
$sniffStr .= '- ' . $sniff . PHP_EOL;
} else {
$sniffStr .= '- ' . get_class($sniff) . PHP_EOL;
}
}
$this->project->setProperty($this->getPropertyName(), (string) $sniffStr);
if ($this->showSniffs) {
$this->log('The list of used sniffs (#' . count($sniffs) . '): ' . PHP_EOL . $sniffStr, Project::MSG_INFO);
}
// process output
$reporting = $phpcs->reporting;
foreach ($this->formatters as $fe) {
$reportFile = null;
if ($fe->getUseFile()) {
$reportFile = $fe->getOutfile();
//ob_start();
}
// Crude check, but they broke backwards compatibility
// with a minor version release.
if (PHP_CodeSniffer::VERSION >= '2.2.0') {
$cliValues = ['colors' => false];
$reporting->printReport(
$fe->getType(),
$this->showSources,
$cliValues,
$reportFile,
$this->reportWidth
);
} else {
$reporting->printReport(
$fe->getType(),
$this->showSources,
$reportFile,
$this->reportWidth
);
}
// reporting class uses ob_end_flush(), but we don't want
// an output if we use a file
if ($fe->getUseFile()) {
//ob_end_clean();
}
}
} | php | protected function printErrorReport($phpcs)
{
$sniffs = $phpcs->getSniffs();
$sniffStr = '';
foreach ($sniffs as $sniff) {
if (is_string($sniff)) {
$sniffStr .= '- ' . $sniff . PHP_EOL;
} else {
$sniffStr .= '- ' . get_class($sniff) . PHP_EOL;
}
}
$this->project->setProperty($this->getPropertyName(), (string) $sniffStr);
if ($this->showSniffs) {
$this->log('The list of used sniffs (#' . count($sniffs) . '): ' . PHP_EOL . $sniffStr, Project::MSG_INFO);
}
// process output
$reporting = $phpcs->reporting;
foreach ($this->formatters as $fe) {
$reportFile = null;
if ($fe->getUseFile()) {
$reportFile = $fe->getOutfile();
//ob_start();
}
// Crude check, but they broke backwards compatibility
// with a minor version release.
if (PHP_CodeSniffer::VERSION >= '2.2.0') {
$cliValues = ['colors' => false];
$reporting->printReport(
$fe->getType(),
$this->showSources,
$cliValues,
$reportFile,
$this->reportWidth
);
} else {
$reporting->printReport(
$fe->getType(),
$this->showSources,
$reportFile,
$this->reportWidth
);
}
// reporting class uses ob_end_flush(), but we don't want
// an output if we use a file
if ($fe->getUseFile()) {
//ob_end_clean();
}
}
} | [
"protected",
"function",
"printErrorReport",
"(",
"$",
"phpcs",
")",
"{",
"$",
"sniffs",
"=",
"$",
"phpcs",
"->",
"getSniffs",
"(",
")",
";",
"$",
"sniffStr",
"=",
"''",
";",
"foreach",
"(",
"$",
"sniffs",
"as",
"$",
"sniff",
")",
"{",
"if",
"(",
"... | Prints the error report.
@param PHP_CodeSniffer $phpcs The PHP_CodeSniffer object containing
the errors. | [
"Prints",
"the",
"error",
"report",
"."
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/tasks/ext/PhpCodeSnifferTask.php#L600-L653 | train |
phingofficial/phing | classes/phing/tasks/ext/PhpCodeSnifferTask.php | PhpCodeSnifferTask.outputCustomFormat | protected function outputCustomFormat($report)
{
$files = $report['files'];
foreach ($files as $file => $attributes) {
$errors = $attributes['errors'];
$warnings = $attributes['warnings'];
$messages = $attributes['messages'];
if ($errors > 0) {
$this->log(
$file . ': ' . $errors . ' error' . ($errors > 1 ? 's' : '') . ' detected',
Project::MSG_ERR
);
$this->outputCustomFormatMessages($messages, 'ERROR');
} else {
$this->log($file . ': No syntax errors detected', Project::MSG_VERBOSE);
}
if ($warnings > 0) {
$this->log(
$file . ': ' . $warnings . ' warning' . ($warnings > 1 ? 's' : '') . ' detected',
Project::MSG_WARN
);
$this->outputCustomFormatMessages($messages, 'WARNING');
}
}
$totalErrors = $report['totals']['errors'];
$totalWarnings = $report['totals']['warnings'];
$this->log(count($files) . ' files were checked', Project::MSG_INFO);
if ($totalErrors > 0) {
$this->log($totalErrors . ' error' . ($totalErrors > 1 ? 's' : '') . ' detected', Project::MSG_ERR);
} else {
$this->log('No syntax errors detected', Project::MSG_INFO);
}
if ($totalWarnings > 0) {
$this->log($totalWarnings . ' warning' . ($totalWarnings > 1 ? 's' : '') . ' detected', Project::MSG_INFO);
}
} | php | protected function outputCustomFormat($report)
{
$files = $report['files'];
foreach ($files as $file => $attributes) {
$errors = $attributes['errors'];
$warnings = $attributes['warnings'];
$messages = $attributes['messages'];
if ($errors > 0) {
$this->log(
$file . ': ' . $errors . ' error' . ($errors > 1 ? 's' : '') . ' detected',
Project::MSG_ERR
);
$this->outputCustomFormatMessages($messages, 'ERROR');
} else {
$this->log($file . ': No syntax errors detected', Project::MSG_VERBOSE);
}
if ($warnings > 0) {
$this->log(
$file . ': ' . $warnings . ' warning' . ($warnings > 1 ? 's' : '') . ' detected',
Project::MSG_WARN
);
$this->outputCustomFormatMessages($messages, 'WARNING');
}
}
$totalErrors = $report['totals']['errors'];
$totalWarnings = $report['totals']['warnings'];
$this->log(count($files) . ' files were checked', Project::MSG_INFO);
if ($totalErrors > 0) {
$this->log($totalErrors . ' error' . ($totalErrors > 1 ? 's' : '') . ' detected', Project::MSG_ERR);
} else {
$this->log('No syntax errors detected', Project::MSG_INFO);
}
if ($totalWarnings > 0) {
$this->log($totalWarnings . ' warning' . ($totalWarnings > 1 ? 's' : '') . ' detected', Project::MSG_INFO);
}
} | [
"protected",
"function",
"outputCustomFormat",
"(",
"$",
"report",
")",
"{",
"$",
"files",
"=",
"$",
"report",
"[",
"'files'",
"]",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
"=>",
"$",
"attributes",
")",
"{",
"$",
"errors",
"=",
"$",
"att... | Outputs the results with a custom format
@param array $report Packaged list of all errors in each file | [
"Outputs",
"the",
"results",
"with",
"a",
"custom",
"format"
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/tasks/ext/PhpCodeSnifferTask.php#L660-L696 | train |
phingofficial/phing | classes/phing/tasks/ext/PhpCodeSnifferTask.php | PhpCodeSnifferTask.outputCustomFormatMessages | protected function outputCustomFormatMessages($messages, $type)
{
foreach ($messages as $line => $messagesPerLine) {
foreach ($messagesPerLine as $column => $messagesPerColumn) {
foreach ($messagesPerColumn as $message) {
$msgType = $message['type'];
if ($type == $msgType) {
$logLevel = Project::MSG_INFO;
if ($msgType == 'ERROR') {
$logLevel = Project::MSG_ERR;
} else {
if ($msgType == 'WARNING') {
$logLevel = Project::MSG_WARN;
}
}
$text = $message['message'];
$string = $msgType . ' in line ' . $line . ' column ' . $column . ': ' . $text;
$this->log($string, $logLevel);
}
}
}
}
} | php | protected function outputCustomFormatMessages($messages, $type)
{
foreach ($messages as $line => $messagesPerLine) {
foreach ($messagesPerLine as $column => $messagesPerColumn) {
foreach ($messagesPerColumn as $message) {
$msgType = $message['type'];
if ($type == $msgType) {
$logLevel = Project::MSG_INFO;
if ($msgType == 'ERROR') {
$logLevel = Project::MSG_ERR;
} else {
if ($msgType == 'WARNING') {
$logLevel = Project::MSG_WARN;
}
}
$text = $message['message'];
$string = $msgType . ' in line ' . $line . ' column ' . $column . ': ' . $text;
$this->log($string, $logLevel);
}
}
}
}
} | [
"protected",
"function",
"outputCustomFormatMessages",
"(",
"$",
"messages",
",",
"$",
"type",
")",
"{",
"foreach",
"(",
"$",
"messages",
"as",
"$",
"line",
"=>",
"$",
"messagesPerLine",
")",
"{",
"foreach",
"(",
"$",
"messagesPerLine",
"as",
"$",
"column",
... | Outputs the messages of a specific type for one file
@param array $messages
@param string $type | [
"Outputs",
"the",
"messages",
"of",
"a",
"specific",
"type",
"for",
"one",
"file"
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/tasks/ext/PhpCodeSnifferTask.php#L704-L726 | train |
phingofficial/phing | classes/phing/tasks/ext/PearPackageTask.php | PearPackageTask.setOptions | protected function setOptions()
{
// 1) first prepare/populate options
$this->populateOptions();
// 2) make any final adjustments (this could move into populateOptions() also)
// default PEAR basedir would be the name of the package (e.g."phing")
if (!isset($this->preparedOptions['baseinstalldir'])) {
$this->preparedOptions['baseinstalldir'] = $this->package;
}
// unless filelistgenerator has been overridden, we use Phing FileSet generator
if (!isset($this->preparedOptions['filelistgenerator'])) {
if (empty($this->filesets)) {
throw new BuildException("You must use a <fileset> tag to specify the files to include in the package.xml");
}
$this->preparedOptions['filelistgenerator'] = 'Fileset';
$this->preparedOptions['usergeneratordir'] = __DIR__ . DIRECTORY_SEPARATOR . 'pearpackage';
// Some PHING-specific options needed by our Fileset reader
$this->preparedOptions['phing_project'] = $this->project;
$this->preparedOptions['phing_filesets'] = $this->filesets;
} elseif ($this->preparedOptions['filelistgenerator'] != 'Fileset' && !empty($this->filesets)) {
throw new BuildException("You cannot use <fileset> element if you have specified the \"filelistgenerator\" option.");
}
// 3) Set the options
// No need for excessive validation here, since the PEAR class will do its own
// validation & return errors
$e = $this->pkg->setOptions($this->preparedOptions);
if (@PEAR::isError($e)) {
throw new BuildException("Unable to set options.", new Exception($e->getMessage()));
}
// convert roles
foreach ($this->roles as $role) {
$this->pkg->addRole($role->getExtension(), $role->getRole());
}
} | php | protected function setOptions()
{
// 1) first prepare/populate options
$this->populateOptions();
// 2) make any final adjustments (this could move into populateOptions() also)
// default PEAR basedir would be the name of the package (e.g."phing")
if (!isset($this->preparedOptions['baseinstalldir'])) {
$this->preparedOptions['baseinstalldir'] = $this->package;
}
// unless filelistgenerator has been overridden, we use Phing FileSet generator
if (!isset($this->preparedOptions['filelistgenerator'])) {
if (empty($this->filesets)) {
throw new BuildException("You must use a <fileset> tag to specify the files to include in the package.xml");
}
$this->preparedOptions['filelistgenerator'] = 'Fileset';
$this->preparedOptions['usergeneratordir'] = __DIR__ . DIRECTORY_SEPARATOR . 'pearpackage';
// Some PHING-specific options needed by our Fileset reader
$this->preparedOptions['phing_project'] = $this->project;
$this->preparedOptions['phing_filesets'] = $this->filesets;
} elseif ($this->preparedOptions['filelistgenerator'] != 'Fileset' && !empty($this->filesets)) {
throw new BuildException("You cannot use <fileset> element if you have specified the \"filelistgenerator\" option.");
}
// 3) Set the options
// No need for excessive validation here, since the PEAR class will do its own
// validation & return errors
$e = $this->pkg->setOptions($this->preparedOptions);
if (@PEAR::isError($e)) {
throw new BuildException("Unable to set options.", new Exception($e->getMessage()));
}
// convert roles
foreach ($this->roles as $role) {
$this->pkg->addRole($role->getExtension(), $role->getRole());
}
} | [
"protected",
"function",
"setOptions",
"(",
")",
"{",
"// 1) first prepare/populate options",
"$",
"this",
"->",
"populateOptions",
"(",
")",
";",
"// 2) make any final adjustments (this could move into populateOptions() also)",
"// default PEAR basedir would be the name of the package... | Sets PEAR package.xml options, based on class properties.
@throws BuildException
@return void | [
"Sets",
"PEAR",
"package",
".",
"xml",
"options",
"based",
"on",
"class",
"properties",
"."
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/tasks/ext/PearPackageTask.php#L128-L169 | train |
phingofficial/phing | classes/phing/tasks/ext/PearPackageTask.php | PearPackageTask.fixDeps | private function fixDeps($deps)
{
foreach (array_keys($deps) as $dep) {
if (isset($deps[$dep]['optional']) && $deps[$dep]['optional']) {
$deps[$dep]['optional'] = "yes";
}
}
return $deps;
} | php | private function fixDeps($deps)
{
foreach (array_keys($deps) as $dep) {
if (isset($deps[$dep]['optional']) && $deps[$dep]['optional']) {
$deps[$dep]['optional'] = "yes";
}
}
return $deps;
} | [
"private",
"function",
"fixDeps",
"(",
"$",
"deps",
")",
"{",
"foreach",
"(",
"array_keys",
"(",
"$",
"deps",
")",
"as",
"$",
"dep",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"deps",
"[",
"$",
"dep",
"]",
"[",
"'optional'",
"]",
")",
"&&",
"$",
"... | Fixes the boolean in optional dependencies
@param $deps
@return | [
"Fixes",
"the",
"boolean",
"in",
"optional",
"dependencies"
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/tasks/ext/PearPackageTask.php#L177-L186 | train |
phingofficial/phing | classes/phing/tasks/ext/PearPackageTask.php | PearPackageTask.populateOptions | private function populateOptions()
{
// These values could be overridden if explicitly defined using nested tags
$this->preparedOptions['package'] = $this->package;
$this->preparedOptions['packagedirectory'] = $this->dir->getAbsolutePath();
if ($this->packageFile !== null) {
// create one w/ full path
$f = new PhingFile($this->packageFile->getAbsolutePath());
$this->preparedOptions['packagefile'] = $f->getName();
// must end in trailing slash
$this->preparedOptions['outputdirectory'] = $f->getParent() . DIRECTORY_SEPARATOR;
$this->log("Creating package file: " . $f->__toString(), Project::MSG_INFO);
} else {
$this->log("Creating [default] package.xml file in base directory.", Project::MSG_INFO);
}
// converts option objects and mapping objects into
// key => value options that can be passed to PEAR_PackageFileManager
foreach ($this->options as $opt) {
$this->preparedOptions[$opt->getName()] = $opt->getValue(); //no arrays yet. preg_split('/\s*,\s*/', $opt->getValue());
}
foreach ($this->mappings as $map) {
$value = $map->getValue(); // getValue returns complex value
if ($map->getName() == 'deps') {
$value = $this->fixDeps($value);
}
$this->preparedOptions[$map->getName()] = $value;
}
} | php | private function populateOptions()
{
// These values could be overridden if explicitly defined using nested tags
$this->preparedOptions['package'] = $this->package;
$this->preparedOptions['packagedirectory'] = $this->dir->getAbsolutePath();
if ($this->packageFile !== null) {
// create one w/ full path
$f = new PhingFile($this->packageFile->getAbsolutePath());
$this->preparedOptions['packagefile'] = $f->getName();
// must end in trailing slash
$this->preparedOptions['outputdirectory'] = $f->getParent() . DIRECTORY_SEPARATOR;
$this->log("Creating package file: " . $f->__toString(), Project::MSG_INFO);
} else {
$this->log("Creating [default] package.xml file in base directory.", Project::MSG_INFO);
}
// converts option objects and mapping objects into
// key => value options that can be passed to PEAR_PackageFileManager
foreach ($this->options as $opt) {
$this->preparedOptions[$opt->getName()] = $opt->getValue(); //no arrays yet. preg_split('/\s*,\s*/', $opt->getValue());
}
foreach ($this->mappings as $map) {
$value = $map->getValue(); // getValue returns complex value
if ($map->getName() == 'deps') {
$value = $this->fixDeps($value);
}
$this->preparedOptions[$map->getName()] = $value;
}
} | [
"private",
"function",
"populateOptions",
"(",
")",
"{",
"// These values could be overridden if explicitly defined using nested tags",
"$",
"this",
"->",
"preparedOptions",
"[",
"'package'",
"]",
"=",
"$",
"this",
"->",
"package",
";",
"$",
"this",
"->",
"preparedOptio... | Adds the options that are set via attributes and the nested tags to the options array. | [
"Adds",
"the",
"options",
"that",
"are",
"set",
"via",
"attributes",
"and",
"the",
"nested",
"tags",
"to",
"the",
"options",
"array",
"."
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/tasks/ext/PearPackageTask.php#L191-L225 | train |
phingofficial/phing | classes/phing/filters/EscapeUnicode.php | EscapeUnicode.read | public function read($len = null)
{
if (!$this->getInitialized()) {
$this->initialize();
$this->setInitialized(true);
}
// Process whole text at once.
$text = null;
while (($data = $this->in->read($len)) !== -1) {
$text .= $data;
}
// At the end.
if (null === $text) {
return -1;
}
$textArray = preg_split("~\R~", $text);
$lines = [];
foreach ($textArray as $offset => $line) {
$lines[] = trim(json_encode($line), '"');
if (strlen($line) !== strlen($lines[$offset])) {
$this->log(
"Escape unicode chars on line " . ($offset + 1)
. " from " . $line . " to " . $lines[$offset],
Project::MSG_VERBOSE
);
}
}
$escaped = implode(PHP_EOL, $lines);
return $escaped;
} | php | public function read($len = null)
{
if (!$this->getInitialized()) {
$this->initialize();
$this->setInitialized(true);
}
// Process whole text at once.
$text = null;
while (($data = $this->in->read($len)) !== -1) {
$text .= $data;
}
// At the end.
if (null === $text) {
return -1;
}
$textArray = preg_split("~\R~", $text);
$lines = [];
foreach ($textArray as $offset => $line) {
$lines[] = trim(json_encode($line), '"');
if (strlen($line) !== strlen($lines[$offset])) {
$this->log(
"Escape unicode chars on line " . ($offset + 1)
. " from " . $line . " to " . $lines[$offset],
Project::MSG_VERBOSE
);
}
}
$escaped = implode(PHP_EOL, $lines);
return $escaped;
} | [
"public",
"function",
"read",
"(",
"$",
"len",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"getInitialized",
"(",
")",
")",
"{",
"$",
"this",
"->",
"initialize",
"(",
")",
";",
"$",
"this",
"->",
"setInitialized",
"(",
"true",
")",
... | Returns the next line in the filtered stream, converting non latin
characters to unicode escapes.
@param int $len optional
@return string the converted lines in the resulting stream, or -1
if the end of the resulting stream has been reached
@throws IOException if the underlying stream throws
an IOException during reading | [
"Returns",
"the",
"next",
"line",
"in",
"the",
"filtered",
"stream",
"converting",
"non",
"latin",
"characters",
"to",
"unicode",
"escapes",
"."
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/filters/EscapeUnicode.php#L49-L84 | train |
phingofficial/phing | classes/phing/filters/EscapeUnicode.php | EscapeUnicode.chain | public function chain(Reader $rdr)
{
$newFilter = new EscapeUnicode($rdr);
$newFilter->setInitialized(true);
$newFilter->setProject($this->getProject());
return $newFilter;
} | php | public function chain(Reader $rdr)
{
$newFilter = new EscapeUnicode($rdr);
$newFilter->setInitialized(true);
$newFilter->setProject($this->getProject());
return $newFilter;
} | [
"public",
"function",
"chain",
"(",
"Reader",
"$",
"rdr",
")",
"{",
"$",
"newFilter",
"=",
"new",
"EscapeUnicode",
"(",
"$",
"rdr",
")",
";",
"$",
"newFilter",
"->",
"setInitialized",
"(",
"true",
")",
";",
"$",
"newFilter",
"->",
"setProject",
"(",
"$... | Creates a new EscapeUnicode using the passed in
Reader for instantiation.
@param Reader $rdr A Reader object providing the underlying stream.
Must not be <code>null</code>.
@return Reader a new filter based on this configuration, but filtering
the specified reader | [
"Creates",
"a",
"new",
"EscapeUnicode",
"using",
"the",
"passed",
"in",
"Reader",
"for",
"instantiation",
"."
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/filters/EscapeUnicode.php#L96-L103 | train |
phingofficial/phing | classes/phing/filters/ReplaceTokens.php | ReplaceTokens.replaceTokenCallback | private function replaceTokenCallback($matches)
{
$key = $matches[1];
/* Get tokens from tokensource and merge them with the
* tokens given directly via build file. This should be
* done a bit more elegantly
*/
if ($this->_alltokens === null) {
$this->_alltokens = [];
$count = count($this->_tokensources);
for ($i = 0; $i < $count; $i++) {
$source = $this->_tokensources[$i];
$this->_alltokens = array_merge($this->_alltokens, $source->getTokens());
}
$this->_alltokens = array_merge($this->_tokens, $this->_alltokens);
}
$tokens = $this->_alltokens;
$replaceWith = null;
$count = count($tokens);
for ($i = 0; $i < $count; $i++) {
if ($tokens[$i]->getKey() === $key) {
$replaceWith = $tokens[$i]->getValue();
}
}
if ($replaceWith === null) {
$replaceWith = $this->_beginToken . $key . $this->_endToken;
$this->log("No token defined for key \"" . $this->_beginToken . $key . $this->_endToken . "\"");
} else {
$this->log(
"Replaced \"" . $this->_beginToken . $key . $this->_endToken . "\" with \"" . $replaceWith . "\"",
Project::MSG_VERBOSE
);
}
return $replaceWith;
} | php | private function replaceTokenCallback($matches)
{
$key = $matches[1];
/* Get tokens from tokensource and merge them with the
* tokens given directly via build file. This should be
* done a bit more elegantly
*/
if ($this->_alltokens === null) {
$this->_alltokens = [];
$count = count($this->_tokensources);
for ($i = 0; $i < $count; $i++) {
$source = $this->_tokensources[$i];
$this->_alltokens = array_merge($this->_alltokens, $source->getTokens());
}
$this->_alltokens = array_merge($this->_tokens, $this->_alltokens);
}
$tokens = $this->_alltokens;
$replaceWith = null;
$count = count($tokens);
for ($i = 0; $i < $count; $i++) {
if ($tokens[$i]->getKey() === $key) {
$replaceWith = $tokens[$i]->getValue();
}
}
if ($replaceWith === null) {
$replaceWith = $this->_beginToken . $key . $this->_endToken;
$this->log("No token defined for key \"" . $this->_beginToken . $key . $this->_endToken . "\"");
} else {
$this->log(
"Replaced \"" . $this->_beginToken . $key . $this->_endToken . "\" with \"" . $replaceWith . "\"",
Project::MSG_VERBOSE
);
}
return $replaceWith;
} | [
"private",
"function",
"replaceTokenCallback",
"(",
"$",
"matches",
")",
"{",
"$",
"key",
"=",
"$",
"matches",
"[",
"1",
"]",
";",
"/* Get tokens from tokensource and merge them with the\n * tokens given directly via build file. This should be\n * done a bit more el... | Performs lookup on key and returns appropriate replacement string.
@param array $matches Array of 1 el containing key to search for.
@return string Text with which to replace key or value of key if none is found. | [
"Performs",
"lookup",
"on",
"key",
"and",
"returns",
"appropriate",
"replacement",
"string",
"."
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/filters/ReplaceTokens.php#L102-L144 | train |
phingofficial/phing | classes/phing/filters/ReplaceTokens.php | ReplaceTokens.chain | public function chain(Reader $reader)
{
$newFilter = new ReplaceTokens($reader);
$newFilter->setProject($this->getProject());
$newFilter->setBeginToken($this->getBeginToken());
$newFilter->setEndToken($this->getEndToken());
$newFilter->setTokens($this->getTokens());
$newFilter->setTokensources($this->getTokensources());
$newFilter->setInitialized(true);
return $newFilter;
} | php | public function chain(Reader $reader)
{
$newFilter = new ReplaceTokens($reader);
$newFilter->setProject($this->getProject());
$newFilter->setBeginToken($this->getBeginToken());
$newFilter->setEndToken($this->getEndToken());
$newFilter->setTokens($this->getTokens());
$newFilter->setTokensources($this->getTokensources());
$newFilter->setInitialized(true);
return $newFilter;
} | [
"public",
"function",
"chain",
"(",
"Reader",
"$",
"reader",
")",
"{",
"$",
"newFilter",
"=",
"new",
"ReplaceTokens",
"(",
"$",
"reader",
")",
";",
"$",
"newFilter",
"->",
"setProject",
"(",
"$",
"this",
"->",
"getProject",
"(",
")",
")",
";",
"$",
"... | Creates a new ReplaceTokens using the passed in
Reader for instantiation.
@param Reader $reader
@throws Exception
@internal param A $object Reader object providing the underlying stream.
Must not be <code>null</code>.
@return object A new filter based on this configuration, but filtering
the specified reader | [
"Creates",
"a",
"new",
"ReplaceTokens",
"using",
"the",
"passed",
"in",
"Reader",
"for",
"instantiation",
"."
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/filters/ReplaceTokens.php#L310-L321 | train |
phingofficial/phing | classes/phing/tasks/system/UpToDateTask.php | UpToDateTask.setSrcfile | public function setSrcfile($file)
{
if (is_string($file)) {
$file = new PhingFile($file);
}
$this->_sourceFile = $file;
} | php | public function setSrcfile($file)
{
if (is_string($file)) {
$file = new PhingFile($file);
}
$this->_sourceFile = $file;
} | [
"public",
"function",
"setSrcfile",
"(",
"$",
"file",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"file",
")",
")",
"{",
"$",
"file",
"=",
"new",
"PhingFile",
"(",
"$",
"file",
")",
";",
"}",
"$",
"this",
"->",
"_sourceFile",
"=",
"$",
"file",
";... | The file that must be older than the target file
if the property is to be set.
@param string|PhingFile $file the file we are checking against the target file. | [
"The",
"file",
"that",
"must",
"be",
"older",
"than",
"the",
"target",
"file",
"if",
"the",
"property",
"is",
"to",
"be",
"set",
"."
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/tasks/system/UpToDateTask.php#L117-L123 | train |
phingofficial/phing | classes/phing/parser/ProjectConfigurator.php | ProjectConfigurator.configureProject | public static function configureProject(Project $project, PhingFile $buildFile): void
{
(new self($project, $buildFile))->parse();
} | php | public static function configureProject(Project $project, PhingFile $buildFile): void
{
(new self($project, $buildFile))->parse();
} | [
"public",
"static",
"function",
"configureProject",
"(",
"Project",
"$",
"project",
",",
"PhingFile",
"$",
"buildFile",
")",
":",
"void",
"{",
"(",
"new",
"self",
"(",
"$",
"project",
",",
"$",
"buildFile",
")",
")",
"->",
"parse",
"(",
")",
";",
"}"
] | Static call to ProjectConfigurator. Use this to configure a
project. Do not use the new operator.
@param Project $project the Project instance this configurator should use
@param PhingFile $buildFile the buildfile object the parser should use
@throws \IOException
@throws \BuildException
@throws NullPointerException | [
"Static",
"call",
"to",
"ProjectConfigurator",
".",
"Use",
"this",
"to",
"configure",
"a",
"project",
".",
"Do",
"not",
"use",
"the",
"new",
"operator",
"."
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/parser/ProjectConfigurator.php#L72-L75 | train |
phingofficial/phing | classes/phing/parser/ProjectConfigurator.php | ProjectConfigurator.parse | protected function parse()
{
try {
// get parse context
$ctx = $this->project->getReference(self::PARSING_CONTEXT_REFERENCE);
if (null == $ctx) {
// make a new context and register it with project
$ctx = new PhingXMLContext($this->project);
$this->project->addReference(self::PARSING_CONTEXT_REFERENCE, $ctx);
}
//record this parse with context
$ctx->addImport($this->buildFile);
if (count($ctx->getImportStack()) > 1) {
$currentImplicit = $ctx->getImplicitTarget();
$currentTargets = $ctx->getCurrentTargets();
$newCurrent = new Target();
$newCurrent->setProject($this->project);
$newCurrent->setName('');
$ctx->setCurrentTargets([]);
$ctx->setImplicitTarget($newCurrent);
// this is an imported file
// modify project tag parse behavior
$this->setIgnoreProjectTag(true);
$this->_parse($ctx);
$newCurrent->main();
$ctx->setImplicitTarget($currentImplicit);
$ctx->setCurrentTargets($currentTargets);
} else {
$ctx->setCurrentTargets([]);
$this->_parse($ctx);
$ctx->getImplicitTarget()->main();
}
} catch (Exception $exc) {
//throw new BuildException("Error reading project file", $exc);
throw $exc;
}
} | php | protected function parse()
{
try {
// get parse context
$ctx = $this->project->getReference(self::PARSING_CONTEXT_REFERENCE);
if (null == $ctx) {
// make a new context and register it with project
$ctx = new PhingXMLContext($this->project);
$this->project->addReference(self::PARSING_CONTEXT_REFERENCE, $ctx);
}
//record this parse with context
$ctx->addImport($this->buildFile);
if (count($ctx->getImportStack()) > 1) {
$currentImplicit = $ctx->getImplicitTarget();
$currentTargets = $ctx->getCurrentTargets();
$newCurrent = new Target();
$newCurrent->setProject($this->project);
$newCurrent->setName('');
$ctx->setCurrentTargets([]);
$ctx->setImplicitTarget($newCurrent);
// this is an imported file
// modify project tag parse behavior
$this->setIgnoreProjectTag(true);
$this->_parse($ctx);
$newCurrent->main();
$ctx->setImplicitTarget($currentImplicit);
$ctx->setCurrentTargets($currentTargets);
} else {
$ctx->setCurrentTargets([]);
$this->_parse($ctx);
$ctx->getImplicitTarget()->main();
}
} catch (Exception $exc) {
//throw new BuildException("Error reading project file", $exc);
throw $exc;
}
} | [
"protected",
"function",
"parse",
"(",
")",
"{",
"try",
"{",
"// get parse context",
"$",
"ctx",
"=",
"$",
"this",
"->",
"project",
"->",
"getReference",
"(",
"self",
"::",
"PARSING_CONTEXT_REFERENCE",
")",
";",
"if",
"(",
"null",
"==",
"$",
"ctx",
")",
... | Creates the ExpatParser, sets root handler and kick off parsing
process.
@throws BuildException if there is any kind of exception during
the parsing process | [
"Creates",
"the",
"ExpatParser",
"sets",
"root",
"handler",
"and",
"kick",
"off",
"parsing",
"process",
"."
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/parser/ProjectConfigurator.php#L170-L211 | train |
phingofficial/phing | classes/phing/parser/ProjectConfigurator.php | ProjectConfigurator.configure | public static function configure($target, $attrs, Project $project)
{
if ($target instanceof TaskAdapter) {
$target = $target->getProxy();
}
// if the target is an UnknownElement, this means that the tag had not been registered
// when the enclosing element (task, target, etc.) was configured. It is possible, however,
// that the tag was registered (e.g. using <taskdef>) after the original configuration.
// ... so, try to load it again:
if ($target instanceof UnknownElement) {
$tryTarget = $project->createTask($target->getTaskType());
if ($tryTarget) {
$target = $tryTarget;
}
}
$bean = get_class($target);
$ih = IntrospectionHelper::getHelper($bean);
foreach ($attrs as $key => $value) {
if ($key == 'id') {
continue;
// throw new BuildException("Id must be set Extermnally");
}
$value = $project->replaceProperties($value);
try { // try to set the attribute
$ih->setAttribute($project, $target, strtolower($key), $value);
} catch (BuildException $be) {
// id attribute must be set externally
if ($key !== "id") {
throw $be;
}
}
}
} | php | public static function configure($target, $attrs, Project $project)
{
if ($target instanceof TaskAdapter) {
$target = $target->getProxy();
}
// if the target is an UnknownElement, this means that the tag had not been registered
// when the enclosing element (task, target, etc.) was configured. It is possible, however,
// that the tag was registered (e.g. using <taskdef>) after the original configuration.
// ... so, try to load it again:
if ($target instanceof UnknownElement) {
$tryTarget = $project->createTask($target->getTaskType());
if ($tryTarget) {
$target = $tryTarget;
}
}
$bean = get_class($target);
$ih = IntrospectionHelper::getHelper($bean);
foreach ($attrs as $key => $value) {
if ($key == 'id') {
continue;
// throw new BuildException("Id must be set Extermnally");
}
$value = $project->replaceProperties($value);
try { // try to set the attribute
$ih->setAttribute($project, $target, strtolower($key), $value);
} catch (BuildException $be) {
// id attribute must be set externally
if ($key !== "id") {
throw $be;
}
}
}
} | [
"public",
"static",
"function",
"configure",
"(",
"$",
"target",
",",
"$",
"attrs",
",",
"Project",
"$",
"project",
")",
"{",
"if",
"(",
"$",
"target",
"instanceof",
"TaskAdapter",
")",
"{",
"$",
"target",
"=",
"$",
"target",
"->",
"getProxy",
"(",
")"... | Configures an element and resolves eventually given properties.
@param mixed $target element to configure
@param array $attrs element's attributes
@param Project $project project this element belongs to
@throws BuildException
@throws Exception | [
"Configures",
"an",
"element",
"and",
"resolves",
"eventually",
"given",
"properties",
"."
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/parser/ProjectConfigurator.php#L258-L293 | train |
phingofficial/phing | classes/phing/parser/ProjectConfigurator.php | ProjectConfigurator.storeChild | public static function storeChild($project, $parent, $child, $tag)
{
$ih = IntrospectionHelper::getHelper(get_class($parent));
$ih->storeElement($project, $parent, $child, $tag);
} | php | public static function storeChild($project, $parent, $child, $tag)
{
$ih = IntrospectionHelper::getHelper(get_class($parent));
$ih->storeElement($project, $parent, $child, $tag);
} | [
"public",
"static",
"function",
"storeChild",
"(",
"$",
"project",
",",
"$",
"parent",
",",
"$",
"child",
",",
"$",
"tag",
")",
"{",
"$",
"ih",
"=",
"IntrospectionHelper",
"::",
"getHelper",
"(",
"get_class",
"(",
"$",
"parent",
")",
")",
";",
"$",
"... | Stores a configured child element into its parent object
@param object the project this element belongs to
@param object the parent element
@param object the child element
@param string the XML tagname | [
"Stores",
"a",
"configured",
"child",
"element",
"into",
"its",
"parent",
"object"
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/parser/ProjectConfigurator.php#L320-L324 | train |
phingofficial/phing | classes/phing/parser/ProjectConfigurator.php | ProjectConfigurator.configureId | public function configureId($target, $attr)
{
if (isset($attr['id']) && $attr['id'] !== null) {
$this->project->addReference($attr['id'], $target);
}
} | php | public function configureId($target, $attr)
{
if (isset($attr['id']) && $attr['id'] !== null) {
$this->project->addReference($attr['id'], $target);
}
} | [
"public",
"function",
"configureId",
"(",
"$",
"target",
",",
"$",
"attr",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"attr",
"[",
"'id'",
"]",
")",
"&&",
"$",
"attr",
"[",
"'id'",
"]",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"project",
"->",
... | Scan Attributes for the id attribute and maybe add a reference to
project.
@param object $target the element's object
@param array $attr the element's attributes | [
"Scan",
"Attributes",
"for",
"the",
"id",
"attribute",
"and",
"maybe",
"add",
"a",
"reference",
"to",
"project",
"."
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/parser/ProjectConfigurator.php#L333-L338 | train |
phingofficial/phing | classes/phing/parser/ProjectConfigurator.php | ProjectConfigurator.addLocationToBuildException | public static function addLocationToBuildException(BuildException $ex, Location $newLocation)
{
if ($ex->getLocation() === null || $ex->getMessage() === null) {
return $ex;
}
$errorMessage = sprintf(
"The following error occurred while executing this line:%s%s %s%s",
PHP_EOL,
$ex->getLocation(),
$ex->getMessage(),
PHP_EOL
);
if ($ex instanceof ExitStatusException) {
$exitStatus = $ex->getCode();
if ($newLocation === null) {
return new ExitStatusException($errorMessage, $exitStatus);
}
return new ExitStatusException($errorMessage, $exitStatus, $newLocation);
}
return new BuildException($errorMessage, $ex, $newLocation);
} | php | public static function addLocationToBuildException(BuildException $ex, Location $newLocation)
{
if ($ex->getLocation() === null || $ex->getMessage() === null) {
return $ex;
}
$errorMessage = sprintf(
"The following error occurred while executing this line:%s%s %s%s",
PHP_EOL,
$ex->getLocation(),
$ex->getMessage(),
PHP_EOL
);
if ($ex instanceof ExitStatusException) {
$exitStatus = $ex->getCode();
if ($newLocation === null) {
return new ExitStatusException($errorMessage, $exitStatus);
}
return new ExitStatusException($errorMessage, $exitStatus, $newLocation);
}
return new BuildException($errorMessage, $ex, $newLocation);
} | [
"public",
"static",
"function",
"addLocationToBuildException",
"(",
"BuildException",
"$",
"ex",
",",
"Location",
"$",
"newLocation",
")",
"{",
"if",
"(",
"$",
"ex",
"->",
"getLocation",
"(",
")",
"===",
"null",
"||",
"$",
"ex",
"->",
"getMessage",
"(",
")... | Add location to build exception.
@param BuildException $ex the build exception, if the build exception
does not include
@param Location $newLocation the location of the calling task (may be null)
@return BuildException a new build exception based in the build exception with
location set to newLocation. If the original exception
did not have a location, just return the build exception | [
"Add",
"location",
"to",
"build",
"exception",
"."
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/parser/ProjectConfigurator.php#L350-L371 | train |
phingofficial/phing | classes/phing/filters/TidyFilter.php | TidyFilter.getDistilledConfig | private function getDistilledConfig()
{
$config = [];
foreach ($this->configParameters as $p) {
$config[$p->getName()] = $p->getValue();
}
return $config;
} | php | private function getDistilledConfig()
{
$config = [];
foreach ($this->configParameters as $p) {
$config[$p->getName()] = $p->getValue();
}
return $config;
} | [
"private",
"function",
"getDistilledConfig",
"(",
")",
"{",
"$",
"config",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"configParameters",
"as",
"$",
"p",
")",
"{",
"$",
"config",
"[",
"$",
"p",
"->",
"getName",
"(",
")",
"]",
"=",
"$",
... | Converts the Parameter objects being used to store configuration into a simle assoc array.
@return array | [
"Converts",
"the",
"Parameter",
"objects",
"being",
"used",
"to",
"store",
"configuration",
"into",
"a",
"simle",
"assoc",
"array",
"."
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/filters/TidyFilter.php#L86-L94 | train |
phingofficial/phing | classes/phing/filters/TidyFilter.php | TidyFilter.read | public function read($len = null)
{
if (!class_exists('Tidy')) {
throw new BuildException("You must enable the 'tidy' extension in your PHP configuration in order to use the Tidy filter.");
}
if (!$this->getInitialized()) {
$this->_initialize();
$this->setInitialized(true);
}
$buffer = $this->in->read($len);
if ($buffer === -1) {
return -1;
}
$config = $this->getDistilledConfig();
$tidy = new Tidy();
$tidy->parseString($buffer, $config, $this->encoding);
$tidy->cleanRepair();
return tidy_get_output($tidy);
} | php | public function read($len = null)
{
if (!class_exists('Tidy')) {
throw new BuildException("You must enable the 'tidy' extension in your PHP configuration in order to use the Tidy filter.");
}
if (!$this->getInitialized()) {
$this->_initialize();
$this->setInitialized(true);
}
$buffer = $this->in->read($len);
if ($buffer === -1) {
return -1;
}
$config = $this->getDistilledConfig();
$tidy = new Tidy();
$tidy->parseString($buffer, $config, $this->encoding);
$tidy->cleanRepair();
return tidy_get_output($tidy);
} | [
"public",
"function",
"read",
"(",
"$",
"len",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"class_exists",
"(",
"'Tidy'",
")",
")",
"{",
"throw",
"new",
"BuildException",
"(",
"\"You must enable the 'tidy' extension in your PHP configuration in order to use the Tidy filter.\... | Reads input and returns Tidy-filtered output.
@param null $len
@throws BuildException
@return int the resulting stream, or -1 if the end of the resulting stream has been reached | [
"Reads",
"input",
"and",
"returns",
"Tidy",
"-",
"filtered",
"output",
"."
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/filters/TidyFilter.php#L103-L126 | train |
phingofficial/phing | classes/phing/filters/TidyFilter.php | TidyFilter.chain | public function chain(Reader $reader)
{
$newFilter = new TidyFilter($reader);
$newFilter->setConfigParameters($this->configParameters);
$newFilter->setEncoding($this->encoding);
$newFilter->setProject($this->getProject());
return $newFilter;
} | php | public function chain(Reader $reader)
{
$newFilter = new TidyFilter($reader);
$newFilter->setConfigParameters($this->configParameters);
$newFilter->setEncoding($this->encoding);
$newFilter->setProject($this->getProject());
return $newFilter;
} | [
"public",
"function",
"chain",
"(",
"Reader",
"$",
"reader",
")",
"{",
"$",
"newFilter",
"=",
"new",
"TidyFilter",
"(",
"$",
"reader",
")",
";",
"$",
"newFilter",
"->",
"setConfigParameters",
"(",
"$",
"this",
"->",
"configParameters",
")",
";",
"$",
"ne... | Creates a new TidyFilter using the passed in Reader for instantiation.
@param A|Reader $reader
@internal param A $reader Reader object providing the underlying stream.
Must not be <code>null</code>.
@return TidyFilter a new filter based on this configuration, but filtering the specified reader | [
"Creates",
"a",
"new",
"TidyFilter",
"using",
"the",
"passed",
"in",
"Reader",
"for",
"instantiation",
"."
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/filters/TidyFilter.php#L137-L145 | train |
phingofficial/phing | classes/phing/system/util/Register.php | Register.getSlot | public static function getSlot($key)
{
if (!isset(self::$slots[$key])) {
self::$slots[$key] = new RegisterSlot($key);
}
return self::$slots[$key];
} | php | public static function getSlot($key)
{
if (!isset(self::$slots[$key])) {
self::$slots[$key] = new RegisterSlot($key);
}
return self::$slots[$key];
} | [
"public",
"static",
"function",
"getSlot",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"slots",
"[",
"$",
"key",
"]",
")",
")",
"{",
"self",
"::",
"$",
"slots",
"[",
"$",
"key",
"]",
"=",
"new",
"RegisterSlot",
"... | Returns RegisterSlot for specified key.
If not slot exists a new one is created for key.
@param string $key
@return RegisterSlot | [
"Returns",
"RegisterSlot",
"for",
"specified",
"key",
"."
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/system/util/Register.php#L56-L63 | train |
phingofficial/phing | classes/phing/tasks/ext/TarTask.php | TarTask.createTarFileSet | public function createTarFileSet()
{
$this->fileset = new TarFileSet();
$this->filesets[] = $this->fileset;
return $this->fileset;
} | php | public function createTarFileSet()
{
$this->fileset = new TarFileSet();
$this->filesets[] = $this->fileset;
return $this->fileset;
} | [
"public",
"function",
"createTarFileSet",
"(",
")",
"{",
"$",
"this",
"->",
"fileset",
"=",
"new",
"TarFileSet",
"(",
")",
";",
"$",
"this",
"->",
"filesets",
"[",
"]",
"=",
"$",
"this",
"->",
"fileset",
";",
"return",
"$",
"this",
"->",
"fileset",
"... | Add a new fileset
@return FileSet | [
"Add",
"a",
"new",
"fileset"
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/tasks/ext/TarTask.php#L90-L96 | train |
phingofficial/phing | classes/phing/types/PearPackageFileSet.php | PearPackageFileSet.getDir | public function getDir(Project $p = null)
{
if ($p === null) {
$p = $this->getProject();
}
if ($this->pps === null) {
$this->loadPearPackageScanner($p);
}
return new PhingFile((string) $this->pps->getBaseDir());
} | php | public function getDir(Project $p = null)
{
if ($p === null) {
$p = $this->getProject();
}
if ($this->pps === null) {
$this->loadPearPackageScanner($p);
}
return new PhingFile((string) $this->pps->getBaseDir());
} | [
"public",
"function",
"getDir",
"(",
"Project",
"$",
"p",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"p",
"===",
"null",
")",
"{",
"$",
"p",
"=",
"$",
"this",
"->",
"getProject",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"pps",
"===",
"nu... | Returns the base directory all package files are relative to
@param Project $p Current phing project
@return PhingFile Base directory | [
"Returns",
"the",
"base",
"directory",
"all",
"package",
"files",
"are",
"relative",
"to"
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/types/PearPackageFileSet.php#L114-L124 | train |
phingofficial/phing | classes/phing/types/PearPackageFileSet.php | PearPackageFileSet.setPackage | public function setPackage($package)
{
$parts = explode('/', $package);
if (count($parts) > 2) {
throw new BuildException('Invalid package name: ' . $package);
}
if (count($parts) == 1) {
$this->channel = 'pear.php.net';
$this->package = $parts[0];
} else {
$this->channel = $parts[0];
$this->package = $parts[1];
}
} | php | public function setPackage($package)
{
$parts = explode('/', $package);
if (count($parts) > 2) {
throw new BuildException('Invalid package name: ' . $package);
}
if (count($parts) == 1) {
$this->channel = 'pear.php.net';
$this->package = $parts[0];
} else {
$this->channel = $parts[0];
$this->package = $parts[1];
}
} | [
"public",
"function",
"setPackage",
"(",
"$",
"package",
")",
"{",
"$",
"parts",
"=",
"explode",
"(",
"'/'",
",",
"$",
"package",
")",
";",
"if",
"(",
"count",
"(",
"$",
"parts",
")",
">",
"2",
")",
"{",
"throw",
"new",
"BuildException",
"(",
"'Inv... | Sets the package name.
If no channel is given, "pear.php.net" is used.
@param string $package Single package name, or "channel/name" combination
@throws BuildException
@return void | [
"Sets",
"the",
"package",
"name",
".",
"If",
"no",
"channel",
"is",
"given",
"pear",
".",
"php",
".",
"net",
"is",
"used",
"."
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/types/PearPackageFileSet.php#L167-L181 | train |
phingofficial/phing | classes/phing/tasks/ext/pdo/PDOTask.php | PDOTask.getConnection | protected function getConnection()
{
if ($this->url === null) {
throw new BuildException("Url attribute must be set!", $this->getLocation());
}
try {
$this->log("Connecting to " . $this->getUrl(), Project::MSG_VERBOSE);
$user = null;
$pass = null;
if ($this->userId) {
$user = $this->getUserId();
}
if ($this->password) {
$pass = $this->getPassword();
}
$conn = new PDO($this->getUrl(), $user, $pass);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
try {
$conn->setAttribute(PDO::ATTR_AUTOCOMMIT, $this->autocommit);
} catch (PDOException $pe) {
$this->log(
"Unable to enable auto-commit for this database: " . $pe->getMessage(),
Project::MSG_VERBOSE
);
}
return $conn;
} catch (PDOException $e) {
throw new BuildException($e->getMessage(), $this->getLocation());
}
} | php | protected function getConnection()
{
if ($this->url === null) {
throw new BuildException("Url attribute must be set!", $this->getLocation());
}
try {
$this->log("Connecting to " . $this->getUrl(), Project::MSG_VERBOSE);
$user = null;
$pass = null;
if ($this->userId) {
$user = $this->getUserId();
}
if ($this->password) {
$pass = $this->getPassword();
}
$conn = new PDO($this->getUrl(), $user, $pass);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
try {
$conn->setAttribute(PDO::ATTR_AUTOCOMMIT, $this->autocommit);
} catch (PDOException $pe) {
$this->log(
"Unable to enable auto-commit for this database: " . $pe->getMessage(),
Project::MSG_VERBOSE
);
}
return $conn;
} catch (PDOException $e) {
throw new BuildException($e->getMessage(), $this->getLocation());
}
} | [
"protected",
"function",
"getConnection",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"url",
"===",
"null",
")",
"{",
"throw",
"new",
"BuildException",
"(",
"\"Url attribute must be set!\"",
",",
"$",
"this",
"->",
"getLocation",
"(",
")",
")",
";",
"}",
... | Creates a new Connection as using the driver, url, userid and password specified.
The calling method is responsible for closing the connection.
@return PDO the newly created connection.
@throws BuildException if the UserId/Password/Url is not set or there is no suitable driver or the driver fails to load. | [
"Creates",
"a",
"new",
"Connection",
"as",
"using",
"the",
"driver",
"url",
"userid",
"and",
"password",
"specified",
".",
"The",
"calling",
"method",
"is",
"responsible",
"for",
"closing",
"the",
"connection",
"."
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/tasks/ext/pdo/PDOTask.php#L119-L155 | train |
phingofficial/phing | classes/phing/filters/LineContains.php | LineContains.chain | public function chain(Reader $reader): LineContains
{
$newFilter = new self($reader);
$newFilter->setContains($this->getContains());
$newFilter->setNegate($this->isNegated());
$newFilter->setMatchAny($this->isMatchAny());
$newFilter->setInitialized(true);
$newFilter->setProject($this->getProject());
return $newFilter;
} | php | public function chain(Reader $reader): LineContains
{
$newFilter = new self($reader);
$newFilter->setContains($this->getContains());
$newFilter->setNegate($this->isNegated());
$newFilter->setMatchAny($this->isMatchAny());
$newFilter->setInitialized(true);
$newFilter->setProject($this->getProject());
return $newFilter;
} | [
"public",
"function",
"chain",
"(",
"Reader",
"$",
"reader",
")",
":",
"LineContains",
"{",
"$",
"newFilter",
"=",
"new",
"self",
"(",
"$",
"reader",
")",
";",
"$",
"newFilter",
"->",
"setContains",
"(",
"$",
"this",
"->",
"getContains",
"(",
")",
")",... | Creates a new LineContains using the passed in
Reader for instantiation.
@param Reader $reader A Reader object providing the underlying stream.
Must not be <code>null</code>.
@return LineContains A new filter based on this configuration, but filtering
the specified reader
@throws Exception | [
"Creates",
"a",
"new",
"LineContains",
"using",
"the",
"passed",
"in",
"Reader",
"for",
"instantiation",
"."
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/filters/LineContains.php#L218-L228 | train |
phingofficial/phing | classes/phing/filters/LineContains.php | LineContains.initialize | private function initialize()
{
$params = $this->getParameters();
if ($params !== null) {
foreach ($params as $param) {
if (self::CONTAINS_KEY === $param->getType()) {
$cont = new Contains();
$cont->setValue($param->getValue());
$this->contains[] = $cont;
} elseif (self::NEGATE_KEY === $param->getType()) {
$this->setNegate(Project::toBoolean($param->getValue()));
}
}
}
} | php | private function initialize()
{
$params = $this->getParameters();
if ($params !== null) {
foreach ($params as $param) {
if (self::CONTAINS_KEY === $param->getType()) {
$cont = new Contains();
$cont->setValue($param->getValue());
$this->contains[] = $cont;
} elseif (self::NEGATE_KEY === $param->getType()) {
$this->setNegate(Project::toBoolean($param->getValue()));
}
}
}
} | [
"private",
"function",
"initialize",
"(",
")",
"{",
"$",
"params",
"=",
"$",
"this",
"->",
"getParameters",
"(",
")",
";",
"if",
"(",
"$",
"params",
"!==",
"null",
")",
"{",
"foreach",
"(",
"$",
"params",
"as",
"$",
"param",
")",
"{",
"if",
"(",
... | Parses the parameters to add user-defined contains strings. | [
"Parses",
"the",
"parameters",
"to",
"add",
"user",
"-",
"defined",
"contains",
"strings",
"."
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/filters/LineContains.php#L233-L247 | train |
phingofficial/phing | classes/phing/tasks/system/TruncateTask.php | TruncateTask.setFile | public function setFile($f)
{
if (is_string($f)) {
$f = new PhingFile($f);
}
$this->file = $f;
} | php | public function setFile($f)
{
if (is_string($f)) {
$f = new PhingFile($f);
}
$this->file = $f;
} | [
"public",
"function",
"setFile",
"(",
"$",
"f",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"f",
")",
")",
"{",
"$",
"f",
"=",
"new",
"PhingFile",
"(",
"$",
"f",
")",
";",
"}",
"$",
"this",
"->",
"file",
"=",
"$",
"f",
";",
"}"
] | Set a single target File.
@param PhingFile|string $f the single File
@throws \IOException
@throws \NullPointerException | [
"Set",
"a",
"single",
"target",
"File",
"."
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/tasks/system/TruncateTask.php#L40-L46 | train |
phingofficial/phing | classes/phing/system/io/FileSystem.php | FileSystem.getFileSystem | public static function getFileSystem()
{
if (self::$fs === null) {
switch (Phing::getProperty('host.fstype')) {
case 'UNIX':
self::$fs = new UnixFileSystem();
break;
case 'WINDOWS':
self::$fs = new WindowsFileSystem();
break;
default:
throw new IOException("Host uses unsupported filesystem, unable to proceed");
}
}
return self::$fs;
} | php | public static function getFileSystem()
{
if (self::$fs === null) {
switch (Phing::getProperty('host.fstype')) {
case 'UNIX':
self::$fs = new UnixFileSystem();
break;
case 'WINDOWS':
self::$fs = new WindowsFileSystem();
break;
default:
throw new IOException("Host uses unsupported filesystem, unable to proceed");
}
}
return self::$fs;
} | [
"public",
"static",
"function",
"getFileSystem",
"(",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"fs",
"===",
"null",
")",
"{",
"switch",
"(",
"Phing",
"::",
"getProperty",
"(",
"'host.fstype'",
")",
")",
"{",
"case",
"'UNIX'",
":",
"self",
"::",
"$",
"... | Static method to return the FileSystem singelton representing
this platform's local filesystem driver.
@return FileSystem
@throws IOException | [
"Static",
"method",
"to",
"return",
"the",
"FileSystem",
"singelton",
"representing",
"this",
"platform",
"s",
"local",
"filesystem",
"driver",
"."
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/system/io/FileSystem.php#L75-L91 | train |
phingofficial/phing | classes/phing/system/io/FileSystem.php | FileSystem.canDelete | public function canDelete(PhingFile $f)
{
clearstatcache();
$dir = dirname($f->getAbsolutePath());
return (bool) @is_writable($dir);
} | php | public function canDelete(PhingFile $f)
{
clearstatcache();
$dir = dirname($f->getAbsolutePath());
return (bool) @is_writable($dir);
} | [
"public",
"function",
"canDelete",
"(",
"PhingFile",
"$",
"f",
")",
"{",
"clearstatcache",
"(",
")",
";",
"$",
"dir",
"=",
"dirname",
"(",
"$",
"f",
"->",
"getAbsolutePath",
"(",
")",
")",
";",
"return",
"(",
"bool",
")",
"@",
"is_writable",
"(",
"$"... | Whether file can be deleted.
@param PhingFile $f
@return boolean | [
"Whether",
"file",
"can",
"be",
"deleted",
"."
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/system/io/FileSystem.php#L239-L245 | train |
phingofficial/phing | classes/phing/system/io/FileSystem.php | FileSystem.delete | public function delete(PhingFile $f, $recursive = false)
{
if ($f->isDirectory()) {
$this->rmdir($f->getPath(), $recursive);
} else {
$this->unlink($f->getPath());
}
} | php | public function delete(PhingFile $f, $recursive = false)
{
if ($f->isDirectory()) {
$this->rmdir($f->getPath(), $recursive);
} else {
$this->unlink($f->getPath());
}
} | [
"public",
"function",
"delete",
"(",
"PhingFile",
"$",
"f",
",",
"$",
"recursive",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"f",
"->",
"isDirectory",
"(",
")",
")",
"{",
"$",
"this",
"->",
"rmdir",
"(",
"$",
"f",
"->",
"getPath",
"(",
")",
",",
... | Delete the file or directory denoted by the given abstract pathname,
returning true if and only if the operation succeeds.
@param PhingFile $f
@param boolean $recursive
@throws IOException | [
"Delete",
"the",
"file",
"or",
"directory",
"denoted",
"by",
"the",
"given",
"abstract",
"pathname",
"returning",
"true",
"if",
"and",
"only",
"if",
"the",
"operation",
"succeeds",
"."
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/system/io/FileSystem.php#L343-L350 | train |
phingofficial/phing | classes/phing/system/io/FileSystem.php | FileSystem.createDirectory | public function createDirectory(&$f, $mode = 0755)
{
$old_umask = umask(0);
$return = @mkdir($f->getAbsolutePath(), $mode);
umask($old_umask);
return $return;
} | php | public function createDirectory(&$f, $mode = 0755)
{
$old_umask = umask(0);
$return = @mkdir($f->getAbsolutePath(), $mode);
umask($old_umask);
return $return;
} | [
"public",
"function",
"createDirectory",
"(",
"&",
"$",
"f",
",",
"$",
"mode",
"=",
"0755",
")",
"{",
"$",
"old_umask",
"=",
"umask",
"(",
"0",
")",
";",
"$",
"return",
"=",
"@",
"mkdir",
"(",
"$",
"f",
"->",
"getAbsolutePath",
"(",
")",
",",
"$"... | Create a new directory denoted by the given abstract pathname,
returning true if and only if the operation succeeds.
NOTE: umask() is reset to 0 while executing mkdir(), and restored afterwards
@param PhingFile $f
@param int $mode
@return boolean | [
"Create",
"a",
"new",
"directory",
"denoted",
"by",
"the",
"given",
"abstract",
"pathname",
"returning",
"true",
"if",
"and",
"only",
"if",
"the",
"operation",
"succeeds",
"."
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/system/io/FileSystem.php#L375-L382 | train |
phingofficial/phing | classes/phing/system/io/FileSystem.php | FileSystem.rename | public function rename(PhingFile $f1, PhingFile $f2)
{
// get the canonical paths of the file to rename
$src = $f1->getAbsolutePath();
$dest = $f2->getAbsolutePath();
if (false === @rename($src, $dest)) {
$msg = "Rename FAILED. Cannot rename $src to $dest. $php_errormsg";
throw new IOException($msg);
}
} | php | public function rename(PhingFile $f1, PhingFile $f2)
{
// get the canonical paths of the file to rename
$src = $f1->getAbsolutePath();
$dest = $f2->getAbsolutePath();
if (false === @rename($src, $dest)) {
$msg = "Rename FAILED. Cannot rename $src to $dest. $php_errormsg";
throw new IOException($msg);
}
} | [
"public",
"function",
"rename",
"(",
"PhingFile",
"$",
"f1",
",",
"PhingFile",
"$",
"f2",
")",
"{",
"// get the canonical paths of the file to rename",
"$",
"src",
"=",
"$",
"f1",
"->",
"getAbsolutePath",
"(",
")",
";",
"$",
"dest",
"=",
"$",
"f2",
"->",
"... | Rename the file or directory denoted by the first abstract pathname to
the second abstract pathname, returning true if and only if
the operation succeeds.
@param PhingFile $f1 abstract source file
@param PhingFile $f2 abstract destination file
@return void
@throws IOException if rename cannot be performed | [
"Rename",
"the",
"file",
"or",
"directory",
"denoted",
"by",
"the",
"first",
"abstract",
"pathname",
"to",
"the",
"second",
"abstract",
"pathname",
"returning",
"true",
"if",
"and",
"only",
"if",
"the",
"operation",
"succeeds",
"."
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/system/io/FileSystem.php#L394-L403 | train |
phingofficial/phing | classes/phing/system/io/FileSystem.php | FileSystem.setLastModifiedTime | public function setLastModifiedTime(PhingFile $f, $time)
{
$path = $f->getPath();
$success = @touch($path, $time);
if (!$success) {
throw new IOException("Could not touch '" . $path . "' due to: $php_errormsg");
}
} | php | public function setLastModifiedTime(PhingFile $f, $time)
{
$path = $f->getPath();
$success = @touch($path, $time);
if (!$success) {
throw new IOException("Could not touch '" . $path . "' due to: $php_errormsg");
}
} | [
"public",
"function",
"setLastModifiedTime",
"(",
"PhingFile",
"$",
"f",
",",
"$",
"time",
")",
"{",
"$",
"path",
"=",
"$",
"f",
"->",
"getPath",
"(",
")",
";",
"$",
"success",
"=",
"@",
"touch",
"(",
"$",
"path",
",",
"$",
"time",
")",
";",
"if"... | Set the last-modified time of the file or directory denoted by the
given abstract pathname returning true if and only if the
operation succeeds.
@param PhingFile $f
@param int $time
@return void
@throws IOException | [
"Set",
"the",
"last",
"-",
"modified",
"time",
"of",
"the",
"file",
"or",
"directory",
"denoted",
"by",
"the",
"given",
"abstract",
"pathname",
"returning",
"true",
"if",
"and",
"only",
"if",
"the",
"operation",
"succeeds",
"."
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/system/io/FileSystem.php#L415-L422 | train |
phingofficial/phing | classes/phing/system/io/FileSystem.php | FileSystem.chown | public function chown($pathname, $user)
{
if (false === @chown($pathname, $user)) { // FAILED.
$msg = "FileSystem::chown() FAILED. Cannot chown $pathname. User $user." . (isset($php_errormsg) ? ' ' . $php_errormsg : "");
throw new IOException($msg);
}
} | php | public function chown($pathname, $user)
{
if (false === @chown($pathname, $user)) { // FAILED.
$msg = "FileSystem::chown() FAILED. Cannot chown $pathname. User $user." . (isset($php_errormsg) ? ' ' . $php_errormsg : "");
throw new IOException($msg);
}
} | [
"public",
"function",
"chown",
"(",
"$",
"pathname",
",",
"$",
"user",
")",
"{",
"if",
"(",
"false",
"===",
"@",
"chown",
"(",
"$",
"pathname",
",",
"$",
"user",
")",
")",
"{",
"// FAILED.",
"$",
"msg",
"=",
"\"FileSystem::chown() FAILED. Cannot chown $pat... | Change the ownership on a file or directory.
@param string $pathname Path and name of file or directory.
@param string $user The user name or number of the file or directory. See http://us.php.net/chown
@return void
@throws IOException if operation failed. | [
"Change",
"the",
"ownership",
"on",
"a",
"file",
"or",
"directory",
"."
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/system/io/FileSystem.php#L553-L559 | train |
phingofficial/phing | classes/phing/system/io/FileSystem.php | FileSystem.chgrp | public function chgrp($pathname, $group)
{
if (false === @chgrp($pathname, $group)) { // FAILED.
$msg = "FileSystem::chgrp() FAILED. Cannot chown $pathname. Group $group." . (isset($php_errormsg) ? ' ' . $php_errormsg : "");
throw new IOException($msg);
}
} | php | public function chgrp($pathname, $group)
{
if (false === @chgrp($pathname, $group)) { // FAILED.
$msg = "FileSystem::chgrp() FAILED. Cannot chown $pathname. Group $group." . (isset($php_errormsg) ? ' ' . $php_errormsg : "");
throw new IOException($msg);
}
} | [
"public",
"function",
"chgrp",
"(",
"$",
"pathname",
",",
"$",
"group",
")",
"{",
"if",
"(",
"false",
"===",
"@",
"chgrp",
"(",
"$",
"pathname",
",",
"$",
"group",
")",
")",
"{",
"// FAILED.",
"$",
"msg",
"=",
"\"FileSystem::chgrp() FAILED. Cannot chown $p... | Change the group on a file or directory.
@param string $pathname Path and name of file or directory.
@param string $group The group of the file or directory. See http://us.php.net/chgrp
@return void
@throws IOException if operation failed. | [
"Change",
"the",
"group",
"on",
"a",
"file",
"or",
"directory",
"."
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/system/io/FileSystem.php#L570-L576 | train |
phingofficial/phing | classes/phing/system/io/FileSystem.php | FileSystem.chmod | public function chmod($pathname, $mode)
{
$str_mode = decoct($mode); // Show octal in messages.
if (false === @chmod($pathname, $mode)) { // FAILED.
$msg = "FileSystem::chmod() FAILED. Cannot chmod $pathname. Mode $str_mode." . (isset($php_errormsg) ? ' ' . $php_errormsg : "");
throw new IOException($msg);
}
} | php | public function chmod($pathname, $mode)
{
$str_mode = decoct($mode); // Show octal in messages.
if (false === @chmod($pathname, $mode)) { // FAILED.
$msg = "FileSystem::chmod() FAILED. Cannot chmod $pathname. Mode $str_mode." . (isset($php_errormsg) ? ' ' . $php_errormsg : "");
throw new IOException($msg);
}
} | [
"public",
"function",
"chmod",
"(",
"$",
"pathname",
",",
"$",
"mode",
")",
"{",
"$",
"str_mode",
"=",
"decoct",
"(",
"$",
"mode",
")",
";",
"// Show octal in messages.",
"if",
"(",
"false",
"===",
"@",
"chmod",
"(",
"$",
"pathname",
",",
"$",
"mode",
... | Change the permissions on a file or directory.
@param string $pathname Path and name of file or directory.
@param int $mode The mode (permissions) of the file or
directory. If using octal add leading 0. eg. 0777.
Mode is affected by the umask system setting.
@return void
@throws IOException if operation failed. | [
"Change",
"the",
"permissions",
"on",
"a",
"file",
"or",
"directory",
"."
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/system/io/FileSystem.php#L589-L596 | train |
phingofficial/phing | classes/phing/system/io/FileSystem.php | FileSystem.lock | public function lock(PhingFile $f)
{
$filename = $f->getPath();
$fp = @fopen($filename, "w");
$result = @flock($fp, LOCK_EX);
@fclose($fp);
if (!$result) {
throw new IOException("Could not lock file '$filename'");
}
} | php | public function lock(PhingFile $f)
{
$filename = $f->getPath();
$fp = @fopen($filename, "w");
$result = @flock($fp, LOCK_EX);
@fclose($fp);
if (!$result) {
throw new IOException("Could not lock file '$filename'");
}
} | [
"public",
"function",
"lock",
"(",
"PhingFile",
"$",
"f",
")",
"{",
"$",
"filename",
"=",
"$",
"f",
"->",
"getPath",
"(",
")",
";",
"$",
"fp",
"=",
"@",
"fopen",
"(",
"$",
"filename",
",",
"\"w\"",
")",
";",
"$",
"result",
"=",
"@",
"flock",
"(... | Locks a file and throws an Exception if this is not possible.
@param PhingFile $f
@return void
@throws IOException | [
"Locks",
"a",
"file",
"and",
"throws",
"an",
"Exception",
"if",
"this",
"is",
"not",
"possible",
"."
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/system/io/FileSystem.php#L605-L614 | train |
phingofficial/phing | classes/phing/system/io/FileSystem.php | FileSystem.unlock | public function unlock(PhingFile $f)
{
$filename = $f->getPath();
$fp = @fopen($filename, "w");
$result = @flock($fp, LOCK_UN);
fclose($fp);
if (!$result) {
throw new IOException("Could not unlock file '$filename'");
}
} | php | public function unlock(PhingFile $f)
{
$filename = $f->getPath();
$fp = @fopen($filename, "w");
$result = @flock($fp, LOCK_UN);
fclose($fp);
if (!$result) {
throw new IOException("Could not unlock file '$filename'");
}
} | [
"public",
"function",
"unlock",
"(",
"PhingFile",
"$",
"f",
")",
"{",
"$",
"filename",
"=",
"$",
"f",
"->",
"getPath",
"(",
")",
";",
"$",
"fp",
"=",
"@",
"fopen",
"(",
"$",
"filename",
",",
"\"w\"",
")",
";",
"$",
"result",
"=",
"@",
"flock",
... | Unlocks a file and throws an IO Error if this is not possible.
@param PhingFile $f
@throws IOException
@return void | [
"Unlocks",
"a",
"file",
"and",
"throws",
"an",
"IO",
"Error",
"if",
"this",
"is",
"not",
"possible",
"."
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/system/io/FileSystem.php#L623-L632 | train |
phingofficial/phing | classes/phing/system/io/FileSystem.php | FileSystem.symlink | public function symlink($target, $link)
{
// If Windows OS then symlink() will report it is not supported in
// the build. Use this error instead of checking for Windows as the OS.
if (false === @symlink($target, $link)) {
// Add error from php to end of log message. $php_errormsg.
$msg = "FileSystem::Symlink() FAILED. Cannot symlink '$target' to '$link'. $php_errormsg";
throw new IOException($msg);
}
} | php | public function symlink($target, $link)
{
// If Windows OS then symlink() will report it is not supported in
// the build. Use this error instead of checking for Windows as the OS.
if (false === @symlink($target, $link)) {
// Add error from php to end of log message. $php_errormsg.
$msg = "FileSystem::Symlink() FAILED. Cannot symlink '$target' to '$link'. $php_errormsg";
throw new IOException($msg);
}
} | [
"public",
"function",
"symlink",
"(",
"$",
"target",
",",
"$",
"link",
")",
"{",
"// If Windows OS then symlink() will report it is not supported in",
"// the build. Use this error instead of checking for Windows as the OS.",
"if",
"(",
"false",
"===",
"@",
"symlink",
"(",
"$... | Symbolically link a file to another name.
Currently symlink is not implemented on Windows. Don't use if the application is to be portable.
@param string $target Path and/or name of file to link.
@param string $link Path and/or name of link to be created.
@throws IOException
@return void | [
"Symbolically",
"link",
"a",
"file",
"to",
"another",
"name",
"."
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/system/io/FileSystem.php#L661-L672 | train |
phingofficial/phing | classes/phing/system/io/FileSystem.php | FileSystem.touch | public function touch($file, $time = null)
{
global $php_errormsg;
if (null === $time) {
$error = @touch($file);
} else {
$error = @touch($file, $time);
}
if (false === $error) { // FAILED.
// Add error from php to end of log message. $php_errormsg.
$msg = "FileSystem::touch() FAILED. Cannot touch '$file'. $php_errormsg";
throw new Exception($msg);
}
} | php | public function touch($file, $time = null)
{
global $php_errormsg;
if (null === $time) {
$error = @touch($file);
} else {
$error = @touch($file, $time);
}
if (false === $error) { // FAILED.
// Add error from php to end of log message. $php_errormsg.
$msg = "FileSystem::touch() FAILED. Cannot touch '$file'. $php_errormsg";
throw new Exception($msg);
}
} | [
"public",
"function",
"touch",
"(",
"$",
"file",
",",
"$",
"time",
"=",
"null",
")",
"{",
"global",
"$",
"php_errormsg",
";",
"if",
"(",
"null",
"===",
"$",
"time",
")",
"{",
"$",
"error",
"=",
"@",
"touch",
"(",
"$",
"file",
")",
";",
"}",
"el... | Set the modification and access time on a file to the present time.
@param string $file Path and/or name of file to touch.
@param int $time
@throws Exception
@return void | [
"Set",
"the",
"modification",
"and",
"access",
"time",
"on",
"a",
"file",
"to",
"the",
"present",
"time",
"."
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/system/io/FileSystem.php#L682-L697 | train |
phingofficial/phing | classes/phing/system/io/FileSystem.php | FileSystem.rmdir | public function rmdir($dir, $children = false)
{
global $php_errormsg;
// If children=FALSE only delete dir if empty.
if (false === $children) {
if (false === @rmdir($dir)) { // FAILED.
// Add error from php to end of log message. $php_errormsg.
$msg = "FileSystem::rmdir() FAILED. Cannot rmdir $dir. $php_errormsg";
throw new Exception($msg);
}
} else { // delete contents and dir.
$handle = @opendir($dir);
if (false === $handle) { // Error.
$msg = "FileSystem::rmdir() FAILED. Cannot opendir() $dir. $php_errormsg";
throw new Exception($msg);
} else { // Read from handle.
// Don't error on readdir().
while (false !== ($entry = @readdir($handle))) {
if ($entry != '.' && $entry != '..') {
// Only add / if it isn't already the last char.
// This ONLY serves the purpose of making the Logger
// output look nice:)
if (strpos(strrev($dir), DIRECTORY_SEPARATOR) === 0) { // there is a /
$next_entry = $dir . $entry;
} else { // no /
$next_entry = $dir . DIRECTORY_SEPARATOR . $entry;
}
// NOTE: As of php 4.1.1 is_dir doesn't return FALSE it
// returns 0. So use == not ===.
// Don't error on is_dir()
if (false == @is_dir($next_entry)) { // Is file.
try {
self::unlink($next_entry); // Delete.
} catch (Exception $e) {
$msg = "FileSystem::Rmdir() FAILED. Cannot FileSystem::Unlink() $next_entry. " . $e->getMessage();
throw new Exception($msg);
}
} else { // Is directory.
try {
self::rmdir($next_entry, true); // Delete
} catch (Exception $e) {
$msg = "FileSystem::rmdir() FAILED. Cannot FileSystem::rmdir() $next_entry. " . $e->getMessage();
throw new Exception($msg);
}
} // end is_dir else
} // end .. if
} // end while
} // end handle if
// Don't error on closedir()
@closedir($handle);
if (false === @rmdir($dir)) { // FAILED.
// Add error from php to end of log message. $php_errormsg.
$msg = "FileSystem::rmdir() FAILED. Cannot rmdir $dir. $php_errormsg";
throw new Exception($msg);
}
}
} | php | public function rmdir($dir, $children = false)
{
global $php_errormsg;
// If children=FALSE only delete dir if empty.
if (false === $children) {
if (false === @rmdir($dir)) { // FAILED.
// Add error from php to end of log message. $php_errormsg.
$msg = "FileSystem::rmdir() FAILED. Cannot rmdir $dir. $php_errormsg";
throw new Exception($msg);
}
} else { // delete contents and dir.
$handle = @opendir($dir);
if (false === $handle) { // Error.
$msg = "FileSystem::rmdir() FAILED. Cannot opendir() $dir. $php_errormsg";
throw new Exception($msg);
} else { // Read from handle.
// Don't error on readdir().
while (false !== ($entry = @readdir($handle))) {
if ($entry != '.' && $entry != '..') {
// Only add / if it isn't already the last char.
// This ONLY serves the purpose of making the Logger
// output look nice:)
if (strpos(strrev($dir), DIRECTORY_SEPARATOR) === 0) { // there is a /
$next_entry = $dir . $entry;
} else { // no /
$next_entry = $dir . DIRECTORY_SEPARATOR . $entry;
}
// NOTE: As of php 4.1.1 is_dir doesn't return FALSE it
// returns 0. So use == not ===.
// Don't error on is_dir()
if (false == @is_dir($next_entry)) { // Is file.
try {
self::unlink($next_entry); // Delete.
} catch (Exception $e) {
$msg = "FileSystem::Rmdir() FAILED. Cannot FileSystem::Unlink() $next_entry. " . $e->getMessage();
throw new Exception($msg);
}
} else { // Is directory.
try {
self::rmdir($next_entry, true); // Delete
} catch (Exception $e) {
$msg = "FileSystem::rmdir() FAILED. Cannot FileSystem::rmdir() $next_entry. " . $e->getMessage();
throw new Exception($msg);
}
} // end is_dir else
} // end .. if
} // end while
} // end handle if
// Don't error on closedir()
@closedir($handle);
if (false === @rmdir($dir)) { // FAILED.
// Add error from php to end of log message. $php_errormsg.
$msg = "FileSystem::rmdir() FAILED. Cannot rmdir $dir. $php_errormsg";
throw new Exception($msg);
}
}
} | [
"public",
"function",
"rmdir",
"(",
"$",
"dir",
",",
"$",
"children",
"=",
"false",
")",
"{",
"global",
"$",
"php_errormsg",
";",
"// If children=FALSE only delete dir if empty.",
"if",
"(",
"false",
"===",
"$",
"children",
")",
"{",
"if",
"(",
"false",
"===... | Delete an empty directory OR a directory and all of its contents.
@param string $dir Path and/or name of directory to delete.
@param bool $children False: don't delete directory contents.
True: delete directory contents.
@throws Exception
@return void | [
"Delete",
"an",
"empty",
"directory",
"OR",
"a",
"directory",
"and",
"all",
"of",
"its",
"contents",
"."
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/system/io/FileSystem.php#L710-L778 | train |
phingofficial/phing | classes/phing/system/io/FileSystem.php | FileSystem.umask | public function umask($mode)
{
global $php_errormsg;
// CONSIDERME:
// Throw a warning if mode is 0. PHP converts illegal octal numbers to
// 0 so 0 might not be what the user intended.
$str_mode = decoct($mode); // Show octal in messages.
if (false === @umask($mode)) { // FAILED.
// Add error from php to end of log message. $php_errormsg.
$msg = "FileSystem::Umask() FAILED. Value $mode. $php_errormsg";
throw new Exception($msg);
}
} | php | public function umask($mode)
{
global $php_errormsg;
// CONSIDERME:
// Throw a warning if mode is 0. PHP converts illegal octal numbers to
// 0 so 0 might not be what the user intended.
$str_mode = decoct($mode); // Show octal in messages.
if (false === @umask($mode)) { // FAILED.
// Add error from php to end of log message. $php_errormsg.
$msg = "FileSystem::Umask() FAILED. Value $mode. $php_errormsg";
throw new Exception($msg);
}
} | [
"public",
"function",
"umask",
"(",
"$",
"mode",
")",
"{",
"global",
"$",
"php_errormsg",
";",
"// CONSIDERME:",
"// Throw a warning if mode is 0. PHP converts illegal octal numbers to",
"// 0 so 0 might not be what the user intended.",
"$",
"str_mode",
"=",
"decoct",
"(",
"$... | Set the umask for file and directory creation.
@param Int $mode
@throws Exception
@internal param Int $mode . Permissions usually in ocatal. Use leading 0 for
octal. Number between 0 and 0777.
@return void | [
"Set",
"the",
"umask",
"for",
"file",
"and",
"directory",
"creation",
"."
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/system/io/FileSystem.php#L790-L805 | train |
phingofficial/phing | classes/phing/system/io/FileSystem.php | FileSystem.compareMTimes | public function compareMTimes($file1, $file2)
{
$mtime1 = filemtime($file1);
$mtime2 = filemtime($file2);
if ($mtime1 === false) { // FAILED. Log and return err.
// Add error from php to end of log message. $php_errormsg.
$msg = "FileSystem::compareMTimes() FAILED. Cannot can not get modified time of $file1.";
throw new Exception($msg);
} elseif ($mtime2 === false) { // FAILED. Log and return err.
// Add error from php to end of log message. $php_errormsg.
$msg = "FileSystem::compareMTimes() FAILED. Cannot can not get modified time of $file2.";
throw new Exception($msg);
} else { // Worked. Log and return compare.
// Compare mtimes.
if ($mtime1 == $mtime2) {
return 0;
} else {
return ($mtime1 < $mtime2) ? -1 : 1;
} // end compare
}
} | php | public function compareMTimes($file1, $file2)
{
$mtime1 = filemtime($file1);
$mtime2 = filemtime($file2);
if ($mtime1 === false) { // FAILED. Log and return err.
// Add error from php to end of log message. $php_errormsg.
$msg = "FileSystem::compareMTimes() FAILED. Cannot can not get modified time of $file1.";
throw new Exception($msg);
} elseif ($mtime2 === false) { // FAILED. Log and return err.
// Add error from php to end of log message. $php_errormsg.
$msg = "FileSystem::compareMTimes() FAILED. Cannot can not get modified time of $file2.";
throw new Exception($msg);
} else { // Worked. Log and return compare.
// Compare mtimes.
if ($mtime1 == $mtime2) {
return 0;
} else {
return ($mtime1 < $mtime2) ? -1 : 1;
} // end compare
}
} | [
"public",
"function",
"compareMTimes",
"(",
"$",
"file1",
",",
"$",
"file2",
")",
"{",
"$",
"mtime1",
"=",
"filemtime",
"(",
"$",
"file1",
")",
";",
"$",
"mtime2",
"=",
"filemtime",
"(",
"$",
"file2",
")",
";",
"if",
"(",
"$",
"mtime1",
"===",
"fal... | Compare the modified time of two files.
@param string $file1 Path and name of file1.
@param string $file2 Path and name of file2.
@return int 1 if file1 is newer.
-1 if file2 is newer.
0 if files have the same time.
Err object on failure.
@throws Exception - if cannot get modified time of either file. | [
"Compare",
"the",
"modified",
"time",
"of",
"two",
"files",
"."
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/system/io/FileSystem.php#L820-L841 | train |
phingofficial/phing | classes/phing/system/io/FileSystem.php | FileSystem.listContents | public function listContents(PhingFile $f)
{
return array_keys(
iterator_to_array(
new FilesystemIterator(
$f->getAbsolutePath(),
FilesystemIterator::KEY_AS_FILENAME
)
)
);
} | php | public function listContents(PhingFile $f)
{
return array_keys(
iterator_to_array(
new FilesystemIterator(
$f->getAbsolutePath(),
FilesystemIterator::KEY_AS_FILENAME
)
)
);
} | [
"public",
"function",
"listContents",
"(",
"PhingFile",
"$",
"f",
")",
"{",
"return",
"array_keys",
"(",
"iterator_to_array",
"(",
"new",
"FilesystemIterator",
"(",
"$",
"f",
"->",
"getAbsolutePath",
"(",
")",
",",
"FilesystemIterator",
"::",
"KEY_AS_FILENAME",
... | returns the contents of a directory in an array
@param PhingFile $f
@return string[] | [
"returns",
"the",
"contents",
"of",
"a",
"directory",
"in",
"an",
"array"
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/system/io/FileSystem.php#L849-L859 | train |
phingofficial/phing | classes/phing/system/io/FileSystem.php | FileSystem.which | public function which($executable, $fallback = false)
{
if (is_string($executable)) {
if (trim($executable) === '') {
return $fallback;
}
} else {
return $fallback;
}
if (basename($executable) === $executable) {
$path = getenv("PATH");
} else {
$path = dirname($executable);
}
$dirSeparator = $this->getSeparator();
$pathSeparator = $this->getPathSeparator();
$elements = explode($pathSeparator, $path);
$amount = count($elements);
$fstype = Phing::getProperty('host.fstype');
switch ($fstype) {
case 'UNIX':
for ($count = 0; $count < $amount; ++$count) {
$file = $elements[$count] . $dirSeparator . $executable;
if (file_exists($file) && is_executable($file)) {
return $file;
}
}
break;
case 'WINDOWS':
$exts = getenv('PATHEXT');
if ($exts === false) {
$exts = ['.exe', '.bat', '.cmd', '.com'];
} else {
$exts = explode($pathSeparator, $exts);
}
for ($count = 0; $count < $amount; $count++) {
foreach ($exts as $ext) {
$file = $elements[$count] . $dirSeparator . $executable . $ext;
// Not all of the extensions above need to be set executable on Windows for them to be executed.
// I'm sure there's a joke here somewhere.
if (file_exists($file)) {
return $file;
}
}
}
break;
}
if (file_exists($executable) && is_executable($executable)) {
return $executable;
}
return $fallback;
} | php | public function which($executable, $fallback = false)
{
if (is_string($executable)) {
if (trim($executable) === '') {
return $fallback;
}
} else {
return $fallback;
}
if (basename($executable) === $executable) {
$path = getenv("PATH");
} else {
$path = dirname($executable);
}
$dirSeparator = $this->getSeparator();
$pathSeparator = $this->getPathSeparator();
$elements = explode($pathSeparator, $path);
$amount = count($elements);
$fstype = Phing::getProperty('host.fstype');
switch ($fstype) {
case 'UNIX':
for ($count = 0; $count < $amount; ++$count) {
$file = $elements[$count] . $dirSeparator . $executable;
if (file_exists($file) && is_executable($file)) {
return $file;
}
}
break;
case 'WINDOWS':
$exts = getenv('PATHEXT');
if ($exts === false) {
$exts = ['.exe', '.bat', '.cmd', '.com'];
} else {
$exts = explode($pathSeparator, $exts);
}
for ($count = 0; $count < $amount; $count++) {
foreach ($exts as $ext) {
$file = $elements[$count] . $dirSeparator . $executable . $ext;
// Not all of the extensions above need to be set executable on Windows for them to be executed.
// I'm sure there's a joke here somewhere.
if (file_exists($file)) {
return $file;
}
}
}
break;
}
if (file_exists($executable) && is_executable($executable)) {
return $executable;
}
return $fallback;
} | [
"public",
"function",
"which",
"(",
"$",
"executable",
",",
"$",
"fallback",
"=",
"false",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"executable",
")",
")",
"{",
"if",
"(",
"trim",
"(",
"$",
"executable",
")",
"===",
"''",
")",
"{",
"return",
"$"... | PHP implementation of the 'which' command.
Used to retrieve/determine the full path for a command.
@param string $executable Executable file to search for
@param mixed $fallback Default to fallback to.
@return string Full path for the specified executable/command. | [
"PHP",
"implementation",
"of",
"the",
"which",
"command",
"."
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/system/io/FileSystem.php#L871-L922 | train |
phingofficial/phing | classes/phing/BuildEvent.php | BuildEvent.setMessage | public function setMessage($message, $priority)
{
$this->message = (string) $message;
$this->priority = (int) $priority;
} | php | public function setMessage($message, $priority)
{
$this->message = (string) $message;
$this->priority = (int) $priority;
} | [
"public",
"function",
"setMessage",
"(",
"$",
"message",
",",
"$",
"priority",
")",
"{",
"$",
"this",
"->",
"message",
"=",
"(",
"string",
")",
"$",
"message",
";",
"$",
"this",
"->",
"priority",
"=",
"(",
"int",
")",
"$",
"priority",
";",
"}"
] | Sets the message with details and the message priority for this event.
@param string The string message of the event
@param integer The priority this message should have | [
"Sets",
"the",
"message",
"with",
"details",
"and",
"the",
"message",
"priority",
"for",
"this",
"event",
"."
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/BuildEvent.php#L117-L121 | train |
phingofficial/phing | classes/phing/tasks/system/ResolvePathTask.php | ResolvePathTask.main | public function main()
{
if (!$this->propertyName) {
throw new BuildException("You must specify the propertyName attribute", $this->getLocation());
}
// Currently only files are supported
if ($this->file === null) {
throw new BuildException("You must specify a path to resolve", $this->getLocation());
}
$fs = FileSystem::getFileSystem();
// if dir attribute was specified then we should
// use that as basedir to which file was relative.
// -- unless the file specified is an absolute path
if ($this->dir !== null && !$fs->isAbsolute(new PhingFile($this->file))) {
$this->file = new PhingFile($this->dir->getPath(), $this->file);
}
$resolved = $this->project->resolveFile($this->file);
$this->log("Resolved " . $this->file . " to " . $resolved->getAbsolutePath(), $this->logLevel);
$this->project->setProperty($this->propertyName, $resolved->getAbsolutePath());
} | php | public function main()
{
if (!$this->propertyName) {
throw new BuildException("You must specify the propertyName attribute", $this->getLocation());
}
// Currently only files are supported
if ($this->file === null) {
throw new BuildException("You must specify a path to resolve", $this->getLocation());
}
$fs = FileSystem::getFileSystem();
// if dir attribute was specified then we should
// use that as basedir to which file was relative.
// -- unless the file specified is an absolute path
if ($this->dir !== null && !$fs->isAbsolute(new PhingFile($this->file))) {
$this->file = new PhingFile($this->dir->getPath(), $this->file);
}
$resolved = $this->project->resolveFile($this->file);
$this->log("Resolved " . $this->file . " to " . $resolved->getAbsolutePath(), $this->logLevel);
$this->project->setProperty($this->propertyName, $resolved->getAbsolutePath());
} | [
"public",
"function",
"main",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"propertyName",
")",
"{",
"throw",
"new",
"BuildException",
"(",
"\"You must specify the propertyName attribute\"",
",",
"$",
"this",
"->",
"getLocation",
"(",
")",
")",
";",
"}"... | Perform the resolution & set property. | [
"Perform",
"the",
"resolution",
"&",
"set",
"property",
"."
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/tasks/system/ResolvePathTask.php#L146-L170 | train |
phingofficial/phing | classes/phing/tasks/system/RecorderEntry.php | RecorderEntry.setRecordState | public function setRecordState($state)
{
if ($state != null) {
$this->flush();
$this->record = StringHelper::booleanValue($state);
}
} | php | public function setRecordState($state)
{
if ($state != null) {
$this->flush();
$this->record = StringHelper::booleanValue($state);
}
} | [
"public",
"function",
"setRecordState",
"(",
"$",
"state",
")",
"{",
"if",
"(",
"$",
"state",
"!=",
"null",
")",
"{",
"$",
"this",
"->",
"flush",
"(",
")",
";",
"$",
"this",
"->",
"record",
"=",
"StringHelper",
"::",
"booleanValue",
"(",
"$",
"state"... | Turns off or on this recorder.
@param bool|null state true for on, false for off, null for no change. | [
"Turns",
"off",
"or",
"on",
"this",
"recorder",
"."
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/tasks/system/RecorderEntry.php#L95-L101 | train |
phingofficial/phing | classes/phing/tasks/system/RecorderEntry.php | RecorderEntry.log | private function log($mesg, $level)
{
if ($this->record && ($level <= $this->loglevel) && $this->out != null) {
$this->out->write($mesg . PHP_EOL);
}
} | php | private function log($mesg, $level)
{
if ($this->record && ($level <= $this->loglevel) && $this->out != null) {
$this->out->write($mesg . PHP_EOL);
}
} | [
"private",
"function",
"log",
"(",
"$",
"mesg",
",",
"$",
"level",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"record",
"&&",
"(",
"$",
"level",
"<=",
"$",
"this",
"->",
"loglevel",
")",
"&&",
"$",
"this",
"->",
"out",
"!=",
"null",
")",
"{",
"$",... | The thing that actually sends the information to the output.
@param string $mesg The message to log.
@param int $level The verbosity level of the message. | [
"The",
"thing",
"that",
"actually",
"sends",
"the",
"information",
"to",
"the",
"output",
"."
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/tasks/system/RecorderEntry.php#L234-L239 | train |
phingofficial/phing | classes/phing/tasks/system/RecorderEntry.php | RecorderEntry.setProject | public function setProject(Project $project)
{
$this->project = $project;
if ($this->project != null) {
$this->project->addBuildListener($this);
}
} | php | public function setProject(Project $project)
{
$this->project = $project;
if ($this->project != null) {
$this->project->addBuildListener($this);
}
} | [
"public",
"function",
"setProject",
"(",
"Project",
"$",
"project",
")",
"{",
"$",
"this",
"->",
"project",
"=",
"$",
"project",
";",
"if",
"(",
"$",
"this",
"->",
"project",
"!=",
"null",
")",
"{",
"$",
"this",
"->",
"project",
"->",
"addBuildListener... | Set the project associated with this recorder entry.
@param Project $project the project instance | [
"Set",
"the",
"project",
"associated",
"with",
"this",
"recorder",
"entry",
"."
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/tasks/system/RecorderEntry.php#L305-L311 | train |
phingofficial/phing | classes/phing/tasks/system/RecorderEntry.php | RecorderEntry.closeFile | public function closeFile()
{
if ($this->out != null) {
$this->out->close();
$this->out = null;
}
} | php | public function closeFile()
{
if ($this->out != null) {
$this->out->close();
$this->out = null;
}
} | [
"public",
"function",
"closeFile",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"out",
"!=",
"null",
")",
"{",
"$",
"this",
"->",
"out",
"->",
"close",
"(",
")",
";",
"$",
"this",
"->",
"out",
"=",
"null",
";",
"}",
"}"
] | Closes the file associated with this recorder.
Used by Recorder. | [
"Closes",
"the",
"file",
"associated",
"with",
"this",
"recorder",
".",
"Used",
"by",
"Recorder",
"."
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/tasks/system/RecorderEntry.php#L347-L353 | train |
phingofficial/phing | classes/phing/tasks/ext/SmartyTask.php | SmartyTask.setContextProperties | public function setContextProperties($file)
{
$sources = explode(",", $file);
$this->contextProperties = new Properties();
// Always try to get the context properties resource
// from a file first. Templates may be taken from a JAR
// file but the context properties resource may be a
// resource in the filesystem. If this fails than attempt
// to get the context properties resource from the
// classpath.
for ($i = 0, $sourcesLength = count($sources); $i < $sourcesLength; $i++) {
$source = new Properties();
try {
// resolve relative path from basedir and leave
// absolute path untouched.
$fullPath = $this->project->resolveFile($sources[$i]);
$this->log("Using contextProperties file: " . $fullPath->__toString());
$source->load($fullPath);
} catch (Exception $e) {
throw new BuildException(
"Context properties file " . $sources[$i] .
" could not be found in the file system!"
);
}
$keys = $source->keys();
foreach ($keys as $key) {
$name = $key;
$value = $this->project->replaceProperties($source->getProperty($name));
$this->contextProperties->setProperty($name, $value);
}
}
} | php | public function setContextProperties($file)
{
$sources = explode(",", $file);
$this->contextProperties = new Properties();
// Always try to get the context properties resource
// from a file first. Templates may be taken from a JAR
// file but the context properties resource may be a
// resource in the filesystem. If this fails than attempt
// to get the context properties resource from the
// classpath.
for ($i = 0, $sourcesLength = count($sources); $i < $sourcesLength; $i++) {
$source = new Properties();
try {
// resolve relative path from basedir and leave
// absolute path untouched.
$fullPath = $this->project->resolveFile($sources[$i]);
$this->log("Using contextProperties file: " . $fullPath->__toString());
$source->load($fullPath);
} catch (Exception $e) {
throw new BuildException(
"Context properties file " . $sources[$i] .
" could not be found in the file system!"
);
}
$keys = $source->keys();
foreach ($keys as $key) {
$name = $key;
$value = $this->project->replaceProperties($source->getProperty($name));
$this->contextProperties->setProperty($name, $value);
}
}
} | [
"public",
"function",
"setContextProperties",
"(",
"$",
"file",
")",
"{",
"$",
"sources",
"=",
"explode",
"(",
"\",\"",
",",
"$",
"file",
")",
";",
"$",
"this",
"->",
"contextProperties",
"=",
"new",
"Properties",
"(",
")",
";",
"// Always try to get the con... | Set the context properties that will be
fed into the initial context be the
generating process starts.
@param string $file
@throws BuildException
@return void | [
"Set",
"the",
"context",
"properties",
"that",
"will",
"be",
"fed",
"into",
"the",
"initial",
"context",
"be",
"the",
"generating",
"process",
"starts",
"."
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/tasks/ext/SmartyTask.php#L417-L452 | train |
phingofficial/phing | classes/phing/tasks/system/WaitForTask.php | WaitForTask._convertUnit | protected function _convertUnit($unit)
{
if ($unit === 'week') {
return self::ONE_WEEK;
}
if ($unit === 'day') {
return self::ONE_DAY;
}
if ($unit === 'hour') {
return self::ONE_HOUR;
}
if ($unit === 'minute') {
return self::ONE_MINUTE;
}
if ($unit === 'second') {
return self::ONE_SECOND;
}
if ($unit === 'millisecond') {
return self::ONE_MILLISECOND;
}
throw new BuildException("Illegal unit '$unit'");
} | php | protected function _convertUnit($unit)
{
if ($unit === 'week') {
return self::ONE_WEEK;
}
if ($unit === 'day') {
return self::ONE_DAY;
}
if ($unit === 'hour') {
return self::ONE_HOUR;
}
if ($unit === 'minute') {
return self::ONE_MINUTE;
}
if ($unit === 'second') {
return self::ONE_SECOND;
}
if ($unit === 'millisecond') {
return self::ONE_MILLISECOND;
}
throw new BuildException("Illegal unit '$unit'");
} | [
"protected",
"function",
"_convertUnit",
"(",
"$",
"unit",
")",
"{",
"if",
"(",
"$",
"unit",
"===",
"'week'",
")",
"{",
"return",
"self",
"::",
"ONE_WEEK",
";",
"}",
"if",
"(",
"$",
"unit",
"===",
"'day'",
")",
"{",
"return",
"self",
"::",
"ONE_DAY",... | Convert the unit to a multipler.
@param string $unit
@throws BuildException
@return int | [
"Convert",
"the",
"unit",
"to",
"a",
"multipler",
"."
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/tasks/system/WaitForTask.php#L93-L120 | train |
phingofficial/phing | classes/phing/tasks/system/WaitForTask.php | WaitForTask.main | public function main()
{
if ($this->countConditions() > 1) {
throw new BuildException("You must not nest more than one condition into <waitfor>");
}
if ($this->countConditions() < 1) {
throw new BuildException("You must nest a condition into <waitfor>");
}
$cs = $this->getIterator();
$condition = $cs->current();
$maxWaitMillis = $this->maxWait * $this->maxWaitMultiplier;
$checkEveryMillis = $this->checkEvery * $this->checkEveryMultiplier;
$start = microtime(true) * 1000;
$end = $start + $maxWaitMillis;
while (microtime(true) * 1000 < $end) {
if ($condition->evaluate()) {
$this->processSuccess();
return;
}
usleep($checkEveryMillis * 1000);
}
$this->processTimeout();
} | php | public function main()
{
if ($this->countConditions() > 1) {
throw new BuildException("You must not nest more than one condition into <waitfor>");
}
if ($this->countConditions() < 1) {
throw new BuildException("You must nest a condition into <waitfor>");
}
$cs = $this->getIterator();
$condition = $cs->current();
$maxWaitMillis = $this->maxWait * $this->maxWaitMultiplier;
$checkEveryMillis = $this->checkEvery * $this->checkEveryMultiplier;
$start = microtime(true) * 1000;
$end = $start + $maxWaitMillis;
while (microtime(true) * 1000 < $end) {
if ($condition->evaluate()) {
$this->processSuccess();
return;
}
usleep($checkEveryMillis * 1000);
}
$this->processTimeout();
} | [
"public",
"function",
"main",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"countConditions",
"(",
")",
">",
"1",
")",
"{",
"throw",
"new",
"BuildException",
"(",
"\"You must not nest more than one condition into <waitfor>\"",
")",
";",
"}",
"if",
"(",
"$",
... | Check repeatedly for the specified conditions until they become
true or the timeout expires.
@throws BuildException | [
"Check",
"repeatedly",
"for",
"the",
"specified",
"conditions",
"until",
"they",
"become",
"true",
"or",
"the",
"timeout",
"expires",
"."
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/tasks/system/WaitForTask.php#L160-L189 | train |
phingofficial/phing | classes/phing/tasks/system/ApplyTask.php | ApplyTask.prepare | protected function prepare()
{
// Log
$this->log('Initializing started ', $this->loglevel);
///// Validating the required parameters /////
if (!in_array($this->type, self::$types)) {
throw new BuildException('Type must be one of \'file\', \'dir\' or \'both\'.');
}
// Executable
if ($this->commandline->getExecutable() === null) {
$this->throwBuildException('Please provide "executable" information');
}
// Retrieving the current working directory
$this->currentdirectory = getcwd();
// Directory (in which the command should be executed)
if ($this->dir !== null) {
// Try expanding (any) symbolic links
if (!$this->dir->getCanonicalFile()->isDirectory()) {
$this->throwBuildException("'" . $this->dir . "' is not a valid directory");
}
// Change working directory
$dirchangestatus = @chdir($this->dir->getPath());
// Log
$this->log(
'Working directory change ' . ($dirchangestatus ? 'successful' : 'failed') . ' to ' . $this->dir->getPath(),
$this->loglevel
);
}
///// Preparing the task environment /////
// Getting current operationg system
$this->currentos = Phing::getProperty('os.name');
// Log
$this->log('Operating System identified : ' . $this->currentos, $this->loglevel);
// Getting the O.S. type identifier
// Validating the 'filesystem' for determining the OS type [UNIX, WINNT and WIN32]
// (Another usage could be with 'os.name' for determination)
if ('WIN' === strtoupper(substr(Phing::getProperty('host.fstype'), 0, 3))) {
$this->osvariant = 'WIN'; // Probable Windows flavour
} else {
$this->osvariant = 'LIN'; // Probable GNU/Linux flavour
}
// Log
$this->log('Operating System variant identified : ' . $this->osvariant, $this->loglevel);
if (count($this->filesets) === 0 && count($this->filelists) === 0 && count($this->getDirSets()) === 0) {
throw new BuildException(
"no resources specified",
$this->getLocation()
);
}
if ($this->targetFilePos !== null && $this->mapperElement === null) {
throw new BuildException(
"targetfile specified without mapper",
$this->getLocation()
);
}
if ($this->destDir !== null && $this->mapperElement === null) {
throw new BuildException(
"dest specified without mapper",
$this->getLocation()
);
}
if ($this->mapperElement !== null) {
$this->mapper = $this->mapperElement->getImplementation();
$this->log('Mapper identified : ' . get_class($this->mapper), $this->loglevel);
}
$this->commandline->setEscape($this->escape);
// Log
$this->log('Initializing completed ', $this->loglevel);
} | php | protected function prepare()
{
// Log
$this->log('Initializing started ', $this->loglevel);
///// Validating the required parameters /////
if (!in_array($this->type, self::$types)) {
throw new BuildException('Type must be one of \'file\', \'dir\' or \'both\'.');
}
// Executable
if ($this->commandline->getExecutable() === null) {
$this->throwBuildException('Please provide "executable" information');
}
// Retrieving the current working directory
$this->currentdirectory = getcwd();
// Directory (in which the command should be executed)
if ($this->dir !== null) {
// Try expanding (any) symbolic links
if (!$this->dir->getCanonicalFile()->isDirectory()) {
$this->throwBuildException("'" . $this->dir . "' is not a valid directory");
}
// Change working directory
$dirchangestatus = @chdir($this->dir->getPath());
// Log
$this->log(
'Working directory change ' . ($dirchangestatus ? 'successful' : 'failed') . ' to ' . $this->dir->getPath(),
$this->loglevel
);
}
///// Preparing the task environment /////
// Getting current operationg system
$this->currentos = Phing::getProperty('os.name');
// Log
$this->log('Operating System identified : ' . $this->currentos, $this->loglevel);
// Getting the O.S. type identifier
// Validating the 'filesystem' for determining the OS type [UNIX, WINNT and WIN32]
// (Another usage could be with 'os.name' for determination)
if ('WIN' === strtoupper(substr(Phing::getProperty('host.fstype'), 0, 3))) {
$this->osvariant = 'WIN'; // Probable Windows flavour
} else {
$this->osvariant = 'LIN'; // Probable GNU/Linux flavour
}
// Log
$this->log('Operating System variant identified : ' . $this->osvariant, $this->loglevel);
if (count($this->filesets) === 0 && count($this->filelists) === 0 && count($this->getDirSets()) === 0) {
throw new BuildException(
"no resources specified",
$this->getLocation()
);
}
if ($this->targetFilePos !== null && $this->mapperElement === null) {
throw new BuildException(
"targetfile specified without mapper",
$this->getLocation()
);
}
if ($this->destDir !== null && $this->mapperElement === null) {
throw new BuildException(
"dest specified without mapper",
$this->getLocation()
);
}
if ($this->mapperElement !== null) {
$this->mapper = $this->mapperElement->getImplementation();
$this->log('Mapper identified : ' . get_class($this->mapper), $this->loglevel);
}
$this->commandline->setEscape($this->escape);
// Log
$this->log('Initializing completed ', $this->loglevel);
} | [
"protected",
"function",
"prepare",
"(",
")",
"{",
"// Log",
"$",
"this",
"->",
"log",
"(",
"'Initializing started '",
",",
"$",
"this",
"->",
"loglevel",
")",
";",
"///// Validating the required parameters /////",
"if",
"(",
"!",
"in_array",
"(",
"$",
"this",
... | Initializes the task operations, i.e.
- Required information validation
- Working directory
@return void
@throws \BuildException
@throws IOException | [
"Initializes",
"the",
"task",
"operations",
"i",
".",
"e",
".",
"-",
"Required",
"information",
"validation",
"-",
"Working",
"directory"
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/tasks/system/ApplyTask.php#L445-L529 | train |
phingofficial/phing | classes/phing/tasks/system/ApplyTask.php | ApplyTask.cleanup | protected function cleanup($return = null, $output = null): void
{
// Restore working directory
if ($this->dir !== null) {
@chdir($this->currentdirectory);
}
} | php | protected function cleanup($return = null, $output = null): void
{
// Restore working directory
if ($this->dir !== null) {
@chdir($this->currentdirectory);
}
} | [
"protected",
"function",
"cleanup",
"(",
"$",
"return",
"=",
"null",
",",
"$",
"output",
"=",
"null",
")",
":",
"void",
"{",
"// Restore working directory",
"if",
"(",
"$",
"this",
"->",
"dir",
"!==",
"null",
")",
"{",
"@",
"chdir",
"(",
"$",
"this",
... | Runs cleanup tasks post execution
- Restore working directory
@return void | [
"Runs",
"cleanup",
"tasks",
"post",
"execution",
"-",
"Restore",
"working",
"directory"
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/tasks/system/ApplyTask.php#L758-L764 | train |
phingofficial/phing | classes/phing/tasks/system/ApplyTask.php | ApplyTask.getFilePath | public function getFilePath($filename, $basedir, $relative)
{
// Validating the 'file' information
$files = (array) $filename;
// Processing the file information
foreach ($files as $index => $file) {
$absolutefilename = (($relative === false) ? ($basedir . PhingFile::$separator) : '');
$absolutefilename .= $file;
if ($relative === false) {
$files[$index] = (new FileUtils())->normalize($absolutefilename);
} else {
$files[$index] = $absolutefilename;
}
}
return (is_array($filename) ? $files : $files[0]);
} | php | public function getFilePath($filename, $basedir, $relative)
{
// Validating the 'file' information
$files = (array) $filename;
// Processing the file information
foreach ($files as $index => $file) {
$absolutefilename = (($relative === false) ? ($basedir . PhingFile::$separator) : '');
$absolutefilename .= $file;
if ($relative === false) {
$files[$index] = (new FileUtils())->normalize($absolutefilename);
} else {
$files[$index] = $absolutefilename;
}
}
return (is_array($filename) ? $files : $files[0]);
} | [
"public",
"function",
"getFilePath",
"(",
"$",
"filename",
",",
"$",
"basedir",
",",
"$",
"relative",
")",
"{",
"// Validating the 'file' information",
"$",
"files",
"=",
"(",
"array",
")",
"$",
"filename",
";",
"// Processing the file information",
"foreach",
"("... | Prepares the filename per base directory and relative path information
@param array|string $filename
@param $basedir
@param $relative
@return mixed processed filenames
@throws IOException | [
"Prepares",
"the",
"filename",
"per",
"base",
"directory",
"and",
"relative",
"path",
"information"
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/tasks/system/ApplyTask.php#L777-L794 | train |
phingofficial/phing | classes/phing/util/PathTokenizer.php | PathTokenizer.nextToken | public function nextToken()
{
if ($this->lookahead !== null) {
$token = $this->lookahead;
$this->lookahead = null;
} else {
$token = trim(array_shift($this->tokens));
}
if (strlen($token) === 1 && Character::isLetter($token{0})
&& $this->dosStyleFilesystem
&& !empty($this->tokens)
) {
// we are on a dos style system so this path could be a drive
// spec. We look at the next token
$nextToken = trim(array_shift($this->tokens));
if (StringHelper::startsWith('\\', $nextToken) || StringHelper::startsWith('/', $nextToken)) {
// we know we are on a DOS style platform and the next path
// starts with a slash or backslash, so we know this is a
// drive spec
$token .= ':' . $nextToken;
} else {
// store the token just read for next time
$this->lookahead = $nextToken;
}
}
return $token;
} | php | public function nextToken()
{
if ($this->lookahead !== null) {
$token = $this->lookahead;
$this->lookahead = null;
} else {
$token = trim(array_shift($this->tokens));
}
if (strlen($token) === 1 && Character::isLetter($token{0})
&& $this->dosStyleFilesystem
&& !empty($this->tokens)
) {
// we are on a dos style system so this path could be a drive
// spec. We look at the next token
$nextToken = trim(array_shift($this->tokens));
if (StringHelper::startsWith('\\', $nextToken) || StringHelper::startsWith('/', $nextToken)) {
// we know we are on a DOS style platform and the next path
// starts with a slash or backslash, so we know this is a
// drive spec
$token .= ':' . $nextToken;
} else {
// store the token just read for next time
$this->lookahead = $nextToken;
}
}
return $token;
} | [
"public",
"function",
"nextToken",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"lookahead",
"!==",
"null",
")",
"{",
"$",
"token",
"=",
"$",
"this",
"->",
"lookahead",
";",
"$",
"this",
"->",
"lookahead",
"=",
"null",
";",
"}",
"else",
"{",
"$",
... | Returns the next path element from this tokenizer.
@return string the next path element from this tokenizer.
@throws Exception if there are no more elements in this tokenizer's path. | [
"Returns",
"the",
"next",
"path",
"element",
"from",
"this",
"tokenizer",
"."
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/util/PathTokenizer.php#L99-L136 | train |
phingofficial/phing | classes/phing/tasks/ext/ssh/SshTask.php | SshTask.handleStream | protected function handleStream($stream)
{
if (!$stream) {
throw new BuildException("Could not execute command!");
}
$this->log("Executing command {$this->command}", Project::MSG_VERBOSE);
stream_set_blocking($stream, true);
$result = stream_get_contents($stream);
// always load contents of error stream, to make sure not one command failed
$stderr_stream = ssh2_fetch_stream($stream, SSH2_STREAM_STDERR);
stream_set_blocking($stderr_stream, true);
$result_error = stream_get_contents($stderr_stream);
if ($this->display) {
print($result);
}
if (!empty($this->property)) {
$this->project->setProperty($this->property, $result);
}
fclose($stream);
if (isset($stderr_stream)) {
fclose($stderr_stream);
}
if ($this->failonerror && !empty($result_error)) {
throw new BuildException("SSH Task failed: " . $result_error);
}
} | php | protected function handleStream($stream)
{
if (!$stream) {
throw new BuildException("Could not execute command!");
}
$this->log("Executing command {$this->command}", Project::MSG_VERBOSE);
stream_set_blocking($stream, true);
$result = stream_get_contents($stream);
// always load contents of error stream, to make sure not one command failed
$stderr_stream = ssh2_fetch_stream($stream, SSH2_STREAM_STDERR);
stream_set_blocking($stderr_stream, true);
$result_error = stream_get_contents($stderr_stream);
if ($this->display) {
print($result);
}
if (!empty($this->property)) {
$this->project->setProperty($this->property, $result);
}
fclose($stream);
if (isset($stderr_stream)) {
fclose($stderr_stream);
}
if ($this->failonerror && !empty($result_error)) {
throw new BuildException("SSH Task failed: " . $result_error);
}
} | [
"protected",
"function",
"handleStream",
"(",
"$",
"stream",
")",
"{",
"if",
"(",
"!",
"$",
"stream",
")",
"{",
"throw",
"new",
"BuildException",
"(",
"\"Could not execute command!\"",
")",
";",
"}",
"$",
"this",
"->",
"log",
"(",
"\"Executing command {$this->... | This function reads the streams from the ssh2_exec
command, stores output data, checks for errors and
closes the streams properly.
@param $stream
@throws BuildException | [
"This",
"function",
"reads",
"the",
"streams",
"from",
"the",
"ssh2_exec",
"command",
"stores",
"output",
"data",
"checks",
"for",
"errors",
"and",
"closes",
"the",
"streams",
"properly",
"."
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/tasks/ext/ssh/SshTask.php#L360-L392 | train |
phingofficial/phing | classes/phing/types/selectors/SelectorUtils.php | SelectorUtils.isOutOfDate | public static function isOutOfDate(PhingFile $src, PhingFile $target, $granularity)
{
if (!$src->exists()) {
return false;
}
if (!$target->exists()) {
return true;
}
if (($src->lastModified() - $granularity) > $target->lastModified()) {
return true;
}
return false;
} | php | public static function isOutOfDate(PhingFile $src, PhingFile $target, $granularity)
{
if (!$src->exists()) {
return false;
}
if (!$target->exists()) {
return true;
}
if (($src->lastModified() - $granularity) > $target->lastModified()) {
return true;
}
return false;
} | [
"public",
"static",
"function",
"isOutOfDate",
"(",
"PhingFile",
"$",
"src",
",",
"PhingFile",
"$",
"target",
",",
"$",
"granularity",
")",
"{",
"if",
"(",
"!",
"$",
"src",
"->",
"exists",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
... | Returns dependency information on these two files. If src has been
modified later than target, it returns true. If target doesn't exist,
it likewise returns true. Otherwise, target is newer than src and
is not out of date, thus the method returns false. It also returns
false if the src file doesn't even exist, since how could the
target then be out of date.
@param PhingFile $src the original file
@param PhingFile $target the file being compared against
@param int $granularity the amount in seconds of slack we will give in
determining out of dateness
@return bool whether the target is out of date | [
"Returns",
"dependency",
"information",
"on",
"these",
"two",
"files",
".",
"If",
"src",
"has",
"been",
"modified",
"later",
"than",
"target",
"it",
"returns",
"true",
".",
"If",
"target",
"doesn",
"t",
"exist",
"it",
"likewise",
"returns",
"true",
".",
"O... | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/types/selectors/SelectorUtils.php#L194-L207 | train |
phingofficial/phing | classes/phing/tasks/system/ForeachTask.php | ForeachTask.process | protected function process(Task $callee, PhingFile $fromDir, $srcFiles, $srcDirs)
{
$mapper = null;
if ($this->mapperElement !== null) {
$mapper = $this->mapperElement->getImplementation();
}
$filecount = count($srcFiles);
$this->total_files += $filecount;
$this->processResources($filecount, $srcFiles, $callee, $fromDir, $mapper);
$dircount = count($srcDirs);
$this->total_dirs += $dircount;
$this->processResources($dircount, $srcDirs, $callee, $fromDir, $mapper);
} | php | protected function process(Task $callee, PhingFile $fromDir, $srcFiles, $srcDirs)
{
$mapper = null;
if ($this->mapperElement !== null) {
$mapper = $this->mapperElement->getImplementation();
}
$filecount = count($srcFiles);
$this->total_files += $filecount;
$this->processResources($filecount, $srcFiles, $callee, $fromDir, $mapper);
$dircount = count($srcDirs);
$this->total_dirs += $dircount;
$this->processResources($dircount, $srcDirs, $callee, $fromDir, $mapper);
} | [
"protected",
"function",
"process",
"(",
"Task",
"$",
"callee",
",",
"PhingFile",
"$",
"fromDir",
",",
"$",
"srcFiles",
",",
"$",
"srcDirs",
")",
"{",
"$",
"mapper",
"=",
"null",
";",
"if",
"(",
"$",
"this",
"->",
"mapperElement",
"!==",
"null",
")",
... | Processes a list of files & directories
@param PhingCallTask $callee
@param PhingFile $fromDir
@param array $srcFiles
@param array $srcDirs | [
"Processes",
"a",
"list",
"of",
"files",
"&",
"directories"
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/tasks/system/ForeachTask.php#L248-L265 | train |
phingofficial/phing | classes/phing/filters/SortFilter.php | SortFilter.chain | public function chain(Reader $rdr)
{
$newFilter = new SortFilter($rdr);
$newFilter->setReverse($this->isReverse());
$newFilter->setInitialized(true);
return $newFilter;
} | php | public function chain(Reader $rdr)
{
$newFilter = new SortFilter($rdr);
$newFilter->setReverse($this->isReverse());
$newFilter->setInitialized(true);
return $newFilter;
} | [
"public",
"function",
"chain",
"(",
"Reader",
"$",
"rdr",
")",
"{",
"$",
"newFilter",
"=",
"new",
"SortFilter",
"(",
"$",
"rdr",
")",
";",
"$",
"newFilter",
"->",
"setReverse",
"(",
"$",
"this",
"->",
"isReverse",
"(",
")",
")",
";",
"$",
"newFilter"... | Creates a new SortReader using the passed in Reader for instantiation.
@param Reader $rdr
A Reader object providing the underlying stream. Must not be
<code>null</code>.
@return SortFilter a new filter based on this configuration, but filtering the
specified reader | [
"Creates",
"a",
"new",
"SortReader",
"using",
"the",
"passed",
"in",
"Reader",
"for",
"instantiation",
"."
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/filters/SortFilter.php#L144-L150 | train |
phingofficial/phing | classes/phing/filters/SortFilter.php | SortFilter.initialize | private function initialize()
{
// get parameters
$params = $this->getParameters();
foreach ($params as $param) {
$paramName = $param->getName();
if (self::$REVERSE_KEY === $paramName) {
$this->setReverse(StringHelper::booleanValue($param->getValue()));
continue;
}
}
} | php | private function initialize()
{
// get parameters
$params = $this->getParameters();
foreach ($params as $param) {
$paramName = $param->getName();
if (self::$REVERSE_KEY === $paramName) {
$this->setReverse(StringHelper::booleanValue($param->getValue()));
continue;
}
}
} | [
"private",
"function",
"initialize",
"(",
")",
"{",
"// get parameters",
"$",
"params",
"=",
"$",
"this",
"->",
"getParameters",
"(",
")",
";",
"foreach",
"(",
"$",
"params",
"as",
"$",
"param",
")",
"{",
"$",
"paramName",
"=",
"$",
"param",
"->",
"get... | Scans the parameters list | [
"Scans",
"the",
"parameters",
"list"
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/filters/SortFilter.php#L179-L191 | train |
phingofficial/phing | classes/phing/tasks/ext/phpunit/PHPUnitReportTask.php | PHPUnitReportTask.transform | protected function transform(DOMDocument $document)
{
if (!$this->toDir->exists()) {
throw new BuildException("Directory '" . $this->toDir . "' does not exist");
}
$xslfile = $this->getStyleSheet();
$xsl = new DOMDocument();
$xsl->load($xslfile->getAbsolutePath());
$proc = new XSLTProcessor();
if (defined('XSL_SECPREF_WRITE_FILE')) {
$proc->setSecurityPrefs(XSL_SECPREF_WRITE_FILE | XSL_SECPREF_CREATE_DIRECTORY);
}
$proc->registerPHPFunctions('nl2br');
$proc->importStylesheet($xsl);
$proc->setParameter('', 'output.sorttable', (string) $this->useSortTable);
if ($this->format === "noframes") {
$writer = new FileWriter(new PhingFile($this->toDir, "phpunit-noframes.html"));
$writer->write($proc->transformToXml($document));
$writer->close();
} else {
ExtendedFileStream::registerStream();
$toDir = (string) $this->toDir;
// urlencode() the path if we're on Windows
if (FileSystem::getFileSystem()->getSeparator() === '\\') {
$toDir = urlencode($toDir);
}
// no output for the framed report
// it's all done by extension...
$proc->setParameter('', 'output.dir', $toDir);
$proc->transformToXml($document);
ExtendedFileStream::unregisterStream();
}
} | php | protected function transform(DOMDocument $document)
{
if (!$this->toDir->exists()) {
throw new BuildException("Directory '" . $this->toDir . "' does not exist");
}
$xslfile = $this->getStyleSheet();
$xsl = new DOMDocument();
$xsl->load($xslfile->getAbsolutePath());
$proc = new XSLTProcessor();
if (defined('XSL_SECPREF_WRITE_FILE')) {
$proc->setSecurityPrefs(XSL_SECPREF_WRITE_FILE | XSL_SECPREF_CREATE_DIRECTORY);
}
$proc->registerPHPFunctions('nl2br');
$proc->importStylesheet($xsl);
$proc->setParameter('', 'output.sorttable', (string) $this->useSortTable);
if ($this->format === "noframes") {
$writer = new FileWriter(new PhingFile($this->toDir, "phpunit-noframes.html"));
$writer->write($proc->transformToXml($document));
$writer->close();
} else {
ExtendedFileStream::registerStream();
$toDir = (string) $this->toDir;
// urlencode() the path if we're on Windows
if (FileSystem::getFileSystem()->getSeparator() === '\\') {
$toDir = urlencode($toDir);
}
// no output for the framed report
// it's all done by extension...
$proc->setParameter('', 'output.dir', $toDir);
$proc->transformToXml($document);
ExtendedFileStream::unregisterStream();
}
} | [
"protected",
"function",
"transform",
"(",
"DOMDocument",
"$",
"document",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"toDir",
"->",
"exists",
"(",
")",
")",
"{",
"throw",
"new",
"BuildException",
"(",
"\"Directory '\"",
".",
"$",
"this",
"->",
"toDir"... | Transforms the DOM document
@param DOMDocument $document
@throws BuildException
@throws IOException | [
"Transforms",
"the",
"DOM",
"document"
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/tasks/ext/phpunit/PHPUnitReportTask.php#L150-L190 | train |
phingofficial/phing | classes/phing/tasks/system/MkdirTask.php | MkdirTask.main | public function main()
{
if ($this->dir === null) {
throw new BuildException("dir attribute is required", $this->getLocation());
}
if ($this->dir->isFile()) {
throw new BuildException(
"Unable to create directory as a file already exists with that name: " . $this->dir->getAbsolutePath()
);
}
if (!$this->dir->exists()) {
$result = $this->dir->mkdirs($this->mode);
if (!$result) {
if ($this->dir->exists()) {
$this->log("A different process or task has already created " . $this->dir->getAbsolutePath());
return;
}
$msg = "Directory " . $this->dir->getAbsolutePath() . " creation was not successful for an unknown reason";
throw new BuildException($msg, $this->getLocation());
}
$this->log("Created dir: " . $this->dir->getAbsolutePath());
}
} | php | public function main()
{
if ($this->dir === null) {
throw new BuildException("dir attribute is required", $this->getLocation());
}
if ($this->dir->isFile()) {
throw new BuildException(
"Unable to create directory as a file already exists with that name: " . $this->dir->getAbsolutePath()
);
}
if (!$this->dir->exists()) {
$result = $this->dir->mkdirs($this->mode);
if (!$result) {
if ($this->dir->exists()) {
$this->log("A different process or task has already created " . $this->dir->getAbsolutePath());
return;
}
$msg = "Directory " . $this->dir->getAbsolutePath() . " creation was not successful for an unknown reason";
throw new BuildException($msg, $this->getLocation());
}
$this->log("Created dir: " . $this->dir->getAbsolutePath());
}
} | [
"public",
"function",
"main",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"dir",
"===",
"null",
")",
"{",
"throw",
"new",
"BuildException",
"(",
"\"dir attribute is required\"",
",",
"$",
"this",
"->",
"getLocation",
"(",
")",
")",
";",
"}",
"if",
"("... | create the directory and all parents
@throws BuildException if dir is somehow invalid, or creation failed. | [
"create",
"the",
"directory",
"and",
"all",
"parents"
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/tasks/system/MkdirTask.php#L57-L80 | train |
phingofficial/phing | classes/phing/tasks/ext/phk/PhkPackageTask.php | PhkPackageTask.main | public function main()
{
/*
* Check for empty first - speed ;)
*/
if (!is_file($this->phkCreatorPath)) {
throw new BuildException('You must specify the "phkcreatorpath" attribute for PHK task.');
}
if (empty($this->inputDirectory)) {
throw new BuildException('You must specify the "inputdirectory" attribute for PHK task.');
}
if (empty($this->outputFile)) {
throw new BuildException('You must specify the "outputfile" attribute for PHK task.');
}
include_once $this->phkCreatorPath;
$mountPoint = PHK_Mgr::mount($this->outputFile, PHK::F_CREATOR);
$phkManager = PHK_Mgr::instance($mountPoint);
/*
* Add files.
*/
$phkManager->ftree()->merge_file_tree('/', $this->inputDirectory, $this->modifiers);
/*
* Add web_access to options, if present.
*/
if (null !== $this->webAccess) {
$webAccessPaths = $this->webAccess->getPaths();
if (!empty($webAccessPaths)) {
$this->options['web_access'] = $webAccessPaths;
}
}
$phkManager->set_options($this->options);
/*
* Intercept output (in PHP we can't intercept stream).
*/
ob_start();
/*
* Create file...
*/
$phkManager->dump();
/*
* Print with Phing log...
*/
$output = trim(ob_get_clean());
$output = explode("\n", $output);
foreach ($output as $line) {
/*
* Delete all '--- *' lines. Bluh!
*/
if (0 === strpos($line, '---')) {
continue;
}
$this->log($line);
}
/*
* Set rights for generated file... Don't use umask() - see
* notes in official documentation for this function.
*/
chmod($this->outputFile, 0644);
} | php | public function main()
{
/*
* Check for empty first - speed ;)
*/
if (!is_file($this->phkCreatorPath)) {
throw new BuildException('You must specify the "phkcreatorpath" attribute for PHK task.');
}
if (empty($this->inputDirectory)) {
throw new BuildException('You must specify the "inputdirectory" attribute for PHK task.');
}
if (empty($this->outputFile)) {
throw new BuildException('You must specify the "outputfile" attribute for PHK task.');
}
include_once $this->phkCreatorPath;
$mountPoint = PHK_Mgr::mount($this->outputFile, PHK::F_CREATOR);
$phkManager = PHK_Mgr::instance($mountPoint);
/*
* Add files.
*/
$phkManager->ftree()->merge_file_tree('/', $this->inputDirectory, $this->modifiers);
/*
* Add web_access to options, if present.
*/
if (null !== $this->webAccess) {
$webAccessPaths = $this->webAccess->getPaths();
if (!empty($webAccessPaths)) {
$this->options['web_access'] = $webAccessPaths;
}
}
$phkManager->set_options($this->options);
/*
* Intercept output (in PHP we can't intercept stream).
*/
ob_start();
/*
* Create file...
*/
$phkManager->dump();
/*
* Print with Phing log...
*/
$output = trim(ob_get_clean());
$output = explode("\n", $output);
foreach ($output as $line) {
/*
* Delete all '--- *' lines. Bluh!
*/
if (0 === strpos($line, '---')) {
continue;
}
$this->log($line);
}
/*
* Set rights for generated file... Don't use umask() - see
* notes in official documentation for this function.
*/
chmod($this->outputFile, 0644);
} | [
"public",
"function",
"main",
"(",
")",
"{",
"/*\n * Check for empty first - speed ;)\n */",
"if",
"(",
"!",
"is_file",
"(",
"$",
"this",
"->",
"phkCreatorPath",
")",
")",
"{",
"throw",
"new",
"BuildException",
"(",
"'You must specify the \"phkcreatorpat... | Main method... | [
"Main",
"method",
"..."
] | 4b1797694dc65505af496ca2e1a3470efb9e35e1 | https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/tasks/ext/phk/PhkPackageTask.php#L191-L257 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.