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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
Xiphe/HTML | src/Xiphe/HTML/core/Config.php | Config.set | public static function set($key, $value, $preferGlobal = false)
{
if (!isset(self::$_config[$key])) {
return false;
}
if (!$preferGlobal && self::$_CurrentHTMLInstance && isset(self::$_CurrentHTMLInstance->$key)) {
self::s3t(self::$_CurrentHTMLInstance->$key, $value);
} else {
if (class_exists('Xiphe\THEMASTER\core\THE')
&& class_exists(TM\THE::SETTINGS)
) {
$prev = TM\THEWPSETTINGS::sGet_setting($key, XIPHE_HTML_TEXTID);
self::s3t($prev, $value);
TM\THESETTINGS::sSet_setting($key, XIPHE_HTML_TEXTID, $prev);
} else {
self::s3t(self::$_config[$key], $value);
}
}
return true;
} | php | public static function set($key, $value, $preferGlobal = false)
{
if (!isset(self::$_config[$key])) {
return false;
}
if (!$preferGlobal && self::$_CurrentHTMLInstance && isset(self::$_CurrentHTMLInstance->$key)) {
self::s3t(self::$_CurrentHTMLInstance->$key, $value);
} else {
if (class_exists('Xiphe\THEMASTER\core\THE')
&& class_exists(TM\THE::SETTINGS)
) {
$prev = TM\THEWPSETTINGS::sGet_setting($key, XIPHE_HTML_TEXTID);
self::s3t($prev, $value);
TM\THESETTINGS::sSet_setting($key, XIPHE_HTML_TEXTID, $prev);
} else {
self::s3t(self::$_config[$key], $value);
}
}
return true;
} | [
"public",
"static",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"preferGlobal",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"_config",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"false",
";",
... | Changes a global configuration.
@param string $key the settings name
@param mixed $value the settings value
@param boolean $preferGlobal Eliminates the instance setting from hierarchy.
@return boolean weather or not the setting was set. | [
"Changes",
"a",
"global",
"configuration",
"."
] | 60cd0e869a75c535fdd785a26e351ded1507f1de | https://github.com/Xiphe/HTML/blob/60cd0e869a75c535fdd785a26e351ded1507f1de/src/Xiphe/HTML/core/Config.php#L284-L305 | train |
Xiphe/HTML | src/Xiphe/HTML/core/Config.php | Config.s3t | public static function s3t(&$target, $value)
{
if ($value === '++' && is_numeric(($oldValue = $target))) {
$value = $oldValue + 1;
} elseif ($value === '--' && is_numeric(($oldValue = $target))) {
$value = $oldValue - 1;
}
$target = $value;
} | php | public static function s3t(&$target, $value)
{
if ($value === '++' && is_numeric(($oldValue = $target))) {
$value = $oldValue + 1;
} elseif ($value === '--' && is_numeric(($oldValue = $target))) {
$value = $oldValue - 1;
}
$target = $value;
} | [
"public",
"static",
"function",
"s3t",
"(",
"&",
"$",
"target",
",",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"===",
"'++'",
"&&",
"is_numeric",
"(",
"(",
"$",
"oldValue",
"=",
"$",
"target",
")",
")",
")",
"{",
"$",
"value",
"=",
"$",
... | Sets the given value to the linked target.
Allows '++' and '--' for increment or decrement the numeric target.
@param mixed &$target the place were the value should be set to.
@param mixed $value the value.
@return void | [
"Sets",
"the",
"given",
"value",
"to",
"the",
"linked",
"target",
"."
] | 60cd0e869a75c535fdd785a26e351ded1507f1de | https://github.com/Xiphe/HTML/blob/60cd0e869a75c535fdd785a26e351ded1507f1de/src/Xiphe/HTML/core/Config.php#L317-L326 | train |
M6Web/WsClientBundle | src/M6Web/Bundle/WSClientBundle/Adapter/Response/GuzzleResponseAdapter.php | GuzzleResponseAdapter.getHeaderValue | public function getHeaderValue($header, $glue = '')
{
if ($header = $this->response->getHeader($header, true)) {
if (is_array($header)) {
return implode($glue, $header);
}
}
return $header;
} | php | public function getHeaderValue($header, $glue = '')
{
if ($header = $this->response->getHeader($header, true)) {
if (is_array($header)) {
return implode($glue, $header);
}
}
return $header;
} | [
"public",
"function",
"getHeaderValue",
"(",
"$",
"header",
",",
"$",
"glue",
"=",
"''",
")",
"{",
"if",
"(",
"$",
"header",
"=",
"$",
"this",
"->",
"response",
"->",
"getHeader",
"(",
"$",
"header",
",",
"true",
")",
")",
"{",
"if",
"(",
"is_array... | return a scalar value of \Guzzle\Http\Message\Header type
@param string $header Header name
@param string $glue Separator (default='')
@return string | [
"return",
"a",
"scalar",
"value",
"of",
"\\",
"Guzzle",
"\\",
"Http",
"\\",
"Message",
"\\",
"Header",
"type"
] | 191df2ac2bbc9a427933a28e8f3b8d2f69f3918d | https://github.com/M6Web/WsClientBundle/blob/191df2ac2bbc9a427933a28e8f3b8d2f69f3918d/src/M6Web/Bundle/WSClientBundle/Adapter/Response/GuzzleResponseAdapter.php#L87-L96 | train |
Evaneos/burrow-tools | src/Legacy/PublisherFactory.php | PublisherFactory.buildAsync | public static function buildAsync(
$host,
$port,
$user,
$pass,
$exchangeName,
$escapeMode = self::ESCAPE_MODE_SERIALIZE,
$timeout = 0
) {
return self::build($host, $port, $user, $pass, $exchangeName, false, $escapeMode, $timeout);
} | php | public static function buildAsync(
$host,
$port,
$user,
$pass,
$exchangeName,
$escapeMode = self::ESCAPE_MODE_SERIALIZE,
$timeout = 0
) {
return self::build($host, $port, $user, $pass, $exchangeName, false, $escapeMode, $timeout);
} | [
"public",
"static",
"function",
"buildAsync",
"(",
"$",
"host",
",",
"$",
"port",
",",
"$",
"user",
",",
"$",
"pass",
",",
"$",
"exchangeName",
",",
"$",
"escapeMode",
"=",
"self",
"::",
"ESCAPE_MODE_SERIALIZE",
",",
"$",
"timeout",
"=",
"0",
")",
"{",... | Build an async publisher
@param string $host
@param string $port
@param string $user
@param string $pass
@param string $exchangeName
@param string $escapeMode
@param int $timeout
@return QueuePublisher | [
"Build",
"an",
"async",
"publisher"
] | a807d8a2fcc3cfd0064644cf18895c0573a3361c | https://github.com/Evaneos/burrow-tools/blob/a807d8a2fcc3cfd0064644cf18895c0573a3361c/src/Legacy/PublisherFactory.php#L36-L46 | train |
Evaneos/burrow-tools | src/Legacy/PublisherFactory.php | PublisherFactory.buildSync | public static function buildSync(
$host,
$port,
$user,
$pass,
$exchangeName,
$escapeMode = self::ESCAPE_MODE_SERIALIZE,
$timeout = 0
) {
return self::build($host, $port, $user, $pass, $exchangeName, true, $escapeMode, $timeout);
} | php | public static function buildSync(
$host,
$port,
$user,
$pass,
$exchangeName,
$escapeMode = self::ESCAPE_MODE_SERIALIZE,
$timeout = 0
) {
return self::build($host, $port, $user, $pass, $exchangeName, true, $escapeMode, $timeout);
} | [
"public",
"static",
"function",
"buildSync",
"(",
"$",
"host",
",",
"$",
"port",
",",
"$",
"user",
",",
"$",
"pass",
",",
"$",
"exchangeName",
",",
"$",
"escapeMode",
"=",
"self",
"::",
"ESCAPE_MODE_SERIALIZE",
",",
"$",
"timeout",
"=",
"0",
")",
"{",
... | Build a sync publisher
@param string $host
@param string $port
@param string $user
@param string $pass
@param string $exchangeName
@param string $escapeMode
@param int $timeout
@return QueuePublisher | [
"Build",
"a",
"sync",
"publisher"
] | a807d8a2fcc3cfd0064644cf18895c0573a3361c | https://github.com/Evaneos/burrow-tools/blob/a807d8a2fcc3cfd0064644cf18895c0573a3361c/src/Legacy/PublisherFactory.php#L61-L71 | train |
Evaneos/burrow-tools | src/Legacy/PublisherFactory.php | PublisherFactory.build | private static function build(
$host,
$port,
$user,
$pass,
$exchangeName,
$sync,
$escapeMode,
$timeout
) {
$driver = DriverFactory::getDriver([
'host' => $host,
'port' => $port,
'user' => $user,
'pwd' => $pass
]);
$publisher = ($sync) ?
new SyncPublisher($driver, $exchangeName, $timeout):
new AsyncPublisher($driver, $exchangeName);
if ($escapeMode === self::ESCAPE_MODE_NONE) {
return $publisher;
}
if ($escapeMode === self::ESCAPE_MODE_JSON) {
return new SerializingPublisher($publisher, new JsonSerializer());
}
if ($escapeMode === self::ESCAPE_MODE_SERIALIZE) {
return new SerializingPublisher($publisher, new PhpSerializer());
}
throw new \InvalidArgumentException('Bad serializer name');
} | php | private static function build(
$host,
$port,
$user,
$pass,
$exchangeName,
$sync,
$escapeMode,
$timeout
) {
$driver = DriverFactory::getDriver([
'host' => $host,
'port' => $port,
'user' => $user,
'pwd' => $pass
]);
$publisher = ($sync) ?
new SyncPublisher($driver, $exchangeName, $timeout):
new AsyncPublisher($driver, $exchangeName);
if ($escapeMode === self::ESCAPE_MODE_NONE) {
return $publisher;
}
if ($escapeMode === self::ESCAPE_MODE_JSON) {
return new SerializingPublisher($publisher, new JsonSerializer());
}
if ($escapeMode === self::ESCAPE_MODE_SERIALIZE) {
return new SerializingPublisher($publisher, new PhpSerializer());
}
throw new \InvalidArgumentException('Bad serializer name');
} | [
"private",
"static",
"function",
"build",
"(",
"$",
"host",
",",
"$",
"port",
",",
"$",
"user",
",",
"$",
"pass",
",",
"$",
"exchangeName",
",",
"$",
"sync",
",",
"$",
"escapeMode",
",",
"$",
"timeout",
")",
"{",
"$",
"driver",
"=",
"DriverFactory",
... | Build a publisher
@param string $host
@param string $port
@param string $user
@param string $pass
@param string $exchangeName
@param bool $sync
@param string $escapeMode
@param int $timeout
@return QueuePublisher | [
"Build",
"a",
"publisher"
] | a807d8a2fcc3cfd0064644cf18895c0573a3361c | https://github.com/Evaneos/burrow-tools/blob/a807d8a2fcc3cfd0064644cf18895c0573a3361c/src/Legacy/PublisherFactory.php#L87-L121 | train |
stubbles/stubbles-xml | src/main/php/DomXmlStreamWriter.php | DomXmlStreamWriter.doWriteStartElement | protected function doWriteStartElement(string $elementName)
{
$this->append(
function(\DOMNode $parent) use ($elementName)
{
$element = $this->doc->createElement($elementName);
$parent->appendChild($element);
array_push($this->openElements, $element);
},
'start element: "' . $elementName . '"'
);
} | php | protected function doWriteStartElement(string $elementName)
{
$this->append(
function(\DOMNode $parent) use ($elementName)
{
$element = $this->doc->createElement($elementName);
$parent->appendChild($element);
array_push($this->openElements, $element);
},
'start element: "' . $elementName . '"'
);
} | [
"protected",
"function",
"doWriteStartElement",
"(",
"string",
"$",
"elementName",
")",
"{",
"$",
"this",
"->",
"append",
"(",
"function",
"(",
"\\",
"DOMNode",
"$",
"parent",
")",
"use",
"(",
"$",
"elementName",
")",
"{",
"$",
"element",
"=",
"$",
"this... | really writes an opening tag
@param string $elementName | [
"really",
"writes",
"an",
"opening",
"tag"
] | 595bc5266190fd9661e9eee140cf2378f623e50a | https://github.com/stubbles/stubbles-xml/blob/595bc5266190fd9661e9eee140cf2378f623e50a/src/main/php/DomXmlStreamWriter.php#L73-L84 | train |
stubbles/stubbles-xml | src/main/php/DomXmlStreamWriter.php | DomXmlStreamWriter.writeText | public function writeText(string $data): XmlStreamWriter
{
return $this->append(
function(\DOMNode $parent) use ($data)
{
$parent->appendChild(
$this->doc->createTextNode($this->encode($data))
);
},
'text'
);
} | php | public function writeText(string $data): XmlStreamWriter
{
return $this->append(
function(\DOMNode $parent) use ($data)
{
$parent->appendChild(
$this->doc->createTextNode($this->encode($data))
);
},
'text'
);
} | [
"public",
"function",
"writeText",
"(",
"string",
"$",
"data",
")",
":",
"XmlStreamWriter",
"{",
"return",
"$",
"this",
"->",
"append",
"(",
"function",
"(",
"\\",
"DOMNode",
"$",
"parent",
")",
"use",
"(",
"$",
"data",
")",
"{",
"$",
"parent",
"->",
... | Write a text node
@param string $data
@return \stubbles\xml\XmlStreamWriter | [
"Write",
"a",
"text",
"node"
] | 595bc5266190fd9661e9eee140cf2378f623e50a | https://github.com/stubbles/stubbles-xml/blob/595bc5266190fd9661e9eee140cf2378f623e50a/src/main/php/DomXmlStreamWriter.php#L92-L103 | train |
stubbles/stubbles-xml | src/main/php/DomXmlStreamWriter.php | DomXmlStreamWriter.writeCData | public function writeCData(string $cdata): XmlStreamWriter
{
return $this->append(
function(\DOMNode $parent) use ($cdata)
{
$parent->appendChild(
$this->doc->createCDATASection($this->encode($cdata))
);
},
'cdata'
);
} | php | public function writeCData(string $cdata): XmlStreamWriter
{
return $this->append(
function(\DOMNode $parent) use ($cdata)
{
$parent->appendChild(
$this->doc->createCDATASection($this->encode($cdata))
);
},
'cdata'
);
} | [
"public",
"function",
"writeCData",
"(",
"string",
"$",
"cdata",
")",
":",
"XmlStreamWriter",
"{",
"return",
"$",
"this",
"->",
"append",
"(",
"function",
"(",
"\\",
"DOMNode",
"$",
"parent",
")",
"use",
"(",
"$",
"cdata",
")",
"{",
"$",
"parent",
"->"... | Write a cdata section
@param string $cdata
@return \stubbles\xml\XmlStreamWriter | [
"Write",
"a",
"cdata",
"section"
] | 595bc5266190fd9661e9eee140cf2378f623e50a | https://github.com/stubbles/stubbles-xml/blob/595bc5266190fd9661e9eee140cf2378f623e50a/src/main/php/DomXmlStreamWriter.php#L111-L122 | train |
stubbles/stubbles-xml | src/main/php/DomXmlStreamWriter.php | DomXmlStreamWriter.writeComment | public function writeComment(string $comment): XmlStreamWriter
{
return $this->append(
function(\DOMNode $parent) use ($comment)
{
$parent->appendChild(
$this->doc->createComment($this->encode($comment))
);
},
'comment'
);
} | php | public function writeComment(string $comment): XmlStreamWriter
{
return $this->append(
function(\DOMNode $parent) use ($comment)
{
$parent->appendChild(
$this->doc->createComment($this->encode($comment))
);
},
'comment'
);
} | [
"public",
"function",
"writeComment",
"(",
"string",
"$",
"comment",
")",
":",
"XmlStreamWriter",
"{",
"return",
"$",
"this",
"->",
"append",
"(",
"function",
"(",
"\\",
"DOMNode",
"$",
"parent",
")",
"use",
"(",
"$",
"comment",
")",
"{",
"$",
"parent",
... | Write a comment
@param string $comment
@return \stubbles\xml\XmlStreamWriter | [
"Write",
"a",
"comment"
] | 595bc5266190fd9661e9eee140cf2378f623e50a | https://github.com/stubbles/stubbles-xml/blob/595bc5266190fd9661e9eee140cf2378f623e50a/src/main/php/DomXmlStreamWriter.php#L130-L141 | train |
stubbles/stubbles-xml | src/main/php/DomXmlStreamWriter.php | DomXmlStreamWriter.writeXmlFragment | public function writeXmlFragment(string $fragment): XmlStreamWriter
{
return $this->append(
function(\DOMNode $parent) use ($fragment)
{
$fragmentNode = $this->doc->createDocumentFragment();
$fragmentNode->appendXML($fragment);
@$parent->appendChild($fragmentNode);
},
'document fragment'
);
} | php | public function writeXmlFragment(string $fragment): XmlStreamWriter
{
return $this->append(
function(\DOMNode $parent) use ($fragment)
{
$fragmentNode = $this->doc->createDocumentFragment();
$fragmentNode->appendXML($fragment);
@$parent->appendChild($fragmentNode);
},
'document fragment'
);
} | [
"public",
"function",
"writeXmlFragment",
"(",
"string",
"$",
"fragment",
")",
":",
"XmlStreamWriter",
"{",
"return",
"$",
"this",
"->",
"append",
"(",
"function",
"(",
"\\",
"DOMNode",
"$",
"parent",
")",
"use",
"(",
"$",
"fragment",
")",
"{",
"$",
"fra... | Write an xml fragment
@param string $fragment
@return \stubbles\xml\XmlStreamWriter | [
"Write",
"an",
"xml",
"fragment"
] | 595bc5266190fd9661e9eee140cf2378f623e50a | https://github.com/stubbles/stubbles-xml/blob/595bc5266190fd9661e9eee140cf2378f623e50a/src/main/php/DomXmlStreamWriter.php#L170-L181 | train |
stubbles/stubbles-xml | src/main/php/DomXmlStreamWriter.php | DomXmlStreamWriter.importStreamWriter | public function importStreamWriter(XmlStreamWriter $writer): XmlStreamWriter
{
return $this->append(
function(\DOMNode $parent) use ($writer)
{
$parent->appendChild($this->doc->importNode(
$writer->asDom()->documentElement,
true
));
},
'imported nodes'
);
} | php | public function importStreamWriter(XmlStreamWriter $writer): XmlStreamWriter
{
return $this->append(
function(\DOMNode $parent) use ($writer)
{
$parent->appendChild($this->doc->importNode(
$writer->asDom()->documentElement,
true
));
},
'imported nodes'
);
} | [
"public",
"function",
"importStreamWriter",
"(",
"XmlStreamWriter",
"$",
"writer",
")",
":",
"XmlStreamWriter",
"{",
"return",
"$",
"this",
"->",
"append",
"(",
"function",
"(",
"\\",
"DOMNode",
"$",
"parent",
")",
"use",
"(",
"$",
"writer",
")",
"{",
"$",... | Import another stream
@param \stubbles\xml\XmlStreamWriter $writer
@return \stubbles\xml\XmlStreamWriter
@throws \stubbles\xml\XmlException | [
"Import",
"another",
"stream"
] | 595bc5266190fd9661e9eee140cf2378f623e50a | https://github.com/stubbles/stubbles-xml/blob/595bc5266190fd9661e9eee140cf2378f623e50a/src/main/php/DomXmlStreamWriter.php#L253-L265 | train |
stubbles/stubbles-xml | src/main/php/DomXmlStreamWriter.php | DomXmlStreamWriter.append | private function append(\Closure $appendTo, string $type): XmlStreamWriter
{
libxml_use_internal_errors(true);
try {
$appendTo(end($this->openElements));
} catch (\DOMException $e) {
throw new XmlException('Error writing "' . $type, $e);
}
$errors = libxml_get_errors();
if (!empty($errors)) {
libxml_clear_errors();
throw new XmlException(
'Error writing "' . $type . '": '
. implode(', ', array_map(
function($error) { return trim($error->message); },
$errors
))
);
}
return $this;
} | php | private function append(\Closure $appendTo, string $type): XmlStreamWriter
{
libxml_use_internal_errors(true);
try {
$appendTo(end($this->openElements));
} catch (\DOMException $e) {
throw new XmlException('Error writing "' . $type, $e);
}
$errors = libxml_get_errors();
if (!empty($errors)) {
libxml_clear_errors();
throw new XmlException(
'Error writing "' . $type . '": '
. implode(', ', array_map(
function($error) { return trim($error->message); },
$errors
))
);
}
return $this;
} | [
"private",
"function",
"append",
"(",
"\\",
"Closure",
"$",
"appendTo",
",",
"string",
"$",
"type",
")",
":",
"XmlStreamWriter",
"{",
"libxml_use_internal_errors",
"(",
"true",
")",
";",
"try",
"{",
"$",
"appendTo",
"(",
"end",
"(",
"$",
"this",
"->",
"o... | wraps handling on element stack
@param \Closure $appendTo function to work with element stack
@param string $type type of stack handling
@return \stubbles\xml\XmlStreamWriter
@throws \stubbles\xml\XmlException | [
"wraps",
"handling",
"on",
"element",
"stack"
] | 595bc5266190fd9661e9eee140cf2378f623e50a | https://github.com/stubbles/stubbles-xml/blob/595bc5266190fd9661e9eee140cf2378f623e50a/src/main/php/DomXmlStreamWriter.php#L295-L317 | train |
Xiphe/HTML | src/Xiphe/HTML/core/Tag.php | Tag.addOption | public function addOption($option)
{
if (in_array($option, Generator::$tagOptionKeys)
&& !$this->hasOption($option)
) {
$this->options[] = $option;
}
} | php | public function addOption($option)
{
if (in_array($option, Generator::$tagOptionKeys)
&& !$this->hasOption($option)
) {
$this->options[] = $option;
}
} | [
"public",
"function",
"addOption",
"(",
"$",
"option",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"option",
",",
"Generator",
"::",
"$",
"tagOptionKeys",
")",
"&&",
"!",
"$",
"this",
"->",
"hasOption",
"(",
"$",
"option",
")",
")",
"{",
"$",
"this",
... | Adds an option to the Tag
@param string $option the new option
@return void | [
"Adds",
"an",
"option",
"to",
"the",
"Tag"
] | 60cd0e869a75c535fdd785a26e351ded1507f1de | https://github.com/Xiphe/HTML/blob/60cd0e869a75c535fdd785a26e351ded1507f1de/src/Xiphe/HTML/core/Tag.php#L144-L151 | train |
Xiphe/HTML | src/Xiphe/HTML/core/Tag.php | Tag.removeOption | public function removeOption($option)
{
if ($this->hasOption($option)) {
$key = array_search($option, $this->options);
unset($this->options[$key]);
}
} | php | public function removeOption($option)
{
if ($this->hasOption($option)) {
$key = array_search($option, $this->options);
unset($this->options[$key]);
}
} | [
"public",
"function",
"removeOption",
"(",
"$",
"option",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasOption",
"(",
"$",
"option",
")",
")",
"{",
"$",
"key",
"=",
"array_search",
"(",
"$",
"option",
",",
"$",
"this",
"->",
"options",
")",
";",
"uns... | Removes an option from the Tag
@param string $option the option that should be removed
@return void | [
"Removes",
"an",
"option",
"from",
"the",
"Tag"
] | 60cd0e869a75c535fdd785a26e351ded1507f1de | https://github.com/Xiphe/HTML/blob/60cd0e869a75c535fdd785a26e351ded1507f1de/src/Xiphe/HTML/core/Tag.php#L160-L166 | train |
Xiphe/HTML | src/Xiphe/HTML/core/Tag.php | Tag.update | public function update($what = 'all')
{
/*
* Generate Class array.
*/
if ($what == 'all' || $what == 'classes') {
Generator::updateClasses($this);
}
/*
* Generate Class array.
*/
if ($what == 'all' || $what == 'urls') {
Generator::magicUrls($this);
}
/*
* Parse the content.
*/
if ($what == 'content') {
Content::parse($this);
}
if ($what == 'content' || $what == 'all' || $what == 'inlineInner') {
if ($this->hasOption('inlineInner')
|| ($this->name !== 'blank'
&& !$this->hasOption('forbidInlineInner')
&& !$this->isSelfClosing()
&& !$this->hasOption('start')
&& strlen($this->content) < Config::get('maxLineWidth')
&& !preg_match('/\r\n|\n|\r/', $this->content))
) {
$this->inlineInner = true;
} else {
$this->inlineInner = false;
}
}
if ($what == 'all' || $what == 'attributes') {
/*
* Sort Atrributes and Classes.
*/
ksort($this->attributes);
/*
* Parse the attributes to string format.
*/
$this->attributeString = Generator::attsToString($this);
}
} | php | public function update($what = 'all')
{
/*
* Generate Class array.
*/
if ($what == 'all' || $what == 'classes') {
Generator::updateClasses($this);
}
/*
* Generate Class array.
*/
if ($what == 'all' || $what == 'urls') {
Generator::magicUrls($this);
}
/*
* Parse the content.
*/
if ($what == 'content') {
Content::parse($this);
}
if ($what == 'content' || $what == 'all' || $what == 'inlineInner') {
if ($this->hasOption('inlineInner')
|| ($this->name !== 'blank'
&& !$this->hasOption('forbidInlineInner')
&& !$this->isSelfClosing()
&& !$this->hasOption('start')
&& strlen($this->content) < Config::get('maxLineWidth')
&& !preg_match('/\r\n|\n|\r/', $this->content))
) {
$this->inlineInner = true;
} else {
$this->inlineInner = false;
}
}
if ($what == 'all' || $what == 'attributes') {
/*
* Sort Atrributes and Classes.
*/
ksort($this->attributes);
/*
* Parse the attributes to string format.
*/
$this->attributeString = Generator::attsToString($this);
}
} | [
"public",
"function",
"update",
"(",
"$",
"what",
"=",
"'all'",
")",
"{",
"/*\n * Generate Class array.\n */",
"if",
"(",
"$",
"what",
"==",
"'all'",
"||",
"$",
"what",
"==",
"'classes'",
")",
"{",
"Generator",
"::",
"updateClasses",
"(",
"$",
... | Updates class variables.
@param string $what set to just update a specific part of the tag
@return void | [
"Updates",
"class",
"variables",
"."
] | 60cd0e869a75c535fdd785a26e351ded1507f1de | https://github.com/Xiphe/HTML/blob/60cd0e869a75c535fdd785a26e351ded1507f1de/src/Xiphe/HTML/core/Tag.php#L293-L342 | train |
Xiphe/HTML | src/Xiphe/HTML/core/Tag.php | Tag.setAttrs | public function setAttrs($attrs)
{
$oldAttrs = $this->attributes;
$oldClasses = $this->classes;
$this->attributes = $attrs;
$this->attributes = Generator::parseAtts($this);
$this->attributes = array_merge($oldAttrs, $this->attributes);
$this->classes = null;
$this->update('classes');
if (!empty($oldClasses) && !empty($this->classes)) {
$this->attributes['class'] = implode(' ', array_merge($oldClasses, $this->classes));
}
$this->classes = null;
if (!empty($oldAttrs['style']) && !empty($this->attributes['style'])) {
$this->attributes['style'] = Generator::mergeStyles($this->attributes['style'], $oldAttrs['style']);
}
$this->update();
} | php | public function setAttrs($attrs)
{
$oldAttrs = $this->attributes;
$oldClasses = $this->classes;
$this->attributes = $attrs;
$this->attributes = Generator::parseAtts($this);
$this->attributes = array_merge($oldAttrs, $this->attributes);
$this->classes = null;
$this->update('classes');
if (!empty($oldClasses) && !empty($this->classes)) {
$this->attributes['class'] = implode(' ', array_merge($oldClasses, $this->classes));
}
$this->classes = null;
if (!empty($oldAttrs['style']) && !empty($this->attributes['style'])) {
$this->attributes['style'] = Generator::mergeStyles($this->attributes['style'], $oldAttrs['style']);
}
$this->update();
} | [
"public",
"function",
"setAttrs",
"(",
"$",
"attrs",
")",
"{",
"$",
"oldAttrs",
"=",
"$",
"this",
"->",
"attributes",
";",
"$",
"oldClasses",
"=",
"$",
"this",
"->",
"classes",
";",
"$",
"this",
"->",
"attributes",
"=",
"$",
"attrs",
";",
"$",
"this"... | Add an array of attributes to the tag.
Merges class and style attributes
Accepts attributes in string format.
@param mixed $attrs the new attributes.
@return void | [
"Add",
"an",
"array",
"of",
"attributes",
"to",
"the",
"tag",
"."
] | 60cd0e869a75c535fdd785a26e351ded1507f1de | https://github.com/Xiphe/HTML/blob/60cd0e869a75c535fdd785a26e351ded1507f1de/src/Xiphe/HTML/core/Tag.php#L363-L385 | train |
Xiphe/HTML | src/Xiphe/HTML/core/Tag.php | Tag.isSelfclosing | public function isSelfclosing()
{
if (isset($this->selfclosing)) {
return (bool) $this->selfclosing;
}
if ($this->hasOption('selfQlose')) {
$this->selfclosing = true;
return true;
} elseif ($this->hasOption('doNotSelfQlose')) {
$this->selfclosing = false;
return false;
}
return in_array($this->realName, TagInfo::$selfClosing);
} | php | public function isSelfclosing()
{
if (isset($this->selfclosing)) {
return (bool) $this->selfclosing;
}
if ($this->hasOption('selfQlose')) {
$this->selfclosing = true;
return true;
} elseif ($this->hasOption('doNotSelfQlose')) {
$this->selfclosing = false;
return false;
}
return in_array($this->realName, TagInfo::$selfClosing);
} | [
"public",
"function",
"isSelfclosing",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"selfclosing",
")",
")",
"{",
"return",
"(",
"bool",
")",
"$",
"this",
"->",
"selfclosing",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"hasOption",
"(",
... | Checks if this tag is meant to be self closing.
@return boolean | [
"Checks",
"if",
"this",
"tag",
"is",
"meant",
"to",
"be",
"self",
"closing",
"."
] | 60cd0e869a75c535fdd785a26e351ded1507f1de | https://github.com/Xiphe/HTML/blob/60cd0e869a75c535fdd785a26e351ded1507f1de/src/Xiphe/HTML/core/Tag.php#L402-L418 | train |
Xiphe/HTML | src/Xiphe/HTML/core/Tag.php | Tag.closingComment | public function closingComment()
{
if (!empty($this->attributes['id'])) {
$hint = '#'.$this->attributes['id'];
} elseif (!empty($this->classes)) {
$hint = '.'.$this->classes[0];
} else {
return false;
}
Generator::call('il_comment', array($hint));
} | php | public function closingComment()
{
if (!empty($this->attributes['id'])) {
$hint = '#'.$this->attributes['id'];
} elseif (!empty($this->classes)) {
$hint = '.'.$this->classes[0];
} else {
return false;
}
Generator::call('il_comment', array($hint));
} | [
"public",
"function",
"closingComment",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"attributes",
"[",
"'id'",
"]",
")",
")",
"{",
"$",
"hint",
"=",
"'#'",
".",
"$",
"this",
"->",
"attributes",
"[",
"'id'",
"]",
";",
"}",
"els... | Adds the closing comment containing the tag id or class.
@return void | [
"Adds",
"the",
"closing",
"comment",
"containing",
"the",
"tag",
"id",
"or",
"class",
"."
] | 60cd0e869a75c535fdd785a26e351ded1507f1de | https://github.com/Xiphe/HTML/blob/60cd0e869a75c535fdd785a26e351ded1507f1de/src/Xiphe/HTML/core/Tag.php#L519-L529 | train |
Xiphe/HTML | src/Xiphe/HTML/core/Tag.php | Tag.content | public function content()
{
if (!$this->_contentPrinted) {
if (!$this->inlineInner) {
Generator::tabs();
}
if ($this->hasOption('cleanContent')
|| (Config::get('clean') && !$this->hasOption('doNotCleanContent'))
) {
echo trim(Cleaner::getClean($this->content));
} else {
echo $this->content;
}
if (!$this->inlineInner) {
Generator::lineBreak();
}
$this->_contentPrinted = true;
}
} | php | public function content()
{
if (!$this->_contentPrinted) {
if (!$this->inlineInner) {
Generator::tabs();
}
if ($this->hasOption('cleanContent')
|| (Config::get('clean') && !$this->hasOption('doNotCleanContent'))
) {
echo trim(Cleaner::getClean($this->content));
} else {
echo $this->content;
}
if (!$this->inlineInner) {
Generator::lineBreak();
}
$this->_contentPrinted = true;
}
} | [
"public",
"function",
"content",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_contentPrinted",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"inlineInner",
")",
"{",
"Generator",
"::",
"tabs",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->... | Echoes the tag content.
@return void | [
"Echoes",
"the",
"tag",
"content",
"."
] | 60cd0e869a75c535fdd785a26e351ded1507f1de | https://github.com/Xiphe/HTML/blob/60cd0e869a75c535fdd785a26e351ded1507f1de/src/Xiphe/HTML/core/Tag.php#L554-L574 | train |
Evaneos/daemon | src/Monitor/MemoryMonitor.php | MemoryMonitor.monitor | public function monitor(Daemon $daemon, $currentObject = null)
{
$currentMemory = $this->getMemoryUsage();
if ($this->memory > 0 && $currentMemory > $this->memory) {
$this->logger
->warning(
'Memory usage increased',
[
'bytes_increased_by' => $currentMemory - $this->memory,
'bytes_current_memory' => $currentMemory
]
);
}
$this->memory = $currentMemory;
} | php | public function monitor(Daemon $daemon, $currentObject = null)
{
$currentMemory = $this->getMemoryUsage();
if ($this->memory > 0 && $currentMemory > $this->memory) {
$this->logger
->warning(
'Memory usage increased',
[
'bytes_increased_by' => $currentMemory - $this->memory,
'bytes_current_memory' => $currentMemory
]
);
}
$this->memory = $currentMemory;
} | [
"public",
"function",
"monitor",
"(",
"Daemon",
"$",
"daemon",
",",
"$",
"currentObject",
"=",
"null",
")",
"{",
"$",
"currentMemory",
"=",
"$",
"this",
"->",
"getMemoryUsage",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"memory",
">",
"0",
"&&",
"$... | Monitor the daemon
@param Daemon $daemon
@param mixed $currentObject
@return void | [
"Monitor",
"the",
"daemon"
] | 9f9f5f74fb011b1e49b4d7d196f5e665d41d359f | https://github.com/Evaneos/daemon/blob/9f9f5f74fb011b1e49b4d7d196f5e665d41d359f/src/Monitor/MemoryMonitor.php#L41-L55 | train |
Xiphe/HTML | src/Xiphe/HTML/modules/Css.php | Css.sure | public function sure()
{
return !(substr($this->args[0], 0, 4) == 'http'
|| substr($this->args[0], 0, 3) == '../'
|| substr($this->args[0], 0, 3) == '\./'
|| substr($this->args[0], 0, 2) == './'
|| substr($this->args[0], 0, 1) == '/'
);
} | php | public function sure()
{
return !(substr($this->args[0], 0, 4) == 'http'
|| substr($this->args[0], 0, 3) == '../'
|| substr($this->args[0], 0, 3) == '\./'
|| substr($this->args[0], 0, 2) == './'
|| substr($this->args[0], 0, 1) == '/'
);
} | [
"public",
"function",
"sure",
"(",
")",
"{",
"return",
"!",
"(",
"substr",
"(",
"$",
"this",
"->",
"args",
"[",
"0",
"]",
",",
"0",
",",
"4",
")",
"==",
"'http'",
"||",
"substr",
"(",
"$",
"this",
"->",
"args",
"[",
"0",
"]",
",",
"0",
",",
... | Don't use this module if content looks like an url.
@return boolean | [
"Don",
"t",
"use",
"this",
"module",
"if",
"content",
"looks",
"like",
"an",
"url",
"."
] | 60cd0e869a75c535fdd785a26e351ded1507f1de | https://github.com/Xiphe/HTML/blob/60cd0e869a75c535fdd785a26e351ded1507f1de/src/Xiphe/HTML/modules/Css.php#L51-L59 | train |
Xiphe/HTML | src/Xiphe/HTML/core/Modules.php | Modules.appendAlias | public static function appendAlias(&$moduleName)
{
if (isset(self::$moduleAliases[$moduleName])) {
$moduleName = self::$moduleAliases[$moduleName];
}
} | php | public static function appendAlias(&$moduleName)
{
if (isset(self::$moduleAliases[$moduleName])) {
$moduleName = self::$moduleAliases[$moduleName];
}
} | [
"public",
"static",
"function",
"appendAlias",
"(",
"&",
"$",
"moduleName",
")",
"{",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"moduleAliases",
"[",
"$",
"moduleName",
"]",
")",
")",
"{",
"$",
"moduleName",
"=",
"self",
"::",
"$",
"moduleAliases",
"... | Checks if the called name is a module alias.
@param string &$moduleName the called name
@return void | [
"Checks",
"if",
"the",
"called",
"name",
"is",
"a",
"module",
"alias",
"."
] | 60cd0e869a75c535fdd785a26e351ded1507f1de | https://github.com/Xiphe/HTML/blob/60cd0e869a75c535fdd785a26e351ded1507f1de/src/Xiphe/HTML/core/Modules.php#L70-L75 | train |
Xiphe/HTML | src/Xiphe/HTML/core/Modules.php | Modules.execute | public static function execute($name, &$args, &$options, $called)
{
$moduleClass = 'Xiphe\HTML\modules\\'.ucfirst($name);
if (is_object(self::$_loadedModules[$name])) {
self::$_loadedModules[$name]->execute($args, $options, $called);
} else {
$Module = new $moduleClass();
$Module->execute($args, $options, $called);
}
} | php | public static function execute($name, &$args, &$options, $called)
{
$moduleClass = 'Xiphe\HTML\modules\\'.ucfirst($name);
if (is_object(self::$_loadedModules[$name])) {
self::$_loadedModules[$name]->execute($args, $options, $called);
} else {
$Module = new $moduleClass();
$Module->execute($args, $options, $called);
}
} | [
"public",
"static",
"function",
"execute",
"(",
"$",
"name",
",",
"&",
"$",
"args",
",",
"&",
"$",
"options",
",",
"$",
"called",
")",
"{",
"$",
"moduleClass",
"=",
"'Xiphe\\HTML\\modules\\\\'",
".",
"ucfirst",
"(",
"$",
"name",
")",
";",
"if",
"(",
... | Loads and executes modules
@param string $name the module name
@param array &$args passed arguments
@param array &$options passed module options
@param string $called original call name (alias)
@return void | [
"Loads",
"and",
"executes",
"modules"
] | 60cd0e869a75c535fdd785a26e351ded1507f1de | https://github.com/Xiphe/HTML/blob/60cd0e869a75c535fdd785a26e351ded1507f1de/src/Xiphe/HTML/core/Modules.php#L87-L97 | train |
Xiphe/HTML | src/Xiphe/HTML/core/Modules.php | Modules.get | public static function get($name, &$args, &$options, &$called)
{
$moduleClass = 'Xiphe\HTML\modules\\'.ucfirst($name);
if (!isset(self::$_loadedModules[$name])) {
self::$_loadedModules[$name] = new $moduleClass();
self::$_loadedModules[$name]->name = $name;
}
self::$_loadedModules[$name]->init($args, $options, $called);
return self::$_loadedModules[$name];
} | php | public static function get($name, &$args, &$options, &$called)
{
$moduleClass = 'Xiphe\HTML\modules\\'.ucfirst($name);
if (!isset(self::$_loadedModules[$name])) {
self::$_loadedModules[$name] = new $moduleClass();
self::$_loadedModules[$name]->name = $name;
}
self::$_loadedModules[$name]->init($args, $options, $called);
return self::$_loadedModules[$name];
} | [
"public",
"static",
"function",
"get",
"(",
"$",
"name",
",",
"&",
"$",
"args",
",",
"&",
"$",
"options",
",",
"&",
"$",
"called",
")",
"{",
"$",
"moduleClass",
"=",
"'Xiphe\\HTML\\modules\\\\'",
".",
"ucfirst",
"(",
"$",
"name",
")",
";",
"if",
"(",... | Returns a freshly initiated module.
@param string $name the module name
@param array &$args passed arguments
@param array &$options passed module options
@param string &$called original call name (alias)
@return object | [
"Returns",
"a",
"freshly",
"initiated",
"module",
"."
] | 60cd0e869a75c535fdd785a26e351ded1507f1de | https://github.com/Xiphe/HTML/blob/60cd0e869a75c535fdd785a26e351ded1507f1de/src/Xiphe/HTML/core/Modules.php#L109-L120 | train |
Xiphe/HTML | src/Xiphe/HTML/core/Modules.php | Modules.exist | public static function exist($name)
{
$name = ucfirst($name);
/*
* If it was checked before negatively - direct return.
*/
if (in_array($name, self::$_unavailableModules)) {
return false;
}
/*
* Check if it was already loaded.
*/
if (isset(self::$_loadedModules[$name])) {
return true;
}
/*
* Or the file exists.
*/
if (file_exists(self::getModulePath().$name.'.php')) {
return true;
} else {
self::$_unavailableModules[] = $name;
}
/*
* Module does not exist.
*/
return false;
} | php | public static function exist($name)
{
$name = ucfirst($name);
/*
* If it was checked before negatively - direct return.
*/
if (in_array($name, self::$_unavailableModules)) {
return false;
}
/*
* Check if it was already loaded.
*/
if (isset(self::$_loadedModules[$name])) {
return true;
}
/*
* Or the file exists.
*/
if (file_exists(self::getModulePath().$name.'.php')) {
return true;
} else {
self::$_unavailableModules[] = $name;
}
/*
* Module does not exist.
*/
return false;
} | [
"public",
"static",
"function",
"exist",
"(",
"$",
"name",
")",
"{",
"$",
"name",
"=",
"ucfirst",
"(",
"$",
"name",
")",
";",
"/*\n * If it was checked before negatively - direct return.\n */",
"if",
"(",
"in_array",
"(",
"$",
"name",
",",
"self",
... | Checks if the Module was loaded before or if the module file exists
@param string $name the module name
@return boolean | [
"Checks",
"if",
"the",
"Module",
"was",
"loaded",
"before",
"or",
"if",
"the",
"module",
"file",
"exists"
] | 60cd0e869a75c535fdd785a26e351ded1507f1de | https://github.com/Xiphe/HTML/blob/60cd0e869a75c535fdd785a26e351ded1507f1de/src/Xiphe/HTML/core/Modules.php#L143-L175 | train |
stubbles/stubbles-xml | src/main/php/serializer/AnnotationBasedObjectXmlSerializer.php | AnnotationBasedObjectXmlSerializer.fromObject | public static function fromObject($object): self
{
$className = get_class($object);
if (isset(self::$cache[$className])) {
return self::$cache[$className];
}
self::$cache[$className] = new self(new \ReflectionObject($object));
return self::$cache[$className];
} | php | public static function fromObject($object): self
{
$className = get_class($object);
if (isset(self::$cache[$className])) {
return self::$cache[$className];
}
self::$cache[$className] = new self(new \ReflectionObject($object));
return self::$cache[$className];
} | [
"public",
"static",
"function",
"fromObject",
"(",
"$",
"object",
")",
":",
"self",
"{",
"$",
"className",
"=",
"get_class",
"(",
"$",
"object",
")",
";",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"cache",
"[",
"$",
"className",
"]",
")",
")",
"{... | creates the structure from given object
This method will cache the result - on the next request with the same
class it will return the same result, even if the given object is a
different instance.
@param object $object
@return \stubbles\xml\serializer\AnnotationBasedObjectXmlSerializer | [
"creates",
"the",
"structure",
"from",
"given",
"object"
] | 595bc5266190fd9661e9eee140cf2378f623e50a | https://github.com/stubbles/stubbles-xml/blob/595bc5266190fd9661e9eee140cf2378f623e50a/src/main/php/serializer/AnnotationBasedObjectXmlSerializer.php#L85-L94 | train |
stubbles/stubbles-xml | src/main/php/serializer/AnnotationBasedObjectXmlSerializer.php | AnnotationBasedObjectXmlSerializer.extractProperties | private function extractProperties(\ReflectionClass $objectClass): array
{
return propertiesOf($objectClass, \ReflectionProperty::IS_PUBLIC)
->filter(function(\ReflectionProperty $property)
{
return !$property->isStatic()
&& !annotationsOf($property)->contain('XmlIgnore');
}
)->map(function(\ReflectionProperty $property)
{
return $this->createSerializerDelegate(
annotationsOf($property),
$property->getName()
);
}
)->data();
} | php | private function extractProperties(\ReflectionClass $objectClass): array
{
return propertiesOf($objectClass, \ReflectionProperty::IS_PUBLIC)
->filter(function(\ReflectionProperty $property)
{
return !$property->isStatic()
&& !annotationsOf($property)->contain('XmlIgnore');
}
)->map(function(\ReflectionProperty $property)
{
return $this->createSerializerDelegate(
annotationsOf($property),
$property->getName()
);
}
)->data();
} | [
"private",
"function",
"extractProperties",
"(",
"\\",
"ReflectionClass",
"$",
"objectClass",
")",
":",
"array",
"{",
"return",
"propertiesOf",
"(",
"$",
"objectClass",
",",
"\\",
"ReflectionProperty",
"::",
"IS_PUBLIC",
")",
"->",
"filter",
"(",
"function",
"("... | extract informations about properties
@param \ReflectionClass $objectClass
@return array | [
"extract",
"informations",
"about",
"properties"
] | 595bc5266190fd9661e9eee140cf2378f623e50a | https://github.com/stubbles/stubbles-xml/blob/595bc5266190fd9661e9eee140cf2378f623e50a/src/main/php/serializer/AnnotationBasedObjectXmlSerializer.php#L136-L152 | train |
stubbles/stubbles-xml | src/main/php/serializer/AnnotationBasedObjectXmlSerializer.php | AnnotationBasedObjectXmlSerializer.extractMethods | private function extractMethods(\ReflectionClass $objectClass): array
{
return methodsOf($objectClass, \ReflectionMethod::IS_PUBLIC)
->filter(function(\ReflectionMethod $method)
{
if ($method->getNumberOfParameters() != 0
|| $method->isStatic()
|| $method->isConstructor()
|| $method->isDestructor()
|| 0 == strncmp($method->getName(), '__', 2)) {
return false;
}
return !annotationsOf($method)->contain('XmlIgnore');
}
)->map(function(\ReflectionMethod $method)
{
return $this->createSerializerDelegate(
annotationsOf($method),
$method->getName()
);
}
)->data();
} | php | private function extractMethods(\ReflectionClass $objectClass): array
{
return methodsOf($objectClass, \ReflectionMethod::IS_PUBLIC)
->filter(function(\ReflectionMethod $method)
{
if ($method->getNumberOfParameters() != 0
|| $method->isStatic()
|| $method->isConstructor()
|| $method->isDestructor()
|| 0 == strncmp($method->getName(), '__', 2)) {
return false;
}
return !annotationsOf($method)->contain('XmlIgnore');
}
)->map(function(\ReflectionMethod $method)
{
return $this->createSerializerDelegate(
annotationsOf($method),
$method->getName()
);
}
)->data();
} | [
"private",
"function",
"extractMethods",
"(",
"\\",
"ReflectionClass",
"$",
"objectClass",
")",
":",
"array",
"{",
"return",
"methodsOf",
"(",
"$",
"objectClass",
",",
"\\",
"ReflectionMethod",
"::",
"IS_PUBLIC",
")",
"->",
"filter",
"(",
"function",
"(",
"\\"... | extract informations about methods
@param \ReflectionClass $objectClass
@return array | [
"extract",
"informations",
"about",
"methods"
] | 595bc5266190fd9661e9eee140cf2378f623e50a | https://github.com/stubbles/stubbles-xml/blob/595bc5266190fd9661e9eee140cf2378f623e50a/src/main/php/serializer/AnnotationBasedObjectXmlSerializer.php#L160-L184 | train |
stubbles/stubbles-xml | src/main/php/serializer/AnnotationBasedObjectXmlSerializer.php | AnnotationBasedObjectXmlSerializer.createSerializerDelegate | private function createSerializerDelegate(
Annotations $annotations,
string $defaultTagName
): XmlSerializerDelegate {
if ($annotations->contain('XmlAttribute')) {
$xmlAttribute = $annotations->firstNamed('XmlAttribute');
return new Attribute(
$xmlAttribute->attributeName(),
$xmlAttribute->getValueByName('skipEmpty', true)
);
} elseif ($annotations->contain('XmlFragment')) {
$xmlFragment = $annotations->firstNamed('XmlFragment');
return new Fragment(
false !== $xmlFragment->tagName() ? $xmlFragment->tagName() : null,
$xmlFragment->getValueByName('transformNewLineToBr', false)
);
} elseif ($annotations->contain('XmlTag')) {
$xmlTag = $annotations->firstNamed('XmlTag');
return new Tag(
false !== $xmlTag->tagName() ? $xmlTag->tagName() : '',
$xmlTag->getValueByName('elementTagName')
);
}
return new Tag($defaultTagName);
} | php | private function createSerializerDelegate(
Annotations $annotations,
string $defaultTagName
): XmlSerializerDelegate {
if ($annotations->contain('XmlAttribute')) {
$xmlAttribute = $annotations->firstNamed('XmlAttribute');
return new Attribute(
$xmlAttribute->attributeName(),
$xmlAttribute->getValueByName('skipEmpty', true)
);
} elseif ($annotations->contain('XmlFragment')) {
$xmlFragment = $annotations->firstNamed('XmlFragment');
return new Fragment(
false !== $xmlFragment->tagName() ? $xmlFragment->tagName() : null,
$xmlFragment->getValueByName('transformNewLineToBr', false)
);
} elseif ($annotations->contain('XmlTag')) {
$xmlTag = $annotations->firstNamed('XmlTag');
return new Tag(
false !== $xmlTag->tagName() ? $xmlTag->tagName() : '',
$xmlTag->getValueByName('elementTagName')
);
}
return new Tag($defaultTagName);
} | [
"private",
"function",
"createSerializerDelegate",
"(",
"Annotations",
"$",
"annotations",
",",
"string",
"$",
"defaultTagName",
")",
":",
"XmlSerializerDelegate",
"{",
"if",
"(",
"$",
"annotations",
"->",
"contain",
"(",
"'XmlAttribute'",
")",
")",
"{",
"$",
"x... | extracts informations about annotated element
@param \stubbles\lang\reflect\annotation\Annotations $annotations annotations of the element to serialize
@param string $defaultTagName default tag name in case element is not annotated
@return \stubbles\xml\serializer\delegate\XmlSerializerDelegate | [
"extracts",
"informations",
"about",
"annotated",
"element"
] | 595bc5266190fd9661e9eee140cf2378f623e50a | https://github.com/stubbles/stubbles-xml/blob/595bc5266190fd9661e9eee140cf2378f623e50a/src/main/php/serializer/AnnotationBasedObjectXmlSerializer.php#L193-L218 | train |
Xiphe/HTML | src/Xiphe/HTML/modules/Select.php | Select.isSelected | public function isSelected($selected, $value, $i)
{
if (is_array($selected)) {
foreach ($selected as $s) {
if ($this->isSelected($s, $value, $i)) {
return true;
}
}
} elseif (is_int($selected) && $i === $selected) {
return true;
} elseif ($value === $selected) {
return true;
}
return false;
} | php | public function isSelected($selected, $value, $i)
{
if (is_array($selected)) {
foreach ($selected as $s) {
if ($this->isSelected($s, $value, $i)) {
return true;
}
}
} elseif (is_int($selected) && $i === $selected) {
return true;
} elseif ($value === $selected) {
return true;
}
return false;
} | [
"public",
"function",
"isSelected",
"(",
"$",
"selected",
",",
"$",
"value",
",",
"$",
"i",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"selected",
")",
")",
"{",
"foreach",
"(",
"$",
"selected",
"as",
"$",
"s",
")",
"{",
"if",
"(",
"$",
"this",
... | Checks for selected options.
@param string $selected targeted selected value
@param mixed $value the current value
@param integer $i the current key
@return boolean | [
"Checks",
"for",
"selected",
"options",
"."
] | 60cd0e869a75c535fdd785a26e351ded1507f1de | https://github.com/Xiphe/HTML/blob/60cd0e869a75c535fdd785a26e351ded1507f1de/src/Xiphe/HTML/modules/Select.php#L137-L152 | train |
Evaneos/burrow-tools | src/Transactional/TransactionalConsumer.php | TransactionalConsumer.consume | public function consume($message, array $headers = [])
{
try {
$this->transactionManager->beginTransaction();
} catch (BeginException $e) {
throw new ConsumerException($e->getMessage(), $e->getCode(), $e);
}
try {
$this->consumer->consume($message, $headers);
$this->transactionManager->commit();
} catch (\Exception $e) {
$this->transactionManager->rollback();
throw $e;
}
} | php | public function consume($message, array $headers = [])
{
try {
$this->transactionManager->beginTransaction();
} catch (BeginException $e) {
throw new ConsumerException($e->getMessage(), $e->getCode(), $e);
}
try {
$this->consumer->consume($message, $headers);
$this->transactionManager->commit();
} catch (\Exception $e) {
$this->transactionManager->rollback();
throw $e;
}
} | [
"public",
"function",
"consume",
"(",
"$",
"message",
",",
"array",
"$",
"headers",
"=",
"[",
"]",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"transactionManager",
"->",
"beginTransaction",
"(",
")",
";",
"}",
"catch",
"(",
"BeginException",
"$",
"e",
")... | Consumes a message.
@param string $message
@param array $headers
@return null|string|void
@throws \Exception | [
"Consumes",
"a",
"message",
"."
] | a807d8a2fcc3cfd0064644cf18895c0573a3361c | https://github.com/Evaneos/burrow-tools/blob/a807d8a2fcc3cfd0064644cf18895c0573a3361c/src/Transactional/TransactionalConsumer.php#L40-L55 | train |
Xiphe/HTML | src/Xiphe/HTML.php | HTML.get | public static function get($initArgs = array())
{
if (get_class(Core\Config::getHTMLInstance()) == 'Xiphe\HTML') {
return Core\Config::getHTMLInstance();
} elseif (get_class($GLOBALS['HTML']) == 'Xiphe\HTML') {
return $GLOBALS['HTML'];
} else {
return new HTML($initArgs);
}
} | php | public static function get($initArgs = array())
{
if (get_class(Core\Config::getHTMLInstance()) == 'Xiphe\HTML') {
return Core\Config::getHTMLInstance();
} elseif (get_class($GLOBALS['HTML']) == 'Xiphe\HTML') {
return $GLOBALS['HTML'];
} else {
return new HTML($initArgs);
}
} | [
"public",
"static",
"function",
"get",
"(",
"$",
"initArgs",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"get_class",
"(",
"Core",
"\\",
"Config",
"::",
"getHTMLInstance",
"(",
")",
")",
"==",
"'Xiphe\\HTML'",
")",
"{",
"return",
"Core",
"\\",
"Config... | Getter for a HTML instance.
Returns the first available instance in this order.
- last used instance
- global instance
- new instance
@param array $initArgs if a new instance is created initiation
args can be passed here
@return Xiphe\HTML | [
"Getter",
"for",
"a",
"HTML",
"instance",
"."
] | 60cd0e869a75c535fdd785a26e351ded1507f1de | https://github.com/Xiphe/HTML/blob/60cd0e869a75c535fdd785a26e351ded1507f1de/src/Xiphe/HTML.php#L63-L72 | train |
Xiphe/HTML | src/Xiphe/HTML.php | HTML.getOption | public function getOption($key)
{
if (Core\Config::isValidOptionName($key)) {
if (isset($this->$key)) {
return $this->$key;
} else {
return Core\Config::get($key, true);
}
}
} | php | public function getOption($key)
{
if (Core\Config::isValidOptionName($key)) {
if (isset($this->$key)) {
return $this->$key;
} else {
return Core\Config::get($key, true);
}
}
} | [
"public",
"function",
"getOption",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"Core",
"\\",
"Config",
"::",
"isValidOptionName",
"(",
"$",
"key",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"$",
"key",
")",
")",
"{",
"return",
"$",
"thi... | Request an option value.
Returns global option value if instance option is not set.
@param string $key the requested option key
@return mixed the requested value | [
"Request",
"an",
"option",
"value",
"."
] | 60cd0e869a75c535fdd785a26e351ded1507f1de | https://github.com/Xiphe/HTML/blob/60cd0e869a75c535fdd785a26e351ded1507f1de/src/Xiphe/HTML.php#L93-L102 | train |
Xiphe/HTML | src/Xiphe/HTML.php | HTML.setOption | public function setOption($key, $value)
{
if (Core\Config::isValidOptionName($key)) {
Core\Config::s3t($this->$key, $value);
}
return $this;
} | php | public function setOption($key, $value)
{
if (Core\Config::isValidOptionName($key)) {
Core\Config::s3t($this->$key, $value);
}
return $this;
} | [
"public",
"function",
"setOption",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"Core",
"\\",
"Config",
"::",
"isValidOptionName",
"(",
"$",
"key",
")",
")",
"{",
"Core",
"\\",
"Config",
"::",
"s3t",
"(",
"$",
"this",
"->",
"$",
"key",
... | Set an option value for this instance
@param string $key the target option name
@param mixed $value the new option value
@return Xiphe\HTML | [
"Set",
"an",
"option",
"value",
"for",
"this",
"instance"
] | 60cd0e869a75c535fdd785a26e351ded1507f1de | https://github.com/Xiphe/HTML/blob/60cd0e869a75c535fdd785a26e351ded1507f1de/src/Xiphe/HTML.php#L112-L119 | train |
Xiphe/HTML | src/Xiphe/HTML.php | HTML.unsetOption | public function unsetOption($key)
{
if (Core\Config::isValidOptionName($key) && isset($this->$key)) {
unset($this->$key);
}
return $this;
} | php | public function unsetOption($key)
{
if (Core\Config::isValidOptionName($key) && isset($this->$key)) {
unset($this->$key);
}
return $this;
} | [
"public",
"function",
"unsetOption",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"Core",
"\\",
"Config",
"::",
"isValidOptionName",
"(",
"$",
"key",
")",
"&&",
"isset",
"(",
"$",
"this",
"->",
"$",
"key",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
... | Deletes an intance option if set.
@param string $key the target option name
@return Xiphe\HTML | [
"Deletes",
"an",
"intance",
"option",
"if",
"set",
"."
] | 60cd0e869a75c535fdd785a26e351ded1507f1de | https://github.com/Xiphe/HTML/blob/60cd0e869a75c535fdd785a26e351ded1507f1de/src/Xiphe/HTML.php#L128-L135 | train |
Xiphe/HTML | src/Xiphe/HTML.php | HTML.unsetInstanceOptions | public function unsetInstanceOptions()
{
foreach (Core\Config::getDefaults() as $k => $v) {
if (isset($this->$k)) {
unset($this->$k);
}
}
return $this;
} | php | public function unsetInstanceOptions()
{
foreach (Core\Config::getDefaults() as $k => $v) {
if (isset($this->$k)) {
unset($this->$k);
}
}
return $this;
} | [
"public",
"function",
"unsetInstanceOptions",
"(",
")",
"{",
"foreach",
"(",
"Core",
"\\",
"Config",
"::",
"getDefaults",
"(",
")",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"$",
"k",
")",
")",
"{",
"un... | Deletes all instance options of this instance.
@return Xiphe\HTML | [
"Deletes",
"all",
"instance",
"options",
"of",
"this",
"instance",
"."
] | 60cd0e869a75c535fdd785a26e351ded1507f1de | https://github.com/Xiphe/HTML/blob/60cd0e869a75c535fdd785a26e351ded1507f1de/src/Xiphe/HTML.php#L142-L151 | train |
Xiphe/HTML | src/Xiphe/HTML.php | HTML.addTabs | public function addTabs($i = 1)
{
Core\Config::setHTMLInstance($this);
Core\Config::set('tabs', (Core\Config::get('tabs') + $i));
return $this;
} | php | public function addTabs($i = 1)
{
Core\Config::setHTMLInstance($this);
Core\Config::set('tabs', (Core\Config::get('tabs') + $i));
return $this;
} | [
"public",
"function",
"addTabs",
"(",
"$",
"i",
"=",
"1",
")",
"{",
"Core",
"\\",
"Config",
"::",
"setHTMLInstance",
"(",
"$",
"this",
")",
";",
"Core",
"\\",
"Config",
"::",
"set",
"(",
"'tabs'",
",",
"(",
"Core",
"\\",
"Config",
"::",
"get",
"(",... | Manipulates the current Tab count.
internal or globaly depends on settings.
@param integer $i the tabs to be added or remove (negative value for remove)
@return Xiphe\HTML | [
"Manipulates",
"the",
"current",
"Tab",
"count",
"."
] | 60cd0e869a75c535fdd785a26e351ded1507f1de | https://github.com/Xiphe/HTML/blob/60cd0e869a75c535fdd785a26e351ded1507f1de/src/Xiphe/HTML.php#L162-L168 | train |
Xiphe/HTML | src/Xiphe/HTML/modules/Openinghtml.php | Openinghtml.xhtml | public function xhtml()
{
$this->htmlattrs['xmlns'] = 'http://www.w3.org/1999/xhtml';
echo '<?xml version="1.0" ?>'."\n";
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"';
Core\Generator::lineBreak();
Core\Config::set('tabs', '++');
Core\Generator::tabs();
echo '"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
Core\Generator::lineBreak();
Core\Config::set('tabs', '--');
echo $this->getHtml();
echo $this->getHead();
} | php | public function xhtml()
{
$this->htmlattrs['xmlns'] = 'http://www.w3.org/1999/xhtml';
echo '<?xml version="1.0" ?>'."\n";
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"';
Core\Generator::lineBreak();
Core\Config::set('tabs', '++');
Core\Generator::tabs();
echo '"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
Core\Generator::lineBreak();
Core\Config::set('tabs', '--');
echo $this->getHtml();
echo $this->getHead();
} | [
"public",
"function",
"xhtml",
"(",
")",
"{",
"$",
"this",
"->",
"htmlattrs",
"[",
"'xmlns'",
"]",
"=",
"'http://www.w3.org/1999/xhtml'",
";",
"echo",
"'<?xml version=\"1.0\" ?>'",
".",
"\"\\n\"",
";",
"echo",
"'<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//... | Generate a XHTML header.
@return void | [
"Generate",
"a",
"XHTML",
"header",
"."
] | 60cd0e869a75c535fdd785a26e351ded1507f1de | https://github.com/Xiphe/HTML/blob/60cd0e869a75c535fdd785a26e351ded1507f1de/src/Xiphe/HTML/modules/Openinghtml.php#L51-L66 | train |
Xiphe/HTML | src/Xiphe/HTML/modules/Openinghtml.php | Openinghtml.html5 | public function html5()
{
echo '<!DOCTYPE HTML>'."\n";
Core\Generator::lineBreak();
echo $this->getHtml();
echo $this->getHead();
\Xiphe\HTML::get()->utf8()
->meta('http-equiv=X-UA-Compatible|content=IE\=edge,chrome\=1');
} | php | public function html5()
{
echo '<!DOCTYPE HTML>'."\n";
Core\Generator::lineBreak();
echo $this->getHtml();
echo $this->getHead();
\Xiphe\HTML::get()->utf8()
->meta('http-equiv=X-UA-Compatible|content=IE\=edge,chrome\=1');
} | [
"public",
"function",
"html5",
"(",
")",
"{",
"echo",
"'<!DOCTYPE HTML>'",
".",
"\"\\n\"",
";",
"Core",
"\\",
"Generator",
"::",
"lineBreak",
"(",
")",
";",
"echo",
"$",
"this",
"->",
"getHtml",
"(",
")",
";",
"echo",
"$",
"this",
"->",
"getHead",
"(",... | Generate a HTML5 header.
@return void | [
"Generate",
"a",
"HTML5",
"header",
"."
] | 60cd0e869a75c535fdd785a26e351ded1507f1de | https://github.com/Xiphe/HTML/blob/60cd0e869a75c535fdd785a26e351ded1507f1de/src/Xiphe/HTML/modules/Openinghtml.php#L73-L81 | train |
Xiphe/HTML | src/Xiphe/HTML/modules/Openinghtml.php | Openinghtml.getHtml | public function getHtml()
{
$html = new Core\Tag(
'html',
array((isset($this->args[1]) ? $this->args[1] : null)),
array('generate', 'start')
);
$html->setAttrs($this->htmlattrs);
return $html;
} | php | public function getHtml()
{
$html = new Core\Tag(
'html',
array((isset($this->args[1]) ? $this->args[1] : null)),
array('generate', 'start')
);
$html->setAttrs($this->htmlattrs);
return $html;
} | [
"public",
"function",
"getHtml",
"(",
")",
"{",
"$",
"html",
"=",
"new",
"Core",
"\\",
"Tag",
"(",
"'html'",
",",
"array",
"(",
"(",
"isset",
"(",
"$",
"this",
"->",
"args",
"[",
"1",
"]",
")",
"?",
"$",
"this",
"->",
"args",
"[",
"1",
"]",
"... | Returns the actual html tag.
@return Tag | [
"Returns",
"the",
"actual",
"html",
"tag",
"."
] | 60cd0e869a75c535fdd785a26e351ded1507f1de | https://github.com/Xiphe/HTML/blob/60cd0e869a75c535fdd785a26e351ded1507f1de/src/Xiphe/HTML/modules/Openinghtml.php#L88-L98 | train |
Xiphe/HTML | src/Xiphe/HTML/modules/Openinghtml.php | Openinghtml.getHead | public function getHead()
{
$head = new Core\Tag(
'head',
array((isset($this->args[0]) ? $this->args[0] : null)),
array('generate', 'start')
);
$head->setAttrs($this->headattrs);
return $head;
} | php | public function getHead()
{
$head = new Core\Tag(
'head',
array((isset($this->args[0]) ? $this->args[0] : null)),
array('generate', 'start')
);
$head->setAttrs($this->headattrs);
return $head;
} | [
"public",
"function",
"getHead",
"(",
")",
"{",
"$",
"head",
"=",
"new",
"Core",
"\\",
"Tag",
"(",
"'head'",
",",
"array",
"(",
"(",
"isset",
"(",
"$",
"this",
"->",
"args",
"[",
"0",
"]",
")",
"?",
"$",
"this",
"->",
"args",
"[",
"0",
"]",
"... | Returns the head tag.
@return Tag | [
"Returns",
"the",
"head",
"tag",
"."
] | 60cd0e869a75c535fdd785a26e351ded1507f1de | https://github.com/Xiphe/HTML/blob/60cd0e869a75c535fdd785a26e351ded1507f1de/src/Xiphe/HTML/modules/Openinghtml.php#L105-L115 | train |
Xiphe/HTML | src/Xiphe/HTML/modules/Openinghtml.php | Openinghtml.ieClass | public function ieClass($before = '')
{
$sIeClass = '';
if (class_exists('Xiphe\THEMASTER\core\THEMASTER')) {
if (\Xiphe\THETOOLS::is_browser('ie')) {
if (\Xiphe\THETOOLS::is_browser('ie<=6')) {
$sIeClass = $before.'lt-ie10 lt-ie9 lt-ie8 lt-ie7';
} elseif (\Xiphe\THETOOLS::is_browser('ie<=7')) {
$sIeClass = $before.'lt-ie10 lt-ie9 lt-ie8';
} elseif (\Xiphe\THETOOLS::is_browser('ie<=8')) {
$sIeClass = $before.'lt-ie10 lt-ie9';
} elseif (\Xiphe\THETOOLS::is_browser('ie<=9')) {
$sIeClass = $before.'lt-ie10';
}
}
}
return $sIeClass;
} | php | public function ieClass($before = '')
{
$sIeClass = '';
if (class_exists('Xiphe\THEMASTER\core\THEMASTER')) {
if (\Xiphe\THETOOLS::is_browser('ie')) {
if (\Xiphe\THETOOLS::is_browser('ie<=6')) {
$sIeClass = $before.'lt-ie10 lt-ie9 lt-ie8 lt-ie7';
} elseif (\Xiphe\THETOOLS::is_browser('ie<=7')) {
$sIeClass = $before.'lt-ie10 lt-ie9 lt-ie8';
} elseif (\Xiphe\THETOOLS::is_browser('ie<=8')) {
$sIeClass = $before.'lt-ie10 lt-ie9';
} elseif (\Xiphe\THETOOLS::is_browser('ie<=9')) {
$sIeClass = $before.'lt-ie10';
}
}
}
return $sIeClass;
} | [
"public",
"function",
"ieClass",
"(",
"$",
"before",
"=",
"''",
")",
"{",
"$",
"sIeClass",
"=",
"''",
";",
"if",
"(",
"class_exists",
"(",
"'Xiphe\\THEMASTER\\core\\THEMASTER'",
")",
")",
"{",
"if",
"(",
"\\",
"Xiphe",
"\\",
"THETOOLS",
"::",
"is_browser",... | Checks if \Xiphe\THETOOLS exists and append ie classes.
@param string $before separator.
@return string | [
"Checks",
"if",
"\\",
"Xiphe",
"\\",
"THETOOLS",
"exists",
"and",
"append",
"ie",
"classes",
"."
] | 60cd0e869a75c535fdd785a26e351ded1507f1de | https://github.com/Xiphe/HTML/blob/60cd0e869a75c535fdd785a26e351ded1507f1de/src/Xiphe/HTML/modules/Openinghtml.php#L124-L142 | train |
Xiphe/HTML | src/Xiphe/HTML/modules/Openinghtml.php | Openinghtml.browserClass | public function browserClass($before = '')
{
if (class_exists('Xiphe\THEMASTER\core\THEMASTER')) {
$browser = str_replace(' ', '_', strtolower(\Xiphe\THETOOLS::get_browser()));
$version = str_replace('.', '-', \Xiphe\THETOOLS::get_browserVersion());
$engine = strtolower(\Xiphe\THETOOLS::get_layoutEngine());
if (!empty($engine)) {
$engine .=' ';
}
if (\Xiphe\THETOOLS::is_browser('mobile')) {
$mobile = 'mobile no-desktop';
} else {
$mobile = 'desktop no-mobile';
}
return "$before$engine$browser $browser-$version $mobile";
}
return '';
} | php | public function browserClass($before = '')
{
if (class_exists('Xiphe\THEMASTER\core\THEMASTER')) {
$browser = str_replace(' ', '_', strtolower(\Xiphe\THETOOLS::get_browser()));
$version = str_replace('.', '-', \Xiphe\THETOOLS::get_browserVersion());
$engine = strtolower(\Xiphe\THETOOLS::get_layoutEngine());
if (!empty($engine)) {
$engine .=' ';
}
if (\Xiphe\THETOOLS::is_browser('mobile')) {
$mobile = 'mobile no-desktop';
} else {
$mobile = 'desktop no-mobile';
}
return "$before$engine$browser $browser-$version $mobile";
}
return '';
} | [
"public",
"function",
"browserClass",
"(",
"$",
"before",
"=",
"''",
")",
"{",
"if",
"(",
"class_exists",
"(",
"'Xiphe\\THEMASTER\\core\\THEMASTER'",
")",
")",
"{",
"$",
"browser",
"=",
"str_replace",
"(",
"' '",
",",
"'_'",
",",
"strtolower",
"(",
"\\",
"... | Checks if \Xiphe\THETOOLS exists and appends browser classes.
@param string $before separator.
@return string | [
"Checks",
"if",
"\\",
"Xiphe",
"\\",
"THETOOLS",
"exists",
"and",
"appends",
"browser",
"classes",
"."
] | 60cd0e869a75c535fdd785a26e351ded1507f1de | https://github.com/Xiphe/HTML/blob/60cd0e869a75c535fdd785a26e351ded1507f1de/src/Xiphe/HTML/modules/Openinghtml.php#L151-L171 | train |
Evaneos/burrow-tools | src/Legacy/DaemonFactory.php | DaemonFactory.buildAsync | public static function buildAsync(
$host,
$port,
$user,
$pass,
$queueName,
QueueConsumer $consumer,
$escapeMode = self::ESCAPE_MODE_SERIALIZE,
$requeueOnFailure = true,
LoggerInterface $logger = null,
$stopOnFailure = false
) {
return self::build(
$host,
$port,
$user,
$pass,
$queueName,
$consumer,
false,
$escapeMode,
$requeueOnFailure,
$stopOnFailure
);
} | php | public static function buildAsync(
$host,
$port,
$user,
$pass,
$queueName,
QueueConsumer $consumer,
$escapeMode = self::ESCAPE_MODE_SERIALIZE,
$requeueOnFailure = true,
LoggerInterface $logger = null,
$stopOnFailure = false
) {
return self::build(
$host,
$port,
$user,
$pass,
$queueName,
$consumer,
false,
$escapeMode,
$requeueOnFailure,
$stopOnFailure
);
} | [
"public",
"static",
"function",
"buildAsync",
"(",
"$",
"host",
",",
"$",
"port",
",",
"$",
"user",
",",
"$",
"pass",
",",
"$",
"queueName",
",",
"QueueConsumer",
"$",
"consumer",
",",
"$",
"escapeMode",
"=",
"self",
"::",
"ESCAPE_MODE_SERIALIZE",
",",
"... | Build an async daemon
@param string $host
@param string $port
@param string $user
@param string $pass
@param string $queueName
@param QueueConsumer $consumer
@param string $escapeMode
@param bool $requeueOnFailure
@param LoggerInterface $logger
@param bool $stopOnFailure
@return QueueHandlingDaemon | [
"Build",
"an",
"async",
"daemon"
] | a807d8a2fcc3cfd0064644cf18895c0573a3361c | https://github.com/Evaneos/burrow-tools/blob/a807d8a2fcc3cfd0064644cf18895c0573a3361c/src/Legacy/DaemonFactory.php#L43-L67 | train |
Evaneos/burrow-tools | src/Legacy/DaemonFactory.php | DaemonFactory.build | private static function build(
$host,
$port,
$user,
$pass,
$queueName,
QueueConsumer $consumer,
$sync,
$escapeMode,
$requeueOnFailure,
LoggerInterface $logger = null,
$stopOnFailure = false
) {
$consumer = self::getSerializingConsumer($consumer, $escapeMode);
$driver = DriverFactory::getDriver([
'host' => $host,
'port' => $port,
'user' => $user,
'pwd' => $pass
]);
$builder = new HandlerBuilder($driver);
if ($sync) {
$builder->sync($consumer);
} else {
$builder->async($consumer);
}
if (! $stopOnFailure) {
$builder->continueOnFailure();
}
if (! $requeueOnFailure) {
$builder->doNotRequeueOnFailure();
}
$builder->log(($logger === null) ? new NullLogger() : $logger);
return new QueueHandlingDaemon($driver, $builder->build(), $queueName);
} | php | private static function build(
$host,
$port,
$user,
$pass,
$queueName,
QueueConsumer $consumer,
$sync,
$escapeMode,
$requeueOnFailure,
LoggerInterface $logger = null,
$stopOnFailure = false
) {
$consumer = self::getSerializingConsumer($consumer, $escapeMode);
$driver = DriverFactory::getDriver([
'host' => $host,
'port' => $port,
'user' => $user,
'pwd' => $pass
]);
$builder = new HandlerBuilder($driver);
if ($sync) {
$builder->sync($consumer);
} else {
$builder->async($consumer);
}
if (! $stopOnFailure) {
$builder->continueOnFailure();
}
if (! $requeueOnFailure) {
$builder->doNotRequeueOnFailure();
}
$builder->log(($logger === null) ? new NullLogger() : $logger);
return new QueueHandlingDaemon($driver, $builder->build(), $queueName);
} | [
"private",
"static",
"function",
"build",
"(",
"$",
"host",
",",
"$",
"port",
",",
"$",
"user",
",",
"$",
"pass",
",",
"$",
"queueName",
",",
"QueueConsumer",
"$",
"consumer",
",",
"$",
"sync",
",",
"$",
"escapeMode",
",",
"$",
"requeueOnFailure",
",",... | Build a daemon
@param string $host
@param string $port
@param string $user
@param string $pass
@param string $queueName
@param QueueConsumer $consumer
@param bool $sync
@param string $escapeMode
@param bool $requeueOnFailure
@param LoggerInterface $logger
@param bool $stopOnFailure
@return QueueHandlingDaemon | [
"Build",
"a",
"daemon"
] | a807d8a2fcc3cfd0064644cf18895c0573a3361c | https://github.com/Evaneos/burrow-tools/blob/a807d8a2fcc3cfd0064644cf18895c0573a3361c/src/Legacy/DaemonFactory.php#L128-L169 | train |
Xiphe/HTML | src/Xiphe/HTML/core/Generator.php | Generator._applyPreGenerationFilters | private static function _applyPreGenerationFilters(&$Obj)
{
if ($Obj->name == 'comment' && Config::get('noComments')) {
$Obj->destroy();
return false;
}
if (in_array('justGetObject', $Obj->options)) {
return $Obj;
}
if (in_array('return', $Obj->options)) {
ob_start();
}
} | php | private static function _applyPreGenerationFilters(&$Obj)
{
if ($Obj->name == 'comment' && Config::get('noComments')) {
$Obj->destroy();
return false;
}
if (in_array('justGetObject', $Obj->options)) {
return $Obj;
}
if (in_array('return', $Obj->options)) {
ob_start();
}
} | [
"private",
"static",
"function",
"_applyPreGenerationFilters",
"(",
"&",
"$",
"Obj",
")",
"{",
"if",
"(",
"$",
"Obj",
"->",
"name",
"==",
"'comment'",
"&&",
"Config",
"::",
"get",
"(",
"'noComments'",
")",
")",
"{",
"$",
"Obj",
"->",
"destroy",
"(",
")... | Things that must be done before the Tag will be created.
@param mixed &$Obj the current Tag or Module
@return mixed the object if it is in justGetObject mode or null. | [
"Things",
"that",
"must",
"be",
"done",
"before",
"the",
"Tag",
"will",
"be",
"created",
"."
] | 60cd0e869a75c535fdd785a26e351ded1507f1de | https://github.com/Xiphe/HTML/blob/60cd0e869a75c535fdd785a26e351ded1507f1de/src/Xiphe/HTML/core/Generator.php#L58-L73 | train |
Xiphe/HTML | src/Xiphe/HTML/core/Generator.php | Generator._applyPostGenerationFilters | private static function _applyPostGenerationFilters(&$Obj)
{
if (in_array('return', $Obj->options)) {
return ob_get_clean();
}
if (in_array('getObject', $Obj->options)) {
return $Obj;
}
} | php | private static function _applyPostGenerationFilters(&$Obj)
{
if (in_array('return', $Obj->options)) {
return ob_get_clean();
}
if (in_array('getObject', $Obj->options)) {
return $Obj;
}
} | [
"private",
"static",
"function",
"_applyPostGenerationFilters",
"(",
"&",
"$",
"Obj",
")",
"{",
"if",
"(",
"in_array",
"(",
"'return'",
",",
"$",
"Obj",
"->",
"options",
")",
")",
"{",
"return",
"ob_get_clean",
"(",
")",
";",
"}",
"if",
"(",
"in_array",
... | Things that must be done after the Tag was generated.
@param object &$Obj the current Tag or Module
@return mixed null or string if the tag is in getObject mode. | [
"Things",
"that",
"must",
"be",
"done",
"after",
"the",
"Tag",
"was",
"generated",
"."
] | 60cd0e869a75c535fdd785a26e351ded1507f1de | https://github.com/Xiphe/HTML/blob/60cd0e869a75c535fdd785a26e351ded1507f1de/src/Xiphe/HTML/core/Generator.php#L82-L91 | train |
Xiphe/HTML | src/Xiphe/HTML/core/Generator.php | Generator.parseAtts | public static function parseAtts($input)
{
if (is_object($input) && get_class($input) == 'Xiphe\HTML\core\Tag') {
$Tag = $input;
$input = $Tag->attributes;
}
/*
* Check if attributes are already in array form.
*/
if (is_array($input)) {
return $input;
}
/*
* If no attributes were passed - return empty array.
*/
if (empty($input)) {
return array();
}
/*
* Split the attribute string into separated attributes by |
*/
$atts = preg_split('/(?<=[^\\\])[|]+/', $input, -1, PREG_SPLIT_NO_EMPTY);
/*
* Set the tags attributes to array
*/
$input = array();
/*
* Split the attributes in key an value by =
*/
foreach ($atts as $k => $attr) {
$attr = preg_split('/(?<=[^\\\])[=]+/', $attr, 2);
foreach ($attr as $k => $v) {
/*
* replace escaped pipe and equal glyphs.
*/
$attr[$k] = preg_replace('/[\\\]([=|\|])/', '$1', $v);
}
/*
* Has no value or key
*/
if (count($attr) == 1) {
/*
* A single attribute was passed
*/
if (isset($Tag) && count($atts) == 1) {
if (($t = self::getKeyAlias($attr)) && !self::_ignoreKeyAlias($t, $Tag) ) {
extract($t);
$attr[1] = substr($attr[0], strlen($alias));
$attr[0] = $key;
} else {
/*
* use the key from TagInfo::$singleAttrkeys
*/
$key = self::getSingleAttrKey($Tag);
if (false !== $key) {
$attr[1] = $attr[0];
$attr[0] = $key;
} else {
$attr[1] = null;
}
}
} elseif (isset($Tag) && ($t = self::getKeyAlias($attr))) {
extract($t);
$attr[1] = substr($attr[0], strlen($alias));
$attr[0] = $key;
} else {
$attr[1] = null;
}
if (isset($Tag) && $attr[0] === '%default') {
$attr[0] = TagInfo::$singleAttrkeys[$Tag->name];
}
}
/*
* Write Attribute to tag.
*/
$input[$attr[0]] = $attr[1];
}
return $input;
} | php | public static function parseAtts($input)
{
if (is_object($input) && get_class($input) == 'Xiphe\HTML\core\Tag') {
$Tag = $input;
$input = $Tag->attributes;
}
/*
* Check if attributes are already in array form.
*/
if (is_array($input)) {
return $input;
}
/*
* If no attributes were passed - return empty array.
*/
if (empty($input)) {
return array();
}
/*
* Split the attribute string into separated attributes by |
*/
$atts = preg_split('/(?<=[^\\\])[|]+/', $input, -1, PREG_SPLIT_NO_EMPTY);
/*
* Set the tags attributes to array
*/
$input = array();
/*
* Split the attributes in key an value by =
*/
foreach ($atts as $k => $attr) {
$attr = preg_split('/(?<=[^\\\])[=]+/', $attr, 2);
foreach ($attr as $k => $v) {
/*
* replace escaped pipe and equal glyphs.
*/
$attr[$k] = preg_replace('/[\\\]([=|\|])/', '$1', $v);
}
/*
* Has no value or key
*/
if (count($attr) == 1) {
/*
* A single attribute was passed
*/
if (isset($Tag) && count($atts) == 1) {
if (($t = self::getKeyAlias($attr)) && !self::_ignoreKeyAlias($t, $Tag) ) {
extract($t);
$attr[1] = substr($attr[0], strlen($alias));
$attr[0] = $key;
} else {
/*
* use the key from TagInfo::$singleAttrkeys
*/
$key = self::getSingleAttrKey($Tag);
if (false !== $key) {
$attr[1] = $attr[0];
$attr[0] = $key;
} else {
$attr[1] = null;
}
}
} elseif (isset($Tag) && ($t = self::getKeyAlias($attr))) {
extract($t);
$attr[1] = substr($attr[0], strlen($alias));
$attr[0] = $key;
} else {
$attr[1] = null;
}
if (isset($Tag) && $attr[0] === '%default') {
$attr[0] = TagInfo::$singleAttrkeys[$Tag->name];
}
}
/*
* Write Attribute to tag.
*/
$input[$attr[0]] = $attr[1];
}
return $input;
} | [
"public",
"static",
"function",
"parseAtts",
"(",
"$",
"input",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"input",
")",
"&&",
"get_class",
"(",
"$",
"input",
")",
"==",
"'Xiphe\\HTML\\core\\Tag'",
")",
"{",
"$",
"Tag",
"=",
"$",
"input",
";",
"$",
... | Parser for string formated attribute arrays
Arrays will be returned immediate.
Multiple attributes should be separated by a pipe char "|"
Name and value of the attribute should be separated by an equal sign "="
The signs can be escaped by a backslash (foo\|bar will not be separated)
@param mixed $input the attribute array, string or Tag object
@return void | [
"Parser",
"for",
"string",
"formated",
"attribute",
"arrays"
] | 60cd0e869a75c535fdd785a26e351ded1507f1de | https://github.com/Xiphe/HTML/blob/60cd0e869a75c535fdd785a26e351ded1507f1de/src/Xiphe/HTML/core/Generator.php#L319-L408 | train |
Xiphe/HTML | src/Xiphe/HTML/core/Generator.php | Generator.updateClasses | public static function updateClasses(Tag &$Tag)
{
if (empty($Tag->classes) && isset($Tag->attributes['class'])) {
$classes = explode(' ', $Tag->attributes['class']);
} elseif (!empty($Tag->classes)) {
$classes = $Tag->classes;
}
if (isset($classes)) {
sort($classes);
$Tag->classes = $classes;
$Tag->attributes['class'] = implode(' ', $classes);
}
} | php | public static function updateClasses(Tag &$Tag)
{
if (empty($Tag->classes) && isset($Tag->attributes['class'])) {
$classes = explode(' ', $Tag->attributes['class']);
} elseif (!empty($Tag->classes)) {
$classes = $Tag->classes;
}
if (isset($classes)) {
sort($classes);
$Tag->classes = $classes;
$Tag->attributes['class'] = implode(' ', $classes);
}
} | [
"public",
"static",
"function",
"updateClasses",
"(",
"Tag",
"&",
"$",
"Tag",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"Tag",
"->",
"classes",
")",
"&&",
"isset",
"(",
"$",
"Tag",
"->",
"attributes",
"[",
"'class'",
"]",
")",
")",
"{",
"$",
"classes... | Builds an array of classes by seperating the class attribute by spaces
If if was not build before
If the classes array exists the attributes class will be updates
@param Tag &$Tag the current Tag
@return void | [
"Builds",
"an",
"array",
"of",
"classes",
"by",
"seperating",
"the",
"class",
"attribute",
"by",
"spaces",
"If",
"if",
"was",
"not",
"build",
"before"
] | 60cd0e869a75c535fdd785a26e351ded1507f1de | https://github.com/Xiphe/HTML/blob/60cd0e869a75c535fdd785a26e351ded1507f1de/src/Xiphe/HTML/core/Generator.php#L445-L458 | train |
Xiphe/HTML | src/Xiphe/HTML/core/Generator.php | Generator.mergeStyles | public static function mergeStyles($a, $b)
{
/*
* Cut the styles at the ; symbols
*/
$a = explode(';', $a);
/*
* Will contain all style keys and the indexes of them in $a.
*/
$amap = array();
/*
* Getter for the style key.
*/
$gk = function ($s) {
return trim(substr($s, 0, strpos($s, ':')));
};
/*
* Cleanup $a and build the map.
*/
foreach ($a as $k => $v) {
if (trim($v) == '') {
unset($a[$k]);
continue;
}
$a[$k] = trim($v);
$amap[$gk($v)] = $k;
}
/*
* Merge $b
*/
foreach (explode(';', $b) as $st) {
if (trim($st) == '') {
continue;
}
/*
* If the current key is set in the map.
* remove it from $a
*/
if (isset($amap[$gk($st)])) {
unset($a[$amap[$gk($st)]]);
}
$a[] = trim($st);
}
/*
* sort, minimize and return.
*/
sort($a);
return str_replace(array(': ', ': '), ':', implode(';', $a)).';';
} | php | public static function mergeStyles($a, $b)
{
/*
* Cut the styles at the ; symbols
*/
$a = explode(';', $a);
/*
* Will contain all style keys and the indexes of them in $a.
*/
$amap = array();
/*
* Getter for the style key.
*/
$gk = function ($s) {
return trim(substr($s, 0, strpos($s, ':')));
};
/*
* Cleanup $a and build the map.
*/
foreach ($a as $k => $v) {
if (trim($v) == '') {
unset($a[$k]);
continue;
}
$a[$k] = trim($v);
$amap[$gk($v)] = $k;
}
/*
* Merge $b
*/
foreach (explode(';', $b) as $st) {
if (trim($st) == '') {
continue;
}
/*
* If the current key is set in the map.
* remove it from $a
*/
if (isset($amap[$gk($st)])) {
unset($a[$amap[$gk($st)]]);
}
$a[] = trim($st);
}
/*
* sort, minimize and return.
*/
sort($a);
return str_replace(array(': ', ': '), ':', implode(';', $a)).';';
} | [
"public",
"static",
"function",
"mergeStyles",
"(",
"$",
"a",
",",
"$",
"b",
")",
"{",
"/*\n * Cut the styles at the ; symbols\n */",
"$",
"a",
"=",
"explode",
"(",
"';'",
",",
"$",
"a",
")",
";",
"/*\n * Will contain all style keys and the ind... | Merges two strings containing styles.
@param string $a style A
@param string $b style B
@return string style A + style B | [
"Merges",
"two",
"strings",
"containing",
"styles",
"."
] | 60cd0e869a75c535fdd785a26e351ded1507f1de | https://github.com/Xiphe/HTML/blob/60cd0e869a75c535fdd785a26e351ded1507f1de/src/Xiphe/HTML/core/Generator.php#L468-L523 | train |
Xiphe/HTML | src/Xiphe/HTML/core/Generator.php | Generator.mergeClasses | public static function mergeClasses($a, $b)
{
$str = 0;
if (!is_array($a)) {
$str++;
$a = explode(' ', $a);
}
if (!is_array($b)) {
$str++;
$b = explode(' ', $b);
}
$b = array_filter($b, function ($item) use ($a) {
return !in_array($item, $a);
});
$r = array_merge($a, $b);
sort($r);
if ($str === 2) {
$r = implode(' ', $r);
}
return $r;
} | php | public static function mergeClasses($a, $b)
{
$str = 0;
if (!is_array($a)) {
$str++;
$a = explode(' ', $a);
}
if (!is_array($b)) {
$str++;
$b = explode(' ', $b);
}
$b = array_filter($b, function ($item) use ($a) {
return !in_array($item, $a);
});
$r = array_merge($a, $b);
sort($r);
if ($str === 2) {
$r = implode(' ', $r);
}
return $r;
} | [
"public",
"static",
"function",
"mergeClasses",
"(",
"$",
"a",
",",
"$",
"b",
")",
"{",
"$",
"str",
"=",
"0",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"a",
")",
")",
"{",
"$",
"str",
"++",
";",
"$",
"a",
"=",
"explode",
"(",
"' '",
",",
"... | Merge two strings or arrays of classes
@param string|array $a
@param string|array $b
@return string|array | [
"Merge",
"two",
"strings",
"or",
"arrays",
"of",
"classes"
] | 60cd0e869a75c535fdd785a26e351ded1507f1de | https://github.com/Xiphe/HTML/blob/60cd0e869a75c535fdd785a26e351ded1507f1de/src/Xiphe/HTML/core/Generator.php#L532-L557 | train |
Xiphe/HTML | src/Xiphe/HTML/core/Generator.php | Generator.mergeAttrs | public static function mergeAttrs($b, $a, $combineClasses = true, $combineStyles = true)
{
$a = self::parseAtts($a);
$b = self::parseAtts($b);
if ($combineClasses && isset($a['class']) && isset($b['class'])) {
$a['class'] = self::mergeClasses($a['class'], $b['class']);
unset($b['class']);
}
if ($combineStyles && isset($a['style']) && isset($b['style'])) {
$a['style'] = self::mergeStyles($a['style'], $b['style']);
unset($b['style']);
}
$r = array_merge($b, $a);
ksort($r);
return $r;
} | php | public static function mergeAttrs($b, $a, $combineClasses = true, $combineStyles = true)
{
$a = self::parseAtts($a);
$b = self::parseAtts($b);
if ($combineClasses && isset($a['class']) && isset($b['class'])) {
$a['class'] = self::mergeClasses($a['class'], $b['class']);
unset($b['class']);
}
if ($combineStyles && isset($a['style']) && isset($b['style'])) {
$a['style'] = self::mergeStyles($a['style'], $b['style']);
unset($b['style']);
}
$r = array_merge($b, $a);
ksort($r);
return $r;
} | [
"public",
"static",
"function",
"mergeAttrs",
"(",
"$",
"b",
",",
"$",
"a",
",",
"$",
"combineClasses",
"=",
"true",
",",
"$",
"combineStyles",
"=",
"true",
")",
"{",
"$",
"a",
"=",
"self",
"::",
"parseAtts",
"(",
"$",
"a",
")",
";",
"$",
"b",
"=... | Merge two sets of Tag attributes.
@param string|array $a
@param string|array $b
@param boolean $combineClasses set false to overwrite classes of $b by the ones from $a
@param boolean $combineStyles set false to overwrite styles of $b by the ones from $a
@return array | [
"Merge",
"two",
"sets",
"of",
"Tag",
"attributes",
"."
] | 60cd0e869a75c535fdd785a26e351ded1507f1de | https://github.com/Xiphe/HTML/blob/60cd0e869a75c535fdd785a26e351ded1507f1de/src/Xiphe/HTML/core/Generator.php#L568-L588 | train |
Xiphe/HTML | src/Xiphe/HTML/core/Generator.php | Generator.addDefaultAttributes | public static function addDefaultAttributes(Tag &$Tag)
{
if (isset(TagInfo::$defaultAttributes[$Tag->name])) {
$Tag->attributes = array_merge(
TagInfo::$defaultAttributes[$Tag->name],
$Tag->attributes
);
}
} | php | public static function addDefaultAttributes(Tag &$Tag)
{
if (isset(TagInfo::$defaultAttributes[$Tag->name])) {
$Tag->attributes = array_merge(
TagInfo::$defaultAttributes[$Tag->name],
$Tag->attributes
);
}
} | [
"public",
"static",
"function",
"addDefaultAttributes",
"(",
"Tag",
"&",
"$",
"Tag",
")",
"{",
"if",
"(",
"isset",
"(",
"TagInfo",
"::",
"$",
"defaultAttributes",
"[",
"$",
"Tag",
"->",
"name",
"]",
")",
")",
"{",
"$",
"Tag",
"->",
"attributes",
"=",
... | Adds default attributes to the tag.
@param Tag &$Tag the current Tag.
@see TagInfo::$defaultAttributes
@return void | [
"Adds",
"default",
"attributes",
"to",
"the",
"tag",
"."
] | 60cd0e869a75c535fdd785a26e351ded1507f1de | https://github.com/Xiphe/HTML/blob/60cd0e869a75c535fdd785a26e351ded1507f1de/src/Xiphe/HTML/core/Generator.php#L598-L606 | train |
Xiphe/HTML | src/Xiphe/HTML/core/Generator.php | Generator.addDefaultOptions | public static function addDefaultOptions(Tag &$Tag)
{
if (isset(TagInfo::$defaultOptions[$Tag->name])) {
foreach (TagInfo::$defaultOptions[$Tag->name] as $defopt) {
if (!in_array($defopt, $Tag->options)) {
$Tag->options[] = $defopt;
}
}
}
} | php | public static function addDefaultOptions(Tag &$Tag)
{
if (isset(TagInfo::$defaultOptions[$Tag->name])) {
foreach (TagInfo::$defaultOptions[$Tag->name] as $defopt) {
if (!in_array($defopt, $Tag->options)) {
$Tag->options[] = $defopt;
}
}
}
} | [
"public",
"static",
"function",
"addDefaultOptions",
"(",
"Tag",
"&",
"$",
"Tag",
")",
"{",
"if",
"(",
"isset",
"(",
"TagInfo",
"::",
"$",
"defaultOptions",
"[",
"$",
"Tag",
"->",
"name",
"]",
")",
")",
"{",
"foreach",
"(",
"TagInfo",
"::",
"$",
"def... | Adds default options to the tag.
@param Tag &$Tag the current Tag.
@see TagInfo::$defaultOptions
@return void | [
"Adds",
"default",
"options",
"to",
"the",
"tag",
"."
] | 60cd0e869a75c535fdd785a26e351ded1507f1de | https://github.com/Xiphe/HTML/blob/60cd0e869a75c535fdd785a26e351ded1507f1de/src/Xiphe/HTML/core/Generator.php#L616-L625 | train |
Xiphe/HTML | src/Xiphe/HTML/core/Generator.php | Generator.addDoubleAttributes | public static function addDoubleAttributes(Tag &$Tag)
{
if (isset(TagInfo::$doubleAttrs[$Tag->name])) {
$missing = array();
$found = '';
foreach (TagInfo::$doubleAttrs[$Tag->name] as $k => $name) {
if ($k === '%callback') {
$callback = $name;
continue;
}
if (isset($Tag->attributes[$name])) {
$found = $Tag->attributes[$name];
} else {
$missing[] = $name;
}
}
if (empty($found) || empty($missing)) {
return;
}
foreach ($missing as $k) {
$Tag->attributes[$k] = $found;
}
if (count($missing) && isset($callback) && is_callable($callback)) {
call_user_func_array($callback, array(&$Tag, $missing));
}
}
} | php | public static function addDoubleAttributes(Tag &$Tag)
{
if (isset(TagInfo::$doubleAttrs[$Tag->name])) {
$missing = array();
$found = '';
foreach (TagInfo::$doubleAttrs[$Tag->name] as $k => $name) {
if ($k === '%callback') {
$callback = $name;
continue;
}
if (isset($Tag->attributes[$name])) {
$found = $Tag->attributes[$name];
} else {
$missing[] = $name;
}
}
if (empty($found) || empty($missing)) {
return;
}
foreach ($missing as $k) {
$Tag->attributes[$k] = $found;
}
if (count($missing) && isset($callback) && is_callable($callback)) {
call_user_func_array($callback, array(&$Tag, $missing));
}
}
} | [
"public",
"static",
"function",
"addDoubleAttributes",
"(",
"Tag",
"&",
"$",
"Tag",
")",
"{",
"if",
"(",
"isset",
"(",
"TagInfo",
"::",
"$",
"doubleAttrs",
"[",
"$",
"Tag",
"->",
"name",
"]",
")",
")",
"{",
"$",
"missing",
"=",
"array",
"(",
")",
"... | Duplicates some attributes if needed.
src & alt on image or name and id on inputs
@param Tag &$Tag the current Tag
@return void | [
"Duplicates",
"some",
"attributes",
"if",
"needed",
"."
] | 60cd0e869a75c535fdd785a26e351ded1507f1de | https://github.com/Xiphe/HTML/blob/60cd0e869a75c535fdd785a26e351ded1507f1de/src/Xiphe/HTML/core/Generator.php#L636-L663 | train |
Xiphe/HTML | src/Xiphe/HTML/core/Generator.php | Generator.magicAlt | public static function magicAlt(Tag &$Tag, $changed)
{
switch ($Tag->realName) {
case 'img':
if (in_array('alt', $changed)) {
$Tag->attributes['alt'] = basename($Tag->attributes['alt']);
}
break;
default:
break;
}
} | php | public static function magicAlt(Tag &$Tag, $changed)
{
switch ($Tag->realName) {
case 'img':
if (in_array('alt', $changed)) {
$Tag->attributes['alt'] = basename($Tag->attributes['alt']);
}
break;
default:
break;
}
} | [
"public",
"static",
"function",
"magicAlt",
"(",
"Tag",
"&",
"$",
"Tag",
",",
"$",
"changed",
")",
"{",
"switch",
"(",
"$",
"Tag",
"->",
"realName",
")",
"{",
"case",
"'img'",
":",
"if",
"(",
"in_array",
"(",
"'alt'",
",",
"$",
"changed",
")",
")",... | Callback function for double attrs on an image tag.
@param Tag &$Tag the current tag
@param array $changed the tags that were changed
@return void | [
"Callback",
"function",
"for",
"double",
"attrs",
"on",
"an",
"image",
"tag",
"."
] | 60cd0e869a75c535fdd785a26e351ded1507f1de | https://github.com/Xiphe/HTML/blob/60cd0e869a75c535fdd785a26e351ded1507f1de/src/Xiphe/HTML/core/Generator.php#L673-L684 | train |
Xiphe/HTML | src/Xiphe/HTML/core/Generator.php | Generator.getKeyAlias | public static function getKeyAlias(array &$attr)
{
foreach (TagInfo::$attrKeyAliases as $alias => $key) {
if (strpos($attr[0], $alias) === 0) {
return compact('key', 'alias');
}
}
return false;
} | php | public static function getKeyAlias(array &$attr)
{
foreach (TagInfo::$attrKeyAliases as $alias => $key) {
if (strpos($attr[0], $alias) === 0) {
return compact('key', 'alias');
}
}
return false;
} | [
"public",
"static",
"function",
"getKeyAlias",
"(",
"array",
"&",
"$",
"attr",
")",
"{",
"foreach",
"(",
"TagInfo",
"::",
"$",
"attrKeyAliases",
"as",
"$",
"alias",
"=>",
"$",
"key",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"attr",
"[",
"0",
"]",
"... | Checks and applies aliases for attribute keys
For example .foo will be converted into class="foo" ("." is the alias for "class")
@param array &$attr the current attribute
@see TagInfo::$attrKeyAliases
@return mixed alias if found, false if not | [
"Checks",
"and",
"applies",
"aliases",
"for",
"attribute",
"keys"
] | 60cd0e869a75c535fdd785a26e351ded1507f1de | https://github.com/Xiphe/HTML/blob/60cd0e869a75c535fdd785a26e351ded1507f1de/src/Xiphe/HTML/core/Generator.php#L798-L807 | train |
Xiphe/HTML | src/Xiphe/HTML/core/Generator.php | Generator._ignoreKeyAlias | private static function _ignoreKeyAlias(array $t, Tag &$Tag)
{
extract($t);
$single = self::getSingleAttrKey($Tag);
if (isset(TagInfo::$ignoreAlisasesOnSingle[$single])
&& in_array($alias, TagInfo::$ignoreAlisasesOnSingle[$single])
) {
return true;
}
return false;
} | php | private static function _ignoreKeyAlias(array $t, Tag &$Tag)
{
extract($t);
$single = self::getSingleAttrKey($Tag);
if (isset(TagInfo::$ignoreAlisasesOnSingle[$single])
&& in_array($alias, TagInfo::$ignoreAlisasesOnSingle[$single])
) {
return true;
}
return false;
} | [
"private",
"static",
"function",
"_ignoreKeyAlias",
"(",
"array",
"$",
"t",
",",
"Tag",
"&",
"$",
"Tag",
")",
"{",
"extract",
"(",
"$",
"t",
")",
";",
"$",
"single",
"=",
"self",
"::",
"getSingleAttrKey",
"(",
"$",
"Tag",
")",
";",
"if",
"(",
"isse... | Checks if the current key alias is meant to be ignored.
It's important to make sure, that this is only used to tags containing just one attribute.
@param array $t the attributes alias
@param Tag &$Tag the current Tag.
@return boolean true if it alias should be ignored. | [
"Checks",
"if",
"the",
"current",
"key",
"alias",
"is",
"meant",
"to",
"be",
"ignored",
"."
] | 60cd0e869a75c535fdd785a26e351ded1507f1de | https://github.com/Xiphe/HTML/blob/60cd0e869a75c535fdd785a26e351ded1507f1de/src/Xiphe/HTML/core/Generator.php#L819-L830 | train |
Xiphe/HTML | src/Xiphe/HTML/core/Generator.php | Generator.getSingleAttrKey | public static function getSingleAttrKey(Tag &$Tag)
{
if (isset(TagInfo::$singleAttrKeys[$Tag->name])) {
return TagInfo::$singleAttrKeys[$Tag->name];
} else {
return TagInfo::$defaultSingleAttrKey;
}
} | php | public static function getSingleAttrKey(Tag &$Tag)
{
if (isset(TagInfo::$singleAttrKeys[$Tag->name])) {
return TagInfo::$singleAttrKeys[$Tag->name];
} else {
return TagInfo::$defaultSingleAttrKey;
}
} | [
"public",
"static",
"function",
"getSingleAttrKey",
"(",
"Tag",
"&",
"$",
"Tag",
")",
"{",
"if",
"(",
"isset",
"(",
"TagInfo",
"::",
"$",
"singleAttrKeys",
"[",
"$",
"Tag",
"->",
"name",
"]",
")",
")",
"{",
"return",
"TagInfo",
"::",
"$",
"singleAttrKe... | Getter for the single attribute keys
For Example if you do $HTML->a('example', 'http://example.org'); The url will be used
as value for the href attribute. Defaults to class
($HTML->div('foo', 'bar') will turn into <div class="bar">foo</div>)
@param Tag &$Tag the current Tag
@see TagInfo::$singleAttrkeys
@see TagInfo::$defaultSingleAttrkey
@return string the attribute key. | [
"Getter",
"for",
"the",
"single",
"attribute",
"keys"
] | 60cd0e869a75c535fdd785a26e351ded1507f1de | https://github.com/Xiphe/HTML/blob/60cd0e869a75c535fdd785a26e351ded1507f1de/src/Xiphe/HTML/core/Generator.php#L845-L852 | train |
stubbles/stubbles-xml | src/main/php/XmlStreamWriter.php | XmlStreamWriter.writeStartElement | public function writeStartElement(string $elementName): self
{
$this->doWriteStartElement($elementName);
$this->depth++;
return $this;
} | php | public function writeStartElement(string $elementName): self
{
$this->doWriteStartElement($elementName);
$this->depth++;
return $this;
} | [
"public",
"function",
"writeStartElement",
"(",
"string",
"$",
"elementName",
")",
":",
"self",
"{",
"$",
"this",
"->",
"doWriteStartElement",
"(",
"$",
"elementName",
")",
";",
"$",
"this",
"->",
"depth",
"++",
";",
"return",
"$",
"this",
";",
"}"
] | Write an opening tag
@param string $elementName
@return \stubbles\xml\XmlStreamWriter | [
"Write",
"an",
"opening",
"tag"
] | 595bc5266190fd9661e9eee140cf2378f623e50a | https://github.com/stubbles/stubbles-xml/blob/595bc5266190fd9661e9eee140cf2378f623e50a/src/main/php/XmlStreamWriter.php#L117-L122 | train |
stubbles/stubbles-xml | src/main/php/XmlStreamWriter.php | XmlStreamWriter.writeEndElement | public function writeEndElement(): self
{
if ($this->isFinished()) {
throw new \LogicException('Can not write end elements, no element open.');
}
$this->doWriteEndElement();
$this->depth--;
return $this;
} | php | public function writeEndElement(): self
{
if ($this->isFinished()) {
throw new \LogicException('Can not write end elements, no element open.');
}
$this->doWriteEndElement();
$this->depth--;
return $this;
} | [
"public",
"function",
"writeEndElement",
"(",
")",
":",
"self",
"{",
"if",
"(",
"$",
"this",
"->",
"isFinished",
"(",
")",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"'Can not write end elements, no element open.'",
")",
";",
"}",
"$",
"this",
"-... | Write an end element
@return \stubbles\xml\XmlStreamWriter
@throws \LogicException in case no element is open | [
"Write",
"an",
"end",
"element"
] | 595bc5266190fd9661e9eee140cf2378f623e50a | https://github.com/stubbles/stubbles-xml/blob/595bc5266190fd9661e9eee140cf2378f623e50a/src/main/php/XmlStreamWriter.php#L188-L197 | train |
Xiphe/HTML | src/Xiphe/HTML/core/Cleaner.php | Cleaner.getClean | public static function getClean($str)
{
if (is_object($str) && get_class($str) == 'Xiphe\HTML\core\Tag') {
$Tag = $str;
$str = $Tag->content;
}
switch (Config::get('cleanMode')) {
case 'strong':
$str = self::getStrong($str);
break;
case 'basic':
$str = self::getBasic($str);
break;
default:
return $str;
}
if (isset($Tag)) {
$Tag->content = $str;
}
return $str;
} | php | public static function getClean($str)
{
if (is_object($str) && get_class($str) == 'Xiphe\HTML\core\Tag') {
$Tag = $str;
$str = $Tag->content;
}
switch (Config::get('cleanMode')) {
case 'strong':
$str = self::getStrong($str);
break;
case 'basic':
$str = self::getBasic($str);
break;
default:
return $str;
}
if (isset($Tag)) {
$Tag->content = $str;
}
return $str;
} | [
"public",
"static",
"function",
"getClean",
"(",
"$",
"str",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"str",
")",
"&&",
"get_class",
"(",
"$",
"str",
")",
"==",
"'Xiphe\\HTML\\core\\Tag'",
")",
"{",
"$",
"Tag",
"=",
"$",
"str",
";",
"$",
"str",
... | Cleans up the given content
@param mixed $str string to be cleaned or Xiphe\HTML\core\Tag with content
@return string the cleaned string. | [
"Cleans",
"up",
"the",
"given",
"content"
] | 60cd0e869a75c535fdd785a26e351ded1507f1de | https://github.com/Xiphe/HTML/blob/60cd0e869a75c535fdd785a26e351ded1507f1de/src/Xiphe/HTML/core/Cleaner.php#L55-L76 | train |
Xiphe/HTML | src/Xiphe/HTML/core/Cleaner.php | Cleaner.getBasic | public static function getBasic($str)
{
$r = '';
/*
* Split the string by line breakes.
*/
foreach (preg_split('/\n\r|\n|\r/', $str, -1, PREG_SPLIT_NO_EMPTY) as $k => $line) {
/*
* And append it with tabs and line breaks to the return var.
*/
$r .= Generator::getTabs();
$r .= trim($line);
$r .= Generator::getLineBreak();
}
return $r;
} | php | public static function getBasic($str)
{
$r = '';
/*
* Split the string by line breakes.
*/
foreach (preg_split('/\n\r|\n|\r/', $str, -1, PREG_SPLIT_NO_EMPTY) as $k => $line) {
/*
* And append it with tabs and line breaks to the return var.
*/
$r .= Generator::getTabs();
$r .= trim($line);
$r .= Generator::getLineBreak();
}
return $r;
} | [
"public",
"static",
"function",
"getBasic",
"(",
"$",
"str",
")",
"{",
"$",
"r",
"=",
"''",
";",
"/*\n * Split the string by line breakes.\n */",
"foreach",
"(",
"preg_split",
"(",
"'/\\n\\r|\\n|\\r/'",
",",
"$",
"str",
",",
"-",
"1",
",",
"PREG_... | unifies the tabs in the given string.
@param string $str the string that will be cleaned up.
@return string | [
"unifies",
"the",
"tabs",
"in",
"the",
"given",
"string",
"."
] | 60cd0e869a75c535fdd785a26e351ded1507f1de | https://github.com/Xiphe/HTML/blob/60cd0e869a75c535fdd785a26e351ded1507f1de/src/Xiphe/HTML/core/Cleaner.php#L109-L125 | train |
Xiphe/HTML | src/Xiphe/HTML/core/Cleaner.php | Cleaner.parseAttrs | public static function parseAttrs($attr)
{
/*
* Skip empty strings
*/
if (trim($attr) == '') {
return '';
}
/*
* Match all attribute like parts from string.
*/
preg_match_all('/[a-zA-Z0-9-_:.]+(\s?=\s?("|\')[^\2]*\2|\s)/U', $attr, $attr);
/*
* Get the interessting part.
*/
$attr = $attr[0];
$r = array();
foreach ($attr as $k => $v) {
/*
* Skip empty matches
*/
if (trim($v) == '') {
continue;
}
/*
* Split by the first = symbol.
*/
$e = explode('=', $v, 2);
/*
* attribute name.
*/
$at = trim($e[0]);
/*
* attribute value.
*/
$val = isset($e[1]) ? trim($e[1]) : null;
if ($val !== null) {
/*
* trim the quotation symbols
*/
$val = trim($val, substr($val, 0, 1));
}
/*
* store it in the return variable.
*/
$r[$at] = $val;
}
return $r;
} | php | public static function parseAttrs($attr)
{
/*
* Skip empty strings
*/
if (trim($attr) == '') {
return '';
}
/*
* Match all attribute like parts from string.
*/
preg_match_all('/[a-zA-Z0-9-_:.]+(\s?=\s?("|\')[^\2]*\2|\s)/U', $attr, $attr);
/*
* Get the interessting part.
*/
$attr = $attr[0];
$r = array();
foreach ($attr as $k => $v) {
/*
* Skip empty matches
*/
if (trim($v) == '') {
continue;
}
/*
* Split by the first = symbol.
*/
$e = explode('=', $v, 2);
/*
* attribute name.
*/
$at = trim($e[0]);
/*
* attribute value.
*/
$val = isset($e[1]) ? trim($e[1]) : null;
if ($val !== null) {
/*
* trim the quotation symbols
*/
$val = trim($val, substr($val, 0, 1));
}
/*
* store it in the return variable.
*/
$r[$at] = $val;
}
return $r;
} | [
"public",
"static",
"function",
"parseAttrs",
"(",
"$",
"attr",
")",
"{",
"/*\n * Skip empty strings\n */",
"if",
"(",
"trim",
"(",
"$",
"attr",
")",
"==",
"''",
")",
"{",
"return",
"''",
";",
"}",
"/*\n * Match all attribute like parts from ... | Parses tag attributes into an array.
@param string $attr a sting with attributes or a starting tag
@return array the attributes in array form. | [
"Parses",
"tag",
"attributes",
"into",
"an",
"array",
"."
] | 60cd0e869a75c535fdd785a26e351ded1507f1de | https://github.com/Xiphe/HTML/blob/60cd0e869a75c535fdd785a26e351ded1507f1de/src/Xiphe/HTML/core/Cleaner.php#L134-L189 | train |
Xiphe/HTML | src/Xiphe/HTML/core/Cleaner.php | Cleaner.getStrong | public static function getStrong($str)
{
/*
* Split the content by html tags.
*/
$tree = preg_split(
'/(<[^!]?[^>]+>(<![^>]+>)?)/',
$str,
-1,
PREG_SPLIT_OFFSET_CAPTURE | PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY
);
/*
* Initiate variables.
*/
$r = array();
$line = '';
$isInline = true;
$oneLine = array();
$lastWasTag = false;
/*
* Loop throu the tree.
*/
foreach ($tree as $k => $elm) {
/*
* Check what kind of element this is.
*/
$info;
switch (self::_getTreeElm($elm[0], $info)) {
case 'start':
/*
* It's a starting tag
*/
$add = new Tag(
$info[1], /* The Tags Name */
array(self::parseAttrs($info[2])), /* The attributes */
array(
'generate',
($info[3] == '/>' ? 'selfQlose' : 'doNotSelfQlose'),
'start',
(in_array($info[1], TagInfo::$inlineTags) ? 'inline' : null)
)
);
break;
case 'end':
/*
* It is a closing tag
*/
$add = Store::get();
break;
case 'comment':
case 'content':
default:
/*
* It's something else
*/
$add = $elm[0];
break;
}
/*
* Add the current content to the output.
*/
self::_toLine($add, $r, $line, $isInline, $oneLine, $lastWasTag);
}
/*
* Check if there is still content in the current line
* and add it to the return array.
*/
if (strlen($line)) {
$r[] = $line;
}
/*
* implode the return array using line breaks and return the string.
*/
return implode(Generator::getLineBreak(), $r).Generator::getLineBreak();
} | php | public static function getStrong($str)
{
/*
* Split the content by html tags.
*/
$tree = preg_split(
'/(<[^!]?[^>]+>(<![^>]+>)?)/',
$str,
-1,
PREG_SPLIT_OFFSET_CAPTURE | PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY
);
/*
* Initiate variables.
*/
$r = array();
$line = '';
$isInline = true;
$oneLine = array();
$lastWasTag = false;
/*
* Loop throu the tree.
*/
foreach ($tree as $k => $elm) {
/*
* Check what kind of element this is.
*/
$info;
switch (self::_getTreeElm($elm[0], $info)) {
case 'start':
/*
* It's a starting tag
*/
$add = new Tag(
$info[1], /* The Tags Name */
array(self::parseAttrs($info[2])), /* The attributes */
array(
'generate',
($info[3] == '/>' ? 'selfQlose' : 'doNotSelfQlose'),
'start',
(in_array($info[1], TagInfo::$inlineTags) ? 'inline' : null)
)
);
break;
case 'end':
/*
* It is a closing tag
*/
$add = Store::get();
break;
case 'comment':
case 'content':
default:
/*
* It's something else
*/
$add = $elm[0];
break;
}
/*
* Add the current content to the output.
*/
self::_toLine($add, $r, $line, $isInline, $oneLine, $lastWasTag);
}
/*
* Check if there is still content in the current line
* and add it to the return array.
*/
if (strlen($line)) {
$r[] = $line;
}
/*
* implode the return array using line breaks and return the string.
*/
return implode(Generator::getLineBreak(), $r).Generator::getLineBreak();
} | [
"public",
"static",
"function",
"getStrong",
"(",
"$",
"str",
")",
"{",
"/*\n * Split the content by html tags.\n */",
"$",
"tree",
"=",
"preg_split",
"(",
"'/(<[^!]?[^>]+>(<![^>]+>)?)/'",
",",
"$",
"str",
",",
"-",
"1",
",",
"PREG_SPLIT_OFFSET_CAPTURE",... | Tears the given string into its smalest possible parts and rebuilds it
so it will fit nicely into the markup generated by Xiphe\HTML
@param string $str the string that needs cleaning
@return string the cleaned string. | [
"Tears",
"the",
"given",
"string",
"into",
"its",
"smalest",
"possible",
"parts",
"and",
"rebuilds",
"it",
"so",
"it",
"will",
"fit",
"nicely",
"into",
"the",
"markup",
"generated",
"by",
"Xiphe",
"\\",
"HTML"
] | 60cd0e869a75c535fdd785a26e351ded1507f1de | https://github.com/Xiphe/HTML/blob/60cd0e869a75c535fdd785a26e351ded1507f1de/src/Xiphe/HTML/core/Cleaner.php#L217-L297 | train |
Xiphe/HTML | src/Xiphe/HTML/core/Cleaner.php | Cleaner._getTreeElm | private static function _getTreeElm($str, &$info)
{
/*
* Normalize the string.
*/
$str = preg_replace('/(\n\r|\n|\r|\s)+/', ' ', $str);
/*
* Identify it by checking its first symbols.
*/
if (strpos($str, '</') === 0) {
return 'end';
} elseif (strpos($str, '<!') === 0) {
return 'content';
} elseif (strpos($str, '<!--') === 0) {
return 'comment';
} elseif (strpos($str, '<') === 0) {
preg_match('/<([a-zA-Z0-9]+)(.*?(?=\/>|>))(\/>|>)+/', $str, $info);
return 'start';
}
return 'content';
} | php | private static function _getTreeElm($str, &$info)
{
/*
* Normalize the string.
*/
$str = preg_replace('/(\n\r|\n|\r|\s)+/', ' ', $str);
/*
* Identify it by checking its first symbols.
*/
if (strpos($str, '</') === 0) {
return 'end';
} elseif (strpos($str, '<!') === 0) {
return 'content';
} elseif (strpos($str, '<!--') === 0) {
return 'comment';
} elseif (strpos($str, '<') === 0) {
preg_match('/<([a-zA-Z0-9]+)(.*?(?=\/>|>))(\/>|>)+/', $str, $info);
return 'start';
}
return 'content';
} | [
"private",
"static",
"function",
"_getTreeElm",
"(",
"$",
"str",
",",
"&",
"$",
"info",
")",
"{",
"/*\n * Normalize the string.\n */",
"$",
"str",
"=",
"preg_replace",
"(",
"'/(\\n\\r|\\n|\\r|\\s)+/'",
",",
"' '",
",",
"$",
"str",
")",
";",
"/*\n... | Checks the type of the given tree element.
@param string $str the current tree element
@param array &$info additional info will be inserted here
@return string the type. | [
"Checks",
"the",
"type",
"of",
"the",
"given",
"tree",
"element",
"."
] | 60cd0e869a75c535fdd785a26e351ded1507f1de | https://github.com/Xiphe/HTML/blob/60cd0e869a75c535fdd785a26e351ded1507f1de/src/Xiphe/HTML/core/Cleaner.php#L471-L494 | train |
stubbles/stubbles-xml | src/main/php/xsl/XslProcessorProvider.php | XslProcessorProvider.callbacks | protected function callbacks(): array
{
if (!is_array($this->callbackList)) {
if (!file_exists($this->configPath . '/xsl-callbacks.ini')) {
$this->callbackList = [];
} else {
$this->callbackList = @parse_ini_file($this->configPath . '/xsl-callbacks.ini');
if (false === $this->callbackList) {
throw new XslCallbackException(
'XSL callback in ' . $this->configPath
. '/xsl-callbacks.ini contains errors and can not be parsed.'
);
}
}
}
return $this->callbackList;
} | php | protected function callbacks(): array
{
if (!is_array($this->callbackList)) {
if (!file_exists($this->configPath . '/xsl-callbacks.ini')) {
$this->callbackList = [];
} else {
$this->callbackList = @parse_ini_file($this->configPath . '/xsl-callbacks.ini');
if (false === $this->callbackList) {
throw new XslCallbackException(
'XSL callback in ' . $this->configPath
. '/xsl-callbacks.ini contains errors and can not be parsed.'
);
}
}
}
return $this->callbackList;
} | [
"protected",
"function",
"callbacks",
"(",
")",
":",
"array",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"this",
"->",
"callbackList",
")",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"this",
"->",
"configPath",
".",
"'/xsl-callbacks.ini'",
")",
... | reads list of callbacks from configuration
@return array
@throws \stubbles\xml\xsl\XslCallbackException | [
"reads",
"list",
"of",
"callbacks",
"from",
"configuration"
] | 595bc5266190fd9661e9eee140cf2378f623e50a | https://github.com/stubbles/stubbles-xml/blob/595bc5266190fd9661e9eee140cf2378f623e50a/src/main/php/xsl/XslProcessorProvider.php#L110-L127 | train |
Xiphe/HTML | src/Xiphe/HTML/core/BasicModule.php | BasicModule.init | final public function init(&$args, &$options, &$called)
{
$this->args = &$args;
$this->options = &$options;
$this->called = &$called;
/*
* Execute Module generated Hook if Wordpress is available.
*/
if (class_exists('\WP')) {
call_user_func_array('do_action', array('Xiphe\HTML\ModuleCreated', &$this, Config::getHTMLInstance()));
}
} | php | final public function init(&$args, &$options, &$called)
{
$this->args = &$args;
$this->options = &$options;
$this->called = &$called;
/*
* Execute Module generated Hook if Wordpress is available.
*/
if (class_exists('\WP')) {
call_user_func_array('do_action', array('Xiphe\HTML\ModuleCreated', &$this, Config::getHTMLInstance()));
}
} | [
"final",
"public",
"function",
"init",
"(",
"&",
"$",
"args",
",",
"&",
"$",
"options",
",",
"&",
"$",
"called",
")",
"{",
"$",
"this",
"->",
"args",
"=",
"&",
"$",
"args",
";",
"$",
"this",
"->",
"options",
"=",
"&",
"$",
"options",
";",
"$",
... | Initiation of a new module.
@param array &$args argument passed during HTML call
@param array &$options (tag)-options added to the module
@param string &$called original call if module has alias
@return void | [
"Initiation",
"of",
"a",
"new",
"module",
"."
] | 60cd0e869a75c535fdd785a26e351ded1507f1de | https://github.com/Xiphe/HTML/blob/60cd0e869a75c535fdd785a26e351ded1507f1de/src/Xiphe/HTML/core/BasicModule.php#L36-L48 | train |
Xiphe/HTML | src/Xiphe/HTML/core/BasicModule.php | BasicModule.generate | final public function generate() {
$options = array_merge($this->options, (array) 'generate');
Generator::call($this->called, $this->args, $options);
} | php | final public function generate() {
$options = array_merge($this->options, (array) 'generate');
Generator::call($this->called, $this->args, $options);
} | [
"final",
"public",
"function",
"generate",
"(",
")",
"{",
"$",
"options",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"options",
",",
"(",
"array",
")",
"'generate'",
")",
";",
"Generator",
"::",
"call",
"(",
"$",
"this",
"->",
"called",
",",
"$",
"t... | Generates a default tag using the current module parameters.
@return void | [
"Generates",
"a",
"default",
"tag",
"using",
"the",
"current",
"module",
"parameters",
"."
] | 60cd0e869a75c535fdd785a26e351ded1507f1de | https://github.com/Xiphe/HTML/blob/60cd0e869a75c535fdd785a26e351ded1507f1de/src/Xiphe/HTML/core/BasicModule.php#L110-L113 | train |
M6Web/WsClientBundle | src/M6Web/Bundle/WSClientBundle/DataCollector/WSClientDataCollector.php | WSClientDataCollector.onWSClientCommand | public function onWSClientCommand(WSEventDispatcher\WSClientEvent $event)
{
//$command = $event->getCommand();
//$arguments = $event->getArguments();
$this->data['commands'][] = array(
'command' => $event->getCommand(),
'arguments' => $event->getArguments(),
'url' => $event->getUrl(),
'cache' => $event->getUseCache(),
'content' => $event->getContent(),
'key' => $event->getKey(),
'statusCode' => $event->getStatusCode(),
'executiontime' => $event->getTiming()
);
} | php | public function onWSClientCommand(WSEventDispatcher\WSClientEvent $event)
{
//$command = $event->getCommand();
//$arguments = $event->getArguments();
$this->data['commands'][] = array(
'command' => $event->getCommand(),
'arguments' => $event->getArguments(),
'url' => $event->getUrl(),
'cache' => $event->getUseCache(),
'content' => $event->getContent(),
'key' => $event->getKey(),
'statusCode' => $event->getStatusCode(),
'executiontime' => $event->getTiming()
);
} | [
"public",
"function",
"onWSClientCommand",
"(",
"WSEventDispatcher",
"\\",
"WSClientEvent",
"$",
"event",
")",
"{",
"//$command = $event->getCommand();",
"//$arguments = $event->getArguments();",
"$",
"this",
"->",
"data",
"[",
"'commands'",
"]",
"[",
"]",
"=",
"array",... | Listen for wsclient command event
@param \M6Web\Bundle\WSClientBundle\EventDispatcher\WSClientEvent|object $event The event object | [
"Listen",
"for",
"wsclient",
"command",
"event"
] | 191df2ac2bbc9a427933a28e8f3b8d2f69f3918d | https://github.com/M6Web/WsClientBundle/blob/191df2ac2bbc9a427933a28e8f3b8d2f69f3918d/src/M6Web/Bundle/WSClientBundle/DataCollector/WSClientDataCollector.php#L38-L52 | train |
stubbles/stubbles-xml | src/main/php/serializer/XmlSerializer.php | XmlSerializer.serialize | public function serialize(
$value,
XmlStreamWriter $xmlWriter,
string $tagName = null,
string $elementTagName = null
): XmlStreamWriter {
switch (gettype($value)) {
case 'NULL':
$this->serializeNull($xmlWriter, $tagName);
break;
case 'boolean':
$this->serializeBool($value, $xmlWriter, $tagName);
break;
case 'string':
case 'integer':
case 'double':
$this->serializeScalarValue($value, $xmlWriter, $tagName);
break;
case 'array':
$this->serializeArray($value, $xmlWriter, $tagName, $elementTagName);
break;
case 'object':
if ($value instanceof \Traversable && !annotationsOf($value)->contain('XmlNonTraversable')) {
if (null === $tagName && $value instanceof \Traversable && annotationsOf($value)->contain('XmlTag')) {
$annotation = annotationsOf($value)->firstNamed('XmlTag');
$tagName = $annotation->getTagName();
$elementTagName = $annotation->getElementTagName();
}
$this->serializeArray($value, $xmlWriter, $tagName, $elementTagName);
} else {
$this->serializeObject($value, $xmlWriter, $tagName);
}
break;
default:
// nothing to do
}
return $xmlWriter;
} | php | public function serialize(
$value,
XmlStreamWriter $xmlWriter,
string $tagName = null,
string $elementTagName = null
): XmlStreamWriter {
switch (gettype($value)) {
case 'NULL':
$this->serializeNull($xmlWriter, $tagName);
break;
case 'boolean':
$this->serializeBool($value, $xmlWriter, $tagName);
break;
case 'string':
case 'integer':
case 'double':
$this->serializeScalarValue($value, $xmlWriter, $tagName);
break;
case 'array':
$this->serializeArray($value, $xmlWriter, $tagName, $elementTagName);
break;
case 'object':
if ($value instanceof \Traversable && !annotationsOf($value)->contain('XmlNonTraversable')) {
if (null === $tagName && $value instanceof \Traversable && annotationsOf($value)->contain('XmlTag')) {
$annotation = annotationsOf($value)->firstNamed('XmlTag');
$tagName = $annotation->getTagName();
$elementTagName = $annotation->getElementTagName();
}
$this->serializeArray($value, $xmlWriter, $tagName, $elementTagName);
} else {
$this->serializeObject($value, $xmlWriter, $tagName);
}
break;
default:
// nothing to do
}
return $xmlWriter;
} | [
"public",
"function",
"serialize",
"(",
"$",
"value",
",",
"XmlStreamWriter",
"$",
"xmlWriter",
",",
"string",
"$",
"tagName",
"=",
"null",
",",
"string",
"$",
"elementTagName",
"=",
"null",
")",
":",
"XmlStreamWriter",
"{",
"switch",
"(",
"gettype",
"(",
... | serialize any data structure to xml
@param mixed $value data to serialize
@param \stubbles\xml\XmlStreamWriter $xmlWriter xml writer to write serialized data into
@param string $tagName name of the surrounding xml tag
@param string $elementTagName recurring element tag name for lists
@return \stubbles\xml\XmlStreamWriter | [
"serialize",
"any",
"data",
"structure",
"to",
"xml"
] | 595bc5266190fd9661e9eee140cf2378f623e50a | https://github.com/stubbles/stubbles-xml/blob/595bc5266190fd9661e9eee140cf2378f623e50a/src/main/php/serializer/XmlSerializer.php#L47-L91 | train |
stubbles/stubbles-xml | src/main/php/serializer/XmlSerializer.php | XmlSerializer.serializeNull | public function serializeNull(XmlStreamWriter $xmlWriter, string $tagName = null): XmlStreamWriter
{
return $xmlWriter->writeStartElement(null === $tagName ? 'null' : $tagName)
->writeElement('null')
->writeEndElement();
} | php | public function serializeNull(XmlStreamWriter $xmlWriter, string $tagName = null): XmlStreamWriter
{
return $xmlWriter->writeStartElement(null === $tagName ? 'null' : $tagName)
->writeElement('null')
->writeEndElement();
} | [
"public",
"function",
"serializeNull",
"(",
"XmlStreamWriter",
"$",
"xmlWriter",
",",
"string",
"$",
"tagName",
"=",
"null",
")",
":",
"XmlStreamWriter",
"{",
"return",
"$",
"xmlWriter",
"->",
"writeStartElement",
"(",
"null",
"===",
"$",
"tagName",
"?",
"'nul... | serializes null to xml
@param \stubbles\xml\XmlStreamWriter $xmlWriter xml writer to write serialized value into
@param string $tagName name of the surrounding xml tag
@return \stubbles\xml\XmlStreamWriter
@since 1.6.0 | [
"serializes",
"null",
"to",
"xml"
] | 595bc5266190fd9661e9eee140cf2378f623e50a | https://github.com/stubbles/stubbles-xml/blob/595bc5266190fd9661e9eee140cf2378f623e50a/src/main/php/serializer/XmlSerializer.php#L101-L106 | train |
stubbles/stubbles-xml | src/main/php/serializer/XmlSerializer.php | XmlSerializer.serializeBool | public function serializeBool($value, XmlStreamWriter $xmlWriter, string $tagName = null): XmlStreamWriter
{
return $this->serializeScalarValue(
$this->convertBoolToString($value),
$xmlWriter,
null === $tagName ? 'boolean' : $tagName
);
} | php | public function serializeBool($value, XmlStreamWriter $xmlWriter, string $tagName = null): XmlStreamWriter
{
return $this->serializeScalarValue(
$this->convertBoolToString($value),
$xmlWriter,
null === $tagName ? 'boolean' : $tagName
);
} | [
"public",
"function",
"serializeBool",
"(",
"$",
"value",
",",
"XmlStreamWriter",
"$",
"xmlWriter",
",",
"string",
"$",
"tagName",
"=",
"null",
")",
":",
"XmlStreamWriter",
"{",
"return",
"$",
"this",
"->",
"serializeScalarValue",
"(",
"$",
"this",
"->",
"co... | serializes boolean value to xml
@param bool $value
@param \stubbles\xml\XmlStreamWriter $xmlWriter xml writer to write serialized value into
@param string $tagName name of the surrounding xml tag
@return \stubbles\xml\XmltreamWriter
@since 1.6.0 | [
"serializes",
"boolean",
"value",
"to",
"xml"
] | 595bc5266190fd9661e9eee140cf2378f623e50a | https://github.com/stubbles/stubbles-xml/blob/595bc5266190fd9661e9eee140cf2378f623e50a/src/main/php/serializer/XmlSerializer.php#L117-L124 | train |
stubbles/stubbles-xml | src/main/php/serializer/XmlSerializer.php | XmlSerializer.serializeFloat | public function serializeFloat($value, XmlStreamWriter $xmlWriter, string $tagName = null): XmlStreamWriter
{
return $this->serializeScalarValue($value, $xmlWriter, $tagName);
} | php | public function serializeFloat($value, XmlStreamWriter $xmlWriter, string $tagName = null): XmlStreamWriter
{
return $this->serializeScalarValue($value, $xmlWriter, $tagName);
} | [
"public",
"function",
"serializeFloat",
"(",
"$",
"value",
",",
"XmlStreamWriter",
"$",
"xmlWriter",
",",
"string",
"$",
"tagName",
"=",
"null",
")",
":",
"XmlStreamWriter",
"{",
"return",
"$",
"this",
"->",
"serializeScalarValue",
"(",
"$",
"value",
",",
"$... | serializes float value to xml
@param float $value
@param \stubbles\xml\XmlStreamWriter $xmlWriter xml writer to write serialized value into
@param string $tagName name of the surrounding xml tag
@return \stubbles\xml\XmlStreamWriter
@since 1.6.0 | [
"serializes",
"float",
"value",
"to",
"xml"
] | 595bc5266190fd9661e9eee140cf2378f623e50a | https://github.com/stubbles/stubbles-xml/blob/595bc5266190fd9661e9eee140cf2378f623e50a/src/main/php/serializer/XmlSerializer.php#L179-L182 | train |
stubbles/stubbles-xml | src/main/php/serializer/XmlSerializer.php | XmlSerializer.serializeScalarValue | protected function serializeScalarValue($value, XmlStreamWriter $xmlWriter, string $tagName = null): XmlStreamWriter
{
return $xmlWriter->writeStartElement(null === $tagName ? gettype($value) : $tagName)
->writeText(strval($value))
->writeEndElement();
} | php | protected function serializeScalarValue($value, XmlStreamWriter $xmlWriter, string $tagName = null): XmlStreamWriter
{
return $xmlWriter->writeStartElement(null === $tagName ? gettype($value) : $tagName)
->writeText(strval($value))
->writeEndElement();
} | [
"protected",
"function",
"serializeScalarValue",
"(",
"$",
"value",
",",
"XmlStreamWriter",
"$",
"xmlWriter",
",",
"string",
"$",
"tagName",
"=",
"null",
")",
":",
"XmlStreamWriter",
"{",
"return",
"$",
"xmlWriter",
"->",
"writeStartElement",
"(",
"null",
"===",... | serializes any scalar value to xml
@param scalar $value
@param \stubbles\xml\XmlStreamWriter $xmlWriter xml writer to write serialized value into
@param string $tagName name of the surrounding xml tag
@return \stubbles\xml\XmlStreamWriter | [
"serializes",
"any",
"scalar",
"value",
"to",
"xml"
] | 595bc5266190fd9661e9eee140cf2378f623e50a | https://github.com/stubbles/stubbles-xml/blob/595bc5266190fd9661e9eee140cf2378f623e50a/src/main/php/serializer/XmlSerializer.php#L192-L197 | train |
stubbles/stubbles-xml | src/main/php/serializer/XmlSerializer.php | XmlSerializer.serializeArray | public function serializeArray(
$array,
XmlStreamWriter $xmlWriter,
string $tagName = null,
string $elementTagName = null
): XmlStreamWriter {
if (null === $tagName) {
$tagName = 'array';
}
if (!empty($tagName)) {
$xmlWriter->writeStartElement($tagName);
}
foreach ($array as $key => $value) {
if (is_int($key)) {
$this->serialize($value, $xmlWriter, $elementTagName);
} else {
$this->serialize($value, $xmlWriter, $key);
}
}
if (!empty($tagName)) {
$xmlWriter->writeEndElement();
}
return $xmlWriter;
} | php | public function serializeArray(
$array,
XmlStreamWriter $xmlWriter,
string $tagName = null,
string $elementTagName = null
): XmlStreamWriter {
if (null === $tagName) {
$tagName = 'array';
}
if (!empty($tagName)) {
$xmlWriter->writeStartElement($tagName);
}
foreach ($array as $key => $value) {
if (is_int($key)) {
$this->serialize($value, $xmlWriter, $elementTagName);
} else {
$this->serialize($value, $xmlWriter, $key);
}
}
if (!empty($tagName)) {
$xmlWriter->writeEndElement();
}
return $xmlWriter;
} | [
"public",
"function",
"serializeArray",
"(",
"$",
"array",
",",
"XmlStreamWriter",
"$",
"xmlWriter",
",",
"string",
"$",
"tagName",
"=",
"null",
",",
"string",
"$",
"elementTagName",
"=",
"null",
")",
":",
"XmlStreamWriter",
"{",
"if",
"(",
"null",
"===",
... | serializes an array to xml
@param array $array array to serialize
@param \stubbles\xml\XmlStreamWriter $xmlWriter xml writer to write serialized array into
@param string $tagName name of the surrounding xml tag
@param string $elementTagName necurring element tag name for lists
@return \stubbles\xml\XmlStreamWriter
@since 1.6.0 | [
"serializes",
"an",
"array",
"to",
"xml"
] | 595bc5266190fd9661e9eee140cf2378f623e50a | https://github.com/stubbles/stubbles-xml/blob/595bc5266190fd9661e9eee140cf2378f623e50a/src/main/php/serializer/XmlSerializer.php#L209-L236 | train |
stubbles/stubbles-xml | src/main/php/serializer/XmlSerializer.php | XmlSerializer.serializeObject | public function serializeObject($object, XmlStreamWriter $xmlWriter, string $tagName = null): XmlStreamWriter
{
$this->serializerFor($object)->serialize($object, $this, $xmlWriter, $tagName);
return $xmlWriter;
} | php | public function serializeObject($object, XmlStreamWriter $xmlWriter, string $tagName = null): XmlStreamWriter
{
$this->serializerFor($object)->serialize($object, $this, $xmlWriter, $tagName);
return $xmlWriter;
} | [
"public",
"function",
"serializeObject",
"(",
"$",
"object",
",",
"XmlStreamWriter",
"$",
"xmlWriter",
",",
"string",
"$",
"tagName",
"=",
"null",
")",
":",
"XmlStreamWriter",
"{",
"$",
"this",
"->",
"serializerFor",
"(",
"$",
"object",
")",
"->",
"serialize... | serializes an object to xml
@param object $object object to serialize
@param \stubbles\xml\XmlStreamWriter $xmlWriter xml writer to write serialized object into
@param string $tagName name of the surrounding xml tag
@return \stubbles\xml\XmlStreamWriter
@since 1.6.0 | [
"serializes",
"an",
"object",
"to",
"xml"
] | 595bc5266190fd9661e9eee140cf2378f623e50a | https://github.com/stubbles/stubbles-xml/blob/595bc5266190fd9661e9eee140cf2378f623e50a/src/main/php/serializer/XmlSerializer.php#L247-L251 | train |
stubbles/stubbles-xml | src/main/php/serializer/XmlSerializer.php | XmlSerializer.serializerFor | protected function serializerFor($object): ObjectXmlSerializer
{
if (!annotationsOf($object)->contain('XmlSerializer')) {
return AnnotationBasedObjectXmlSerializer::fromObject($object);
}
return $this->injector->getInstance(
annotationsOf($object)
->firstNamed('XmlSerializer')
->getValue()
->getName()
);
} | php | protected function serializerFor($object): ObjectXmlSerializer
{
if (!annotationsOf($object)->contain('XmlSerializer')) {
return AnnotationBasedObjectXmlSerializer::fromObject($object);
}
return $this->injector->getInstance(
annotationsOf($object)
->firstNamed('XmlSerializer')
->getValue()
->getName()
);
} | [
"protected",
"function",
"serializerFor",
"(",
"$",
"object",
")",
":",
"ObjectXmlSerializer",
"{",
"if",
"(",
"!",
"annotationsOf",
"(",
"$",
"object",
")",
"->",
"contain",
"(",
"'XmlSerializer'",
")",
")",
"{",
"return",
"AnnotationBasedObjectXmlSerializer",
... | returns serializer for given object
@param object $object
@return \stubbles\xml\serializer\ObjectXmlSerializer | [
"returns",
"serializer",
"for",
"given",
"object"
] | 595bc5266190fd9661e9eee140cf2378f623e50a | https://github.com/stubbles/stubbles-xml/blob/595bc5266190fd9661e9eee140cf2378f623e50a/src/main/php/serializer/XmlSerializer.php#L259-L271 | train |
stubbles/stubbles-xml | src/main/php/xsl/XslProcessor.php | XslProcessor.onXmlFile | public function onXmlFile(string $xmlFile, bool $xinclude = true): self
{
$doc = new \DOMDocument();
if (false === @$doc->load($xmlFile)) {
throw new XslProcessorException(
'Can not read xml document file ' . $xmlFile
);
}
if (true === $xinclude) {
$doc->xinclude();
}
return $this->onDocument($doc);
} | php | public function onXmlFile(string $xmlFile, bool $xinclude = true): self
{
$doc = new \DOMDocument();
if (false === @$doc->load($xmlFile)) {
throw new XslProcessorException(
'Can not read xml document file ' . $xmlFile
);
}
if (true === $xinclude) {
$doc->xinclude();
}
return $this->onDocument($doc);
} | [
"public",
"function",
"onXmlFile",
"(",
"string",
"$",
"xmlFile",
",",
"bool",
"$",
"xinclude",
"=",
"true",
")",
":",
"self",
"{",
"$",
"doc",
"=",
"new",
"\\",
"DOMDocument",
"(",
")",
";",
"if",
"(",
"false",
"===",
"@",
"$",
"doc",
"->",
"load"... | sets the document to transform
@param string $xmlFile name of the xml file containing the document to transform
@param bool $xinclude whether to resolve xincludes or not, defaults to true
@return \stubbles\xml\xsl\XslProcessor
@throws \stubbles\xml\xsl\XslProcessorException | [
"sets",
"the",
"document",
"to",
"transform"
] | 595bc5266190fd9661e9eee140cf2378f623e50a | https://github.com/stubbles/stubbles-xml/blob/595bc5266190fd9661e9eee140cf2378f623e50a/src/main/php/xsl/XslProcessor.php#L135-L149 | train |
stubbles/stubbles-xml | src/main/php/xsl/XslProcessor.php | XslProcessor.applyStylesheet | public function applyStylesheet(\DOMDocument $stylesheet): self
{
$this->stylesheets[] = $stylesheet;
$this->xsltProcessor->importStylesheet($stylesheet);
return $this;
} | php | public function applyStylesheet(\DOMDocument $stylesheet): self
{
$this->stylesheets[] = $stylesheet;
$this->xsltProcessor->importStylesheet($stylesheet);
return $this;
} | [
"public",
"function",
"applyStylesheet",
"(",
"\\",
"DOMDocument",
"$",
"stylesheet",
")",
":",
"self",
"{",
"$",
"this",
"->",
"stylesheets",
"[",
"]",
"=",
"$",
"stylesheet",
";",
"$",
"this",
"->",
"xsltProcessor",
"->",
"importStylesheet",
"(",
"$",
"s... | add a stylesheet to use
@param \DOMDocument $stylesheet
@return \stubbles\xml\xsl\XslProcessor | [
"add",
"a",
"stylesheet",
"to",
"use"
] | 595bc5266190fd9661e9eee140cf2378f623e50a | https://github.com/stubbles/stubbles-xml/blob/595bc5266190fd9661e9eee140cf2378f623e50a/src/main/php/xsl/XslProcessor.php#L157-L162 | train |
stubbles/stubbles-xml | src/main/php/xsl/XslProcessor.php | XslProcessor.applyStylesheetFromFile | public function applyStylesheetFromFile(string $stylesheetFile): self
{
$stylesheet = new \DOMDocument();
if (false === @$stylesheet->load($stylesheetFile)) {
throw new XslProcessorException('Can not read stylesheet file ' . $stylesheetFile);
}
return $this->applyStylesheet($stylesheet);
} | php | public function applyStylesheetFromFile(string $stylesheetFile): self
{
$stylesheet = new \DOMDocument();
if (false === @$stylesheet->load($stylesheetFile)) {
throw new XslProcessorException('Can not read stylesheet file ' . $stylesheetFile);
}
return $this->applyStylesheet($stylesheet);
} | [
"public",
"function",
"applyStylesheetFromFile",
"(",
"string",
"$",
"stylesheetFile",
")",
":",
"self",
"{",
"$",
"stylesheet",
"=",
"new",
"\\",
"DOMDocument",
"(",
")",
";",
"if",
"(",
"false",
"===",
"@",
"$",
"stylesheet",
"->",
"load",
"(",
"$",
"s... | add a stylesheet to use from a file
@param string $stylesheetFile
@return \stubbles\xml\xsl\XslProcessor
@throws \stubbles\xml\xsl\XslProcessorException | [
"add",
"a",
"stylesheet",
"to",
"use",
"from",
"a",
"file"
] | 595bc5266190fd9661e9eee140cf2378f623e50a | https://github.com/stubbles/stubbles-xml/blob/595bc5266190fd9661e9eee140cf2378f623e50a/src/main/php/xsl/XslProcessor.php#L171-L179 | train |
stubbles/stubbles-xml | src/main/php/xsl/XslProcessor.php | XslProcessor.usingCallback | public function usingCallback(string $name, $instance): self
{
$this->xslCallbacks->addCallback($name, $instance);
return $this;
} | php | public function usingCallback(string $name, $instance): self
{
$this->xslCallbacks->addCallback($name, $instance);
return $this;
} | [
"public",
"function",
"usingCallback",
"(",
"string",
"$",
"name",
",",
"$",
"instance",
")",
":",
"self",
"{",
"$",
"this",
"->",
"xslCallbacks",
"->",
"addCallback",
"(",
"$",
"name",
",",
"$",
"instance",
")",
";",
"return",
"$",
"this",
";",
"}"
] | register an instance as callback
@param string $name name to register the callback under
@param object $instance the instance to register as callback
@return \stubbles\xml\xsl\XslProcessor | [
"register",
"an",
"instance",
"as",
"callback"
] | 595bc5266190fd9661e9eee140cf2378f623e50a | https://github.com/stubbles/stubbles-xml/blob/595bc5266190fd9661e9eee140cf2378f623e50a/src/main/php/xsl/XslProcessor.php#L198-L202 | train |
stubbles/stubbles-xml | src/main/php/xsl/XslProcessor.php | XslProcessor.registerCallbacks | protected function registerCallbacks()
{
self::$_callbacks = $this->xslCallbacks;
$this->xsltProcessor->registerPHPFunctions(get_class($this) . '::invokeCallback');
} | php | protected function registerCallbacks()
{
self::$_callbacks = $this->xslCallbacks;
$this->xsltProcessor->registerPHPFunctions(get_class($this) . '::invokeCallback');
} | [
"protected",
"function",
"registerCallbacks",
"(",
")",
"{",
"self",
"::",
"$",
"_callbacks",
"=",
"$",
"this",
"->",
"xslCallbacks",
";",
"$",
"this",
"->",
"xsltProcessor",
"->",
"registerPHPFunctions",
"(",
"get_class",
"(",
"$",
"this",
")",
".",
"'::inv... | register all callback instances
Workaround for limitation of XSLTProcessor::registerPHPFunctions()
callback instance in static variable to have data available when
php:function callback calls the static method as
XSLTProcessor::registerPHPFunctions() does not support non-static
methods nor anonymous functions directly. | [
"register",
"all",
"callback",
"instances"
] | 595bc5266190fd9661e9eee140cf2378f623e50a | https://github.com/stubbles/stubbles-xml/blob/595bc5266190fd9661e9eee140cf2378f623e50a/src/main/php/xsl/XslProcessor.php#L223-L227 | train |
stubbles/stubbles-xml | src/main/php/xsl/XslProcessor.php | XslProcessor.withParameter | public function withParameter(string $nameSpace, string $paramName, string $paramValue): self
{
if (false === $this->xsltProcessor->setParameter($nameSpace, $paramName, $paramValue)) {
throw new XslProcessorException(
'Could not set parameter ' . $nameSpace . ':' . $paramName
. ' with value ' . $paramValue
);
}
if (!isset($this->parameters[$nameSpace])) {
$this->parameters[$nameSpace] = [];
}
$this->parameters[$nameSpace][$paramName] = $paramValue;
return $this;
} | php | public function withParameter(string $nameSpace, string $paramName, string $paramValue): self
{
if (false === $this->xsltProcessor->setParameter($nameSpace, $paramName, $paramValue)) {
throw new XslProcessorException(
'Could not set parameter ' . $nameSpace . ':' . $paramName
. ' with value ' . $paramValue
);
}
if (!isset($this->parameters[$nameSpace])) {
$this->parameters[$nameSpace] = [];
}
$this->parameters[$nameSpace][$paramName] = $paramValue;
return $this;
} | [
"public",
"function",
"withParameter",
"(",
"string",
"$",
"nameSpace",
",",
"string",
"$",
"paramName",
",",
"string",
"$",
"paramValue",
")",
":",
"self",
"{",
"if",
"(",
"false",
"===",
"$",
"this",
"->",
"xsltProcessor",
"->",
"setParameter",
"(",
"$",... | sets a parameter for a namespace
@param string $nameSpace the namespace where the parameter is in
@param string $paramName the name of the parameter to set
@param string $paramValue the value to set the parameter to
@return \stubbles\xml\xsl\XslProcessor
@throws \stubbles\xml\xsl\XslProcessorException | [
"sets",
"a",
"parameter",
"for",
"a",
"namespace"
] | 595bc5266190fd9661e9eee140cf2378f623e50a | https://github.com/stubbles/stubbles-xml/blob/595bc5266190fd9661e9eee140cf2378f623e50a/src/main/php/xsl/XslProcessor.php#L259-L274 | train |
stubbles/stubbles-xml | src/main/php/xsl/XslProcessor.php | XslProcessor.withParameters | public function withParameters(string $nameSpace, array $params): self
{
if (false === $this->xsltProcessor->setParameter($nameSpace, $params)) {
throw new XslProcessorException('Could not set parameters in ' . $nameSpace);
}
if (!isset($this->parameters[$nameSpace])) {
$this->parameters[$nameSpace] = [];
}
$this->parameters[$nameSpace] = array_merge($this->parameters[$nameSpace], $params);
return $this;
} | php | public function withParameters(string $nameSpace, array $params): self
{
if (false === $this->xsltProcessor->setParameter($nameSpace, $params)) {
throw new XslProcessorException('Could not set parameters in ' . $nameSpace);
}
if (!isset($this->parameters[$nameSpace])) {
$this->parameters[$nameSpace] = [];
}
$this->parameters[$nameSpace] = array_merge($this->parameters[$nameSpace], $params);
return $this;
} | [
"public",
"function",
"withParameters",
"(",
"string",
"$",
"nameSpace",
",",
"array",
"$",
"params",
")",
":",
"self",
"{",
"if",
"(",
"false",
"===",
"$",
"this",
"->",
"xsltProcessor",
"->",
"setParameter",
"(",
"$",
"nameSpace",
",",
"$",
"params",
"... | set a list of parameters for the given namespace
@param string $nameSpace the namespace where the parameters are in
@param array $params the list of parameters to set: name => value
@return \stubbles\xml\xsl\XslProcessor
@throws \stubbles\xml\xsl\XslProcessorException | [
"set",
"a",
"list",
"of",
"parameters",
"for",
"the",
"given",
"namespace"
] | 595bc5266190fd9661e9eee140cf2378f623e50a | https://github.com/stubbles/stubbles-xml/blob/595bc5266190fd9661e9eee140cf2378f623e50a/src/main/php/xsl/XslProcessor.php#L284-L296 | train |
stubbles/stubbles-xml | src/main/php/xsl/XslProcessor.php | XslProcessor.toDoc | public function toDoc(): \DOMDocument
{
if (null === $this->document) {
throw new XslProcessorException(
'Can not transform, set document or xml file to transform first'
);
}
$this->registerCallbacks();
$result = $this->xsltProcessor->transformToDoc($this->document);
if (false === $result) {
throw new XslProcessorException($this->createMessage());
}
return $result;
} | php | public function toDoc(): \DOMDocument
{
if (null === $this->document) {
throw new XslProcessorException(
'Can not transform, set document or xml file to transform first'
);
}
$this->registerCallbacks();
$result = $this->xsltProcessor->transformToDoc($this->document);
if (false === $result) {
throw new XslProcessorException($this->createMessage());
}
return $result;
} | [
"public",
"function",
"toDoc",
"(",
")",
":",
"\\",
"DOMDocument",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"document",
")",
"{",
"throw",
"new",
"XslProcessorException",
"(",
"'Can not transform, set document or xml file to transform first'",
")",
";",
"... | transoforms the document into another DOMDocument
@return \DOMDocument
@throws \stubbles\xml\xsl\XslProcessorException | [
"transoforms",
"the",
"document",
"into",
"another",
"DOMDocument"
] | 595bc5266190fd9661e9eee140cf2378f623e50a | https://github.com/stubbles/stubbles-xml/blob/595bc5266190fd9661e9eee140cf2378f623e50a/src/main/php/xsl/XslProcessor.php#L304-L319 | train |
stubbles/stubbles-xml | src/main/php/xsl/XslProcessor.php | XslProcessor.toUri | public function toUri(string $uri): int
{
if (null === $this->document) {
throw new XslProcessorException(
'Can not transform, set document or xml file to transform first'
);
}
$this->registerCallbacks();
$bytes = $this->xsltProcessor->transformToURI($this->document, $uri);
if (false === $bytes) {
throw new XslProcessorException($this->createMessage());
}
return $bytes;
} | php | public function toUri(string $uri): int
{
if (null === $this->document) {
throw new XslProcessorException(
'Can not transform, set document or xml file to transform first'
);
}
$this->registerCallbacks();
$bytes = $this->xsltProcessor->transformToURI($this->document, $uri);
if (false === $bytes) {
throw new XslProcessorException($this->createMessage());
}
return $bytes;
} | [
"public",
"function",
"toUri",
"(",
"string",
"$",
"uri",
")",
":",
"int",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"document",
")",
"{",
"throw",
"new",
"XslProcessorException",
"(",
"'Can not transform, set document or xml file to transform first'",
")"... | transforms the document and saves it to the given uri, returns the
amount of bytes written
@param string $uri
@return int
@throws \stubbles\xml\xsl\XslProcessorException | [
"transforms",
"the",
"document",
"and",
"saves",
"it",
"to",
"the",
"given",
"uri",
"returns",
"the",
"amount",
"of",
"bytes",
"written"
] | 595bc5266190fd9661e9eee140cf2378f623e50a | https://github.com/stubbles/stubbles-xml/blob/595bc5266190fd9661e9eee140cf2378f623e50a/src/main/php/xsl/XslProcessor.php#L329-L344 | train |
stubbles/stubbles-xml | src/main/php/xsl/XslProcessor.php | XslProcessor.toXml | public function toXml(): string
{
if (null === $this->document) {
throw new XslProcessorException(
'Can not transform, set document or xml file to transform first'
);
}
$this->registerCallbacks();
$result = $this->xsltProcessor->transformToXML($this->document);
if (false === $result) {
throw new XslProcessorException($this->createMessage());
}
return $result;
} | php | public function toXml(): string
{
if (null === $this->document) {
throw new XslProcessorException(
'Can not transform, set document or xml file to transform first'
);
}
$this->registerCallbacks();
$result = $this->xsltProcessor->transformToXML($this->document);
if (false === $result) {
throw new XslProcessorException($this->createMessage());
}
return $result;
} | [
"public",
"function",
"toXml",
"(",
")",
":",
"string",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"document",
")",
"{",
"throw",
"new",
"XslProcessorException",
"(",
"'Can not transform, set document or xml file to transform first'",
")",
";",
"}",
"$",
... | transforms the document and returns the result as string
@return string
@throws \stubbles\xml\xsl\XslProcessorException | [
"transforms",
"the",
"document",
"and",
"returns",
"the",
"result",
"as",
"string"
] | 595bc5266190fd9661e9eee140cf2378f623e50a | https://github.com/stubbles/stubbles-xml/blob/595bc5266190fd9661e9eee140cf2378f623e50a/src/main/php/xsl/XslProcessor.php#L352-L367 | train |
stubbles/stubbles-xml | src/main/php/xsl/XslProcessor.php | XslProcessor.createMessage | private function createMessage(): string
{
$message = '';
foreach (libxml_get_errors() as $error) {
$message .= trim($error->message) . (($error->file) ? (' in file ' . $error->file) : ('')) . ' on line ' . $error->line . ' in column ' . $error->column . "\n";
}
libxml_clear_errors();
if (strlen($message) === 0) {
return 'Transformation failed: unknown error.';
}
return $message;
} | php | private function createMessage(): string
{
$message = '';
foreach (libxml_get_errors() as $error) {
$message .= trim($error->message) . (($error->file) ? (' in file ' . $error->file) : ('')) . ' on line ' . $error->line . ' in column ' . $error->column . "\n";
}
libxml_clear_errors();
if (strlen($message) === 0) {
return 'Transformation failed: unknown error.';
}
return $message;
} | [
"private",
"function",
"createMessage",
"(",
")",
":",
"string",
"{",
"$",
"message",
"=",
"''",
";",
"foreach",
"(",
"libxml_get_errors",
"(",
")",
"as",
"$",
"error",
")",
"{",
"$",
"message",
".=",
"trim",
"(",
"$",
"error",
"->",
"message",
")",
... | creates a message frim the last libxml error
@return string | [
"creates",
"a",
"message",
"frim",
"the",
"last",
"libxml",
"error"
] | 595bc5266190fd9661e9eee140cf2378f623e50a | https://github.com/stubbles/stubbles-xml/blob/595bc5266190fd9661e9eee140cf2378f623e50a/src/main/php/xsl/XslProcessor.php#L374-L387 | train |
stubbles/stubbles-xml | src/main/php/XmlStreamWriterProvider.php | XmlStreamWriterProvider.createStreamWriter | protected function createStreamWriter(string $xmlExtension): XmlStreamWriter
{
$className = $this->types[$xmlExtension];
return new $className($this->version, $this->encoding);
} | php | protected function createStreamWriter(string $xmlExtension): XmlStreamWriter
{
$className = $this->types[$xmlExtension];
return new $className($this->version, $this->encoding);
} | [
"protected",
"function",
"createStreamWriter",
"(",
"string",
"$",
"xmlExtension",
")",
":",
"XmlStreamWriter",
"{",
"$",
"className",
"=",
"$",
"this",
"->",
"types",
"[",
"$",
"xmlExtension",
"]",
";",
"return",
"new",
"$",
"className",
"(",
"$",
"this",
... | creates a xml stream writer of the given type
@param string $xmlExtension concrete type to create
@return \stubbles\xml\XmlStreamWriter | [
"creates",
"a",
"xml",
"stream",
"writer",
"of",
"the",
"given",
"type"
] | 595bc5266190fd9661e9eee140cf2378f623e50a | https://github.com/stubbles/stubbles-xml/blob/595bc5266190fd9661e9eee140cf2378f623e50a/src/main/php/XmlStreamWriterProvider.php#L92-L96 | train |
stubbles/stubbles-xml | src/main/php/XmlStreamWriterProvider.php | XmlStreamWriterProvider.createAsAvailable | protected function createAsAvailable(): XmlStreamWriter
{
foreach (array_keys($this->types) as $xmlExtension) {
if (extension_loaded($xmlExtension)) {
return $this->createStreamWriter($xmlExtension);
}
}
throw new XmlException(
'No supported xml extension available, can not create a xml stream writer!'
);
} | php | protected function createAsAvailable(): XmlStreamWriter
{
foreach (array_keys($this->types) as $xmlExtension) {
if (extension_loaded($xmlExtension)) {
return $this->createStreamWriter($xmlExtension);
}
}
throw new XmlException(
'No supported xml extension available, can not create a xml stream writer!'
);
} | [
"protected",
"function",
"createAsAvailable",
"(",
")",
":",
"XmlStreamWriter",
"{",
"foreach",
"(",
"array_keys",
"(",
"$",
"this",
"->",
"types",
")",
"as",
"$",
"xmlExtension",
")",
"{",
"if",
"(",
"extension_loaded",
"(",
"$",
"xmlExtension",
")",
")",
... | creates a xml stream writer depending on available xml extensions
@return \stubbles\xml\XmlStreamWriter
@throws \stubbles\xml\XMLException | [
"creates",
"a",
"xml",
"stream",
"writer",
"depending",
"on",
"available",
"xml",
"extensions"
] | 595bc5266190fd9661e9eee140cf2378f623e50a | https://github.com/stubbles/stubbles-xml/blob/595bc5266190fd9661e9eee140cf2378f623e50a/src/main/php/XmlStreamWriterProvider.php#L104-L115 | train |
krystal-framework/krystal.framework | src/Krystal/Db/Sql/Db.php | Db.asManyToMany | public function asManyToMany($alias, $junction, $column, $table, $pk, $columns = '*')
{
$this->relationProcessor->queue(__FUNCTION__, func_get_args());
return $this;
} | php | public function asManyToMany($alias, $junction, $column, $table, $pk, $columns = '*')
{
$this->relationProcessor->queue(__FUNCTION__, func_get_args());
return $this;
} | [
"public",
"function",
"asManyToMany",
"(",
"$",
"alias",
",",
"$",
"junction",
",",
"$",
"column",
",",
"$",
"table",
",",
"$",
"pk",
",",
"$",
"columns",
"=",
"'*'",
")",
"{",
"$",
"this",
"->",
"relationProcessor",
"->",
"queue",
"(",
"__FUNCTION__",... | Appends many-to-many grabber to the queue
@param string $alias Alias name
@param string $junction Junction table name
@param string $column Column name from junction table to be selected
@param string $table Slave table name table
@param string $pk PK column name in slave table
@param mixed $columns Columns to be selected in slave table
@return \Krystal\Db\Sql\Db | [
"Appends",
"many",
"-",
"to",
"-",
"many",
"grabber",
"to",
"the",
"queue"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/Db.php#L108-L112 | train |
krystal-framework/krystal.framework | src/Krystal/Db/Sql/Db.php | Db.asOneToOne | public function asOneToOne($column, $alias, $table, $link)
{
$this->relationProcessor->queue(__FUNCTION__, func_get_args());
return $this;
} | php | public function asOneToOne($column, $alias, $table, $link)
{
$this->relationProcessor->queue(__FUNCTION__, func_get_args());
return $this;
} | [
"public",
"function",
"asOneToOne",
"(",
"$",
"column",
",",
"$",
"alias",
",",
"$",
"table",
",",
"$",
"link",
")",
"{",
"$",
"this",
"->",
"relationProcessor",
"->",
"queue",
"(",
"__FUNCTION__",
",",
"func_get_args",
"(",
")",
")",
";",
"return",
"$... | Appends one-to-one grabber to the queue
@param string $column Column name from the master table to be replaced by alias
@param string $alias Alias name for the column name being replaced
@param string $table Slave table name
@param string $link Linking column name from slave table
@return \Krystal\Db\Sql\Db | [
"Appends",
"one",
"-",
"to",
"-",
"one",
"grabber",
"to",
"the",
"queue"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/Db.php#L123-L127 | train |
krystal-framework/krystal.framework | src/Krystal/Db/Sql/Db.php | Db.asOneToMany | public function asOneToMany($table, $pk, $alias)
{
$this->relationProcessor->queue(__FUNCTION__, func_get_args());
return $this;
} | php | public function asOneToMany($table, $pk, $alias)
{
$this->relationProcessor->queue(__FUNCTION__, func_get_args());
return $this;
} | [
"public",
"function",
"asOneToMany",
"(",
"$",
"table",
",",
"$",
"pk",
",",
"$",
"alias",
")",
"{",
"$",
"this",
"->",
"relationProcessor",
"->",
"queue",
"(",
"__FUNCTION__",
",",
"func_get_args",
"(",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Appends one-to-many grabber to the queue
@param string $table Slave table name
@param string $pk Column name which is primary key
@param string $alias Alias for result-set
@return \Krystal\Db\Sql\Db | [
"Appends",
"one",
"-",
"to",
"-",
"many",
"grabber",
"to",
"the",
"queue"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/Db.php#L137-L141 | train |
krystal-framework/krystal.framework | src/Krystal/Db/Sql/Db.php | Db.asData | private function asData(array $data)
{
foreach ($data as $key => $value) {
if ($value instanceof RawSqlFragmentInterface) {
$data[$key] = $value->getFragment();
} elseif ($value instanceof RawBindingInterface) {
$data[$key] = $value->getTarget();
} else {
$placeholder = $this->getUniqPlaceholder();
$data[$key] = $placeholder;
$this->bind($placeholder, $value);
}
}
return $data;
} | php | private function asData(array $data)
{
foreach ($data as $key => $value) {
if ($value instanceof RawSqlFragmentInterface) {
$data[$key] = $value->getFragment();
} elseif ($value instanceof RawBindingInterface) {
$data[$key] = $value->getTarget();
} else {
$placeholder = $this->getUniqPlaceholder();
$data[$key] = $placeholder;
$this->bind($placeholder, $value);
}
}
return $data;
} | [
"private",
"function",
"asData",
"(",
"array",
"$",
"data",
")",
"{",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"instanceof",
"RawSqlFragmentInterface",
")",
"{",
"$",
"data",
"[",
"$",
"key... | Prepared raw data before a command is executed
@param array $data
@return array | [
"Prepared",
"raw",
"data",
"before",
"a",
"command",
"is",
"executed"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/Db.php#L251-L267 | train |
krystal-framework/krystal.framework | src/Krystal/Db/Sql/Db.php | Db.createUniqPlaceholder | private function createUniqPlaceholder($key)
{
if ($key instanceof RawSqlFragment) {
$placeholder = $key->getFragment();
} else if ($key instanceof RawBindingInterface) {
$placeholder = $key->getTarget();
} else {
// Create unique placeholder
$placeholder = $this->getUniqPlaceholder();
// Bind to the global stack
$this->bind($placeholder, $key);
}
return $placeholder;
} | php | private function createUniqPlaceholder($key)
{
if ($key instanceof RawSqlFragment) {
$placeholder = $key->getFragment();
} else if ($key instanceof RawBindingInterface) {
$placeholder = $key->getTarget();
} else {
// Create unique placeholder
$placeholder = $this->getUniqPlaceholder();
// Bind to the global stack
$this->bind($placeholder, $key);
}
return $placeholder;
} | [
"private",
"function",
"createUniqPlaceholder",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"$",
"key",
"instanceof",
"RawSqlFragment",
")",
"{",
"$",
"placeholder",
"=",
"$",
"key",
"->",
"getFragment",
"(",
")",
";",
"}",
"else",
"if",
"(",
"$",
"key",
"in... | Creates unique placeholder
@param string $key
@return string | [
"Creates",
"unique",
"placeholder"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/Db.php#L275-L290 | train |
krystal-framework/krystal.framework | src/Krystal/Db/Sql/Db.php | Db.getCount | private function getCount($column)
{
$alias = 'count';
// Save initial state
$original = clone $this->queryBuilder;
$bindings = $this->bindings;
// Set guessed query and execute it
$this->queryBuilder->setQueryString($this->queryBuilder->guessCountQuery($column, $alias));
$count = $this->query($alias);
// And finally restore initial state
$this->queryBuilder = $original;
$this->bindings = $bindings;
return $count;
} | php | private function getCount($column)
{
$alias = 'count';
// Save initial state
$original = clone $this->queryBuilder;
$bindings = $this->bindings;
// Set guessed query and execute it
$this->queryBuilder->setQueryString($this->queryBuilder->guessCountQuery($column, $alias));
$count = $this->query($alias);
// And finally restore initial state
$this->queryBuilder = $original;
$this->bindings = $bindings;
return $count;
} | [
"private",
"function",
"getCount",
"(",
"$",
"column",
")",
"{",
"$",
"alias",
"=",
"'count'",
";",
"// Save initial state",
"$",
"original",
"=",
"clone",
"$",
"this",
"->",
"queryBuilder",
";",
"$",
"bindings",
"=",
"$",
"this",
"->",
"bindings",
";",
... | Returns count for pagination
This is the implementation of Memento pattern
@param string $column Column to be selected when counting
@return integer | [
"Returns",
"count",
"for",
"pagination",
"This",
"is",
"the",
"implementation",
"of",
"Memento",
"pattern"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/Db.php#L321-L338 | train |
krystal-framework/krystal.framework | src/Krystal/Db/Sql/Db.php | Db.fetchAllTables | public function fetchAllTables()
{
$tables = array();
$result = $this->pdo->query('SHOW TABLES')->fetchAll();
foreach ($result as $index => $array) {
// Extract a value - we don't care about a key
$data = array_values($array);
// Its ready not, just append it
$tables[] = $data[0];
}
return $tables;
} | php | public function fetchAllTables()
{
$tables = array();
$result = $this->pdo->query('SHOW TABLES')->fetchAll();
foreach ($result as $index => $array) {
// Extract a value - we don't care about a key
$data = array_values($array);
// Its ready not, just append it
$tables[] = $data[0];
}
return $tables;
} | [
"public",
"function",
"fetchAllTables",
"(",
")",
"{",
"$",
"tables",
"=",
"array",
"(",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"pdo",
"->",
"query",
"(",
"'SHOW TABLES'",
")",
"->",
"fetchAll",
"(",
")",
";",
"foreach",
"(",
"$",
"result",... | Fetch all tables
@return array | [
"Fetch",
"all",
"tables"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/Db.php#L345-L358 | train |
krystal-framework/krystal.framework | src/Krystal/Db/Sql/Db.php | Db.dump | public function dump(array $tables = array())
{
$result = null;
if (empty($tables)) {
$tables = $this->fetchAllTables();
}
// Building logic
foreach ($tables as $table) {
// Main SELECT query
$select = $this->queryBuilder->clear()
->select('*')
->from($table)
->getQueryString();
$stmt = $this->pdo->query($select);
$fieldCount = $stmt->columnCount();
// Append additional drop state
$result .= $this->queryBuilder->clear()
->dropTable($table)
->getQueryString();;
// Show how this table was created
$createResult = $this->pdo->query(sprintf('SHOW CREATE TABLE %s', $table))->fetch();
$result .= "\n\n" . $createResult['Create Table'] . ";\n\n";
// Start main loop
for ($i = 0; $i < $fieldCount; $i++) {
// Loop to generate INSERT statements
while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
$values = array();
// Extra values and push them to $values array
for ($j = 0; $j < $fieldCount; $j++) {
// We need to ensure all quotes are properly escaped
$row[$j] = addslashes($row[$j]);
// Ensure its correctly escaped
$row[$j] = str_replace("\n", "\\n", $row[$j]);
$row[$j] = sprintf('"%s"', $row[$j]);
// Push the value
array_push($values, $row[$j]);
}
// Generate short INSERT statement
$result .= $this->queryBuilder->clear()
->insertShort($table, $values)
->getQueryString();
$result .= "\n";
// Free memory for next iteration
unset($vals);
}
}
$result .= "\n";
}
return $result;
} | php | public function dump(array $tables = array())
{
$result = null;
if (empty($tables)) {
$tables = $this->fetchAllTables();
}
// Building logic
foreach ($tables as $table) {
// Main SELECT query
$select = $this->queryBuilder->clear()
->select('*')
->from($table)
->getQueryString();
$stmt = $this->pdo->query($select);
$fieldCount = $stmt->columnCount();
// Append additional drop state
$result .= $this->queryBuilder->clear()
->dropTable($table)
->getQueryString();;
// Show how this table was created
$createResult = $this->pdo->query(sprintf('SHOW CREATE TABLE %s', $table))->fetch();
$result .= "\n\n" . $createResult['Create Table'] . ";\n\n";
// Start main loop
for ($i = 0; $i < $fieldCount; $i++) {
// Loop to generate INSERT statements
while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
$values = array();
// Extra values and push them to $values array
for ($j = 0; $j < $fieldCount; $j++) {
// We need to ensure all quotes are properly escaped
$row[$j] = addslashes($row[$j]);
// Ensure its correctly escaped
$row[$j] = str_replace("\n", "\\n", $row[$j]);
$row[$j] = sprintf('"%s"', $row[$j]);
// Push the value
array_push($values, $row[$j]);
}
// Generate short INSERT statement
$result .= $this->queryBuilder->clear()
->insertShort($table, $values)
->getQueryString();
$result .= "\n";
// Free memory for next iteration
unset($vals);
}
}
$result .= "\n";
}
return $result;
} | [
"public",
"function",
"dump",
"(",
"array",
"$",
"tables",
"=",
"array",
"(",
")",
")",
"{",
"$",
"result",
"=",
"null",
";",
"if",
"(",
"empty",
"(",
"$",
"tables",
")",
")",
"{",
"$",
"tables",
"=",
"$",
"this",
"->",
"fetchAllTables",
"(",
")"... | Dump tables into SQL string
@param array $tables If empty current tables will be taken into account
@return string | [
"Dump",
"tables",
"into",
"SQL",
"string"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/Db.php#L366-L429 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.