repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
39
1.84M
func_code_tokens
sequencelengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
sequencelengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
yidas/codeigniter-model
src/Model.php
Model._relationship
protected function _relationship($modelName, $relationship, $foreignKey=null, $localKey=null) { /** * PSR-4 support check * * @see https://github.com/yidas/codeigniter-psr4-autoload */ if (strpos($modelName, "\\") !== false ) { $model = new $modelName; } else { // Original CodeIgniter 3 model loader get_instance()->load->model($modelName); $model = $this->$modelName; } $libClass = __CLASS__; // Check if is using same library if (!is_subclass_of($model, $libClass)) { throw new Exception("Model `{$modelName}` does not extend {$libClass}", 500); } // Keys $foreignKey = ($foreignKey) ? $foreignKey : $this->primaryKey; $localKey = ($localKey) ? $localKey : $this->primaryKey; $query = $model->find() ->where($foreignKey, $this->$localKey); // Inject Model name into query builder for ORM relationships $query->modelName = $modelName; // Inject relationship type into query builder for ORM relationships $query->relationship = $relationship; return $query; }
php
protected function _relationship($modelName, $relationship, $foreignKey=null, $localKey=null) { if (strpos($modelName, "\\") !== false ) { $model = new $modelName; } else { get_instance()->load->model($modelName); $model = $this->$modelName; } $libClass = __CLASS__; if (!is_subclass_of($model, $libClass)) { throw new Exception("Model `{$modelName}` does not extend {$libClass}", 500); } $foreignKey = ($foreignKey) ? $foreignKey : $this->primaryKey; $localKey = ($localKey) ? $localKey : $this->primaryKey; $query = $model->find() ->where($foreignKey, $this->$localKey); $query->modelName = $modelName; $query->relationship = $relationship; return $query; }
[ "protected", "function", "_relationship", "(", "$", "modelName", ",", "$", "relationship", ",", "$", "foreignKey", "=", "null", ",", "$", "localKey", "=", "null", ")", "{", "/**\n * PSR-4 support check\n * \n * @see https://github.com/yidas/codeigniter-psr4-autoload\n */", "if", "(", "strpos", "(", "$", "modelName", ",", "\"\\\\\"", ")", "!==", "false", ")", "{", "$", "model", "=", "new", "$", "modelName", ";", "}", "else", "{", "// Original CodeIgniter 3 model loader", "get_instance", "(", ")", "->", "load", "->", "model", "(", "$", "modelName", ")", ";", "$", "model", "=", "$", "this", "->", "$", "modelName", ";", "}", "$", "libClass", "=", "__CLASS__", ";", "// Check if is using same library", "if", "(", "!", "is_subclass_of", "(", "$", "model", ",", "$", "libClass", ")", ")", "{", "throw", "new", "Exception", "(", "\"Model `{$modelName}` does not extend {$libClass}\"", ",", "500", ")", ";", "}", "// Keys", "$", "foreignKey", "=", "(", "$", "foreignKey", ")", "?", "$", "foreignKey", ":", "$", "this", "->", "primaryKey", ";", "$", "localKey", "=", "(", "$", "localKey", ")", "?", "$", "localKey", ":", "$", "this", "->", "primaryKey", ";", "$", "query", "=", "$", "model", "->", "find", "(", ")", "->", "where", "(", "$", "foreignKey", ",", "$", "this", "->", "$", "localKey", ")", ";", "// Inject Model name into query builder for ORM relationships", "$", "query", "->", "modelName", "=", "$", "modelName", ";", "// Inject relationship type into query builder for ORM relationships", "$", "query", "->", "relationship", "=", "$", "relationship", ";", "return", "$", "query", ";", "}" ]
Base relationship. @param string $modelName The model class name of the related record @param string $relationship @param string $foreignKey @param string $localKey @return object CI_DB_query_builder
[ "Base", "relationship", "." ]
train
https://github.com/yidas/codeigniter-model/blob/14cd273bb0620dc0e2993fe924ee37f00301992f/src/Model.php#L1169-L1206
yidas/codeigniter-model
src/Model.php
Model.indexBy
public static function indexBy(Array &$array, $key=null, $obj2Array=false) { // Use model instance's primary key while no given key $key = ($key) ?: (new static())->primaryKey; $tmp = []; foreach ($array as $row) { // Array & Object types support if (is_object($row) && isset($row->$key)) { $tmp[$row->$key] = ($obj2Array) ? (array)$row : $row; } elseif (is_array($row) && isset($row[$key])) { $tmp[$row[$key]] = $row; } } return $array = $tmp; }
php
public static function indexBy(Array &$array, $key=null, $obj2Array=false) { $key = ($key) ?: (new static())->primaryKey; $tmp = []; foreach ($array as $row) { if (is_object($row) && isset($row->$key)) { $tmp[$row->$key] = ($obj2Array) ? (array)$row : $row; } elseif (is_array($row) && isset($row[$key])) { $tmp[$row[$key]] = $row; } } return $array = $tmp; }
[ "public", "static", "function", "indexBy", "(", "Array", "&", "$", "array", ",", "$", "key", "=", "null", ",", "$", "obj2Array", "=", "false", ")", "{", "// Use model instance's primary key while no given key", "$", "key", "=", "(", "$", "key", ")", "?", ":", "(", "new", "static", "(", ")", ")", "->", "primaryKey", ";", "$", "tmp", "=", "[", "]", ";", "foreach", "(", "$", "array", "as", "$", "row", ")", "{", "// Array & Object types support ", "if", "(", "is_object", "(", "$", "row", ")", "&&", "isset", "(", "$", "row", "->", "$", "key", ")", ")", "{", "$", "tmp", "[", "$", "row", "->", "$", "key", "]", "=", "(", "$", "obj2Array", ")", "?", "(", "array", ")", "$", "row", ":", "$", "row", ";", "}", "elseif", "(", "is_array", "(", "$", "row", ")", "&&", "isset", "(", "$", "row", "[", "$", "key", "]", ")", ")", "{", "$", "tmp", "[", "$", "row", "[", "$", "key", "]", "]", "=", "$", "row", ";", "}", "}", "return", "$", "array", "=", "$", "tmp", ";", "}" ]
Index by Key @param array $array Array data for handling @param string $key Array key for index key @param bool $obj2Array Object converts to array if is object @return array Result with indexBy Key @example $records = $this->Model->findAll(); $this->Model->indexBy($records, 'sn');
[ "Index", "by", "Key" ]
train
https://github.com/yidas/codeigniter-model/blob/14cd273bb0620dc0e2993fe924ee37f00301992f/src/Model.php#L1230-L1248
yidas/codeigniter-model
src/Model.php
Model.htmlEncode
public static function htmlEncode($content, $doubleEncode = true) { $ci = & get_instance(); return htmlspecialchars($content, ENT_QUOTES | ENT_SUBSTITUTE, $ci->config->item('charset') ? $ci->config->item('charset') : 'UTF-8', $doubleEncode); }
php
public static function htmlEncode($content, $doubleEncode = true) { $ci = & get_instance(); return htmlspecialchars($content, ENT_QUOTES | ENT_SUBSTITUTE, $ci->config->item('charset') ? $ci->config->item('charset') : 'UTF-8', $doubleEncode); }
[ "public", "static", "function", "htmlEncode", "(", "$", "content", ",", "$", "doubleEncode", "=", "true", ")", "{", "$", "ci", "=", "&", "get_instance", "(", ")", ";", "return", "htmlspecialchars", "(", "$", "content", ",", "ENT_QUOTES", "|", "ENT_SUBSTITUTE", ",", "$", "ci", "->", "config", "->", "item", "(", "'charset'", ")", "?", "$", "ci", "->", "config", "->", "item", "(", "'charset'", ")", ":", "'UTF-8'", ",", "$", "doubleEncode", ")", ";", "}" ]
Encodes special characters into HTML entities. The [[$this->config->item('charset')]] will be used for encoding. @param string $content the content to be encoded @param bool $doubleEncode whether to encode HTML entities in `$content`. If false, HTML entities in `$content` will not be further encoded. @return string the encoded content @see http://www.php.net/manual/en/function.htmlspecialchars.php @see https://www.yiiframework.com/doc/api/2.0/yii-helpers-basehtml#encode()-detail
[ "Encodes", "special", "characters", "into", "HTML", "entities", "." ]
train
https://github.com/yidas/codeigniter-model/blob/14cd273bb0620dc0e2993fe924ee37f00301992f/src/Model.php#L1263-L1268
yidas/codeigniter-model
src/Model.php
Model._attrEventBeforeInsert
protected function _attrEventBeforeInsert(&$attributes) { $this->_formatDate(static::CREATED_AT, $attributes); // Trigger UPDATED_AT if ($this->createdWithUpdated) { $this->_formatDate(static::UPDATED_AT, $attributes); } return $attributes; }
php
protected function _attrEventBeforeInsert(&$attributes) { $this->_formatDate(static::CREATED_AT, $attributes); if ($this->createdWithUpdated) { $this->_formatDate(static::UPDATED_AT, $attributes); } return $attributes; }
[ "protected", "function", "_attrEventBeforeInsert", "(", "&", "$", "attributes", ")", "{", "$", "this", "->", "_formatDate", "(", "static", "::", "CREATED_AT", ",", "$", "attributes", ")", ";", "// Trigger UPDATED_AT", "if", "(", "$", "this", "->", "createdWithUpdated", ")", "{", "$", "this", "->", "_formatDate", "(", "static", "::", "UPDATED_AT", ",", "$", "attributes", ")", ";", "}", "return", "$", "attributes", ";", "}" ]
Attributes handle function for each Insert @param array $attributes @return array Addon $attributes of pointer
[ "Attributes", "handle", "function", "for", "each", "Insert" ]
train
https://github.com/yidas/codeigniter-model/blob/14cd273bb0620dc0e2993fe924ee37f00301992f/src/Model.php#L1304-L1315
yidas/codeigniter-model
src/Model.php
Model._findByCondition
protected function _findByCondition($condition=null) { // Reset Query if condition existed if ($condition !== null) { $this->_dbr->reset_query(); $query = $this->find(); } else { // Support for previous find(), no need to find() again $query = $this->_dbr; } // Check condition type if (is_array($condition)) { // Check if is numeric array if (array_keys($condition)===range(0, count($condition)-1)) { /* Numeric Array */ $query->where_in($this->_field($this->primaryKey), $condition); } else { /* Associated Array */ foreach ($condition as $field => $value) { (is_array($value)) ? $query->where_in($field, $value) : $query->where($field, $value); } } } elseif (is_numeric($condition) || is_string($condition)) { /* Single Primary Key */ $query->where($this->_field($this->primaryKey), $condition); } else { // Simply Check SQL for no condition such as update/delete // Warning: This protection just simply check keywords that may not find out for some situations. $sql = $this->_dbr->get_compiled_select('', false); // No reset query // Check FROM for table condition if (stripos($sql, 'from ')===false) throw new Exception("You should find() first, or use condition array for update/delete", 400); // No condition situation needs to enable where protection if (stripos($sql, 'where ')===false) throw new Exception("You could not update/delete without any condition! Use find()->where('1=1') or condition array at least.", 400); } return $query; }
php
protected function _findByCondition($condition=null) { if ($condition !== null) { $this->_dbr->reset_query(); $query = $this->find(); } else { $query = $this->_dbr; } if (is_array($condition)) { if (array_keys($condition)===range(0, count($condition)-1)) { $query->where_in($this->_field($this->primaryKey), $condition); } else { foreach ($condition as $field => $value) { (is_array($value)) ? $query->where_in($field, $value) : $query->where($field, $value); } } } elseif (is_numeric($condition) || is_string($condition)) { $query->where($this->_field($this->primaryKey), $condition); } else { $sql = $this->_dbr->get_compiled_select('', false); if (stripos($sql, 'from ')===false) throw new Exception("You should find() first, or use condition array for update/delete", 400); if (stripos($sql, 'where ')===false) throw new Exception("You could not update/delete without any condition! Use find()->where('1=1') or condition array at least.", 400); } return $query; }
[ "protected", "function", "_findByCondition", "(", "$", "condition", "=", "null", ")", "{", "// Reset Query if condition existed", "if", "(", "$", "condition", "!==", "null", ")", "{", "$", "this", "->", "_dbr", "->", "reset_query", "(", ")", ";", "$", "query", "=", "$", "this", "->", "find", "(", ")", ";", "}", "else", "{", "// Support for previous find(), no need to find() again", "$", "query", "=", "$", "this", "->", "_dbr", ";", "}", "// Check condition type", "if", "(", "is_array", "(", "$", "condition", ")", ")", "{", "// Check if is numeric array", "if", "(", "array_keys", "(", "$", "condition", ")", "===", "range", "(", "0", ",", "count", "(", "$", "condition", ")", "-", "1", ")", ")", "{", "/* Numeric Array */", "$", "query", "->", "where_in", "(", "$", "this", "->", "_field", "(", "$", "this", "->", "primaryKey", ")", ",", "$", "condition", ")", ";", "}", "else", "{", "/* Associated Array */", "foreach", "(", "$", "condition", "as", "$", "field", "=>", "$", "value", ")", "{", "(", "is_array", "(", "$", "value", ")", ")", "?", "$", "query", "->", "where_in", "(", "$", "field", ",", "$", "value", ")", ":", "$", "query", "->", "where", "(", "$", "field", ",", "$", "value", ")", ";", "}", "}", "}", "elseif", "(", "is_numeric", "(", "$", "condition", ")", "||", "is_string", "(", "$", "condition", ")", ")", "{", "/* Single Primary Key */", "$", "query", "->", "where", "(", "$", "this", "->", "_field", "(", "$", "this", "->", "primaryKey", ")", ",", "$", "condition", ")", ";", "}", "else", "{", "// Simply Check SQL for no condition such as update/delete", "// Warning: This protection just simply check keywords that may not find out for some situations.", "$", "sql", "=", "$", "this", "->", "_dbr", "->", "get_compiled_select", "(", "''", ",", "false", ")", ";", "// No reset query", "// Check FROM for table condition", "if", "(", "stripos", "(", "$", "sql", ",", "'from '", ")", "===", "false", ")", "throw", "new", "Exception", "(", "\"You should find() first, or use condition array for update/delete\"", ",", "400", ")", ";", "// No condition situation needs to enable where protection", "if", "(", "stripos", "(", "$", "sql", ",", "'where '", ")", "===", "false", ")", "throw", "new", "Exception", "(", "\"You could not update/delete without any condition! Use find()->where('1=1') or condition array at least.\"", ",", "400", ")", ";", "}", "return", "$", "query", ";", "}" ]
Finds record(s) by the given condition with a fresh query. This method is internally called by findOne(), findAll(), update(), delete(), etc. The query will be reset to start a new scope if the condition is used. @param mixed Primary key value or a set of column values. If is null, it would be used for previous find() method, which means it would not rebuild find() so it would check and protect the SQL statement. @return object CI_DB_query_builder @internal @example // find a single customer whose primary key value is 10 $this->_findByCondition(10); // find the customers whose primary key value is 10, 11 or 12. $this->_findByCondition([10, 11, 12]); // find the first customer whose age is 30 and whose status is 1 $this->_findByCondition(['age' => 30, 'status' => 1]);
[ "Finds", "record", "(", "s", ")", "by", "the", "given", "condition", "with", "a", "fresh", "query", "." ]
train
https://github.com/yidas/codeigniter-model/blob/14cd273bb0620dc0e2993fe924ee37f00301992f/src/Model.php#L1364-L1410
yidas/codeigniter-model
src/Model.php
Model._formatDate
protected function _formatDate($field, &$attributes) { if ($this->timestamps && $field) { switch ($this->dateFormat) { case 'datetime': $dateFormat = date("Y-m-d H:i:s"); break; case 'unixtime': default: $dateFormat = time(); break; } $attributes[$field] = $dateFormat; } return $attributes; }
php
protected function _formatDate($field, &$attributes) { if ($this->timestamps && $field) { switch ($this->dateFormat) { case 'datetime': $dateFormat = date("Y-m-d H:i:s"); break; case 'unixtime': default: $dateFormat = time(); break; } $attributes[$field] = $dateFormat; } return $attributes; }
[ "protected", "function", "_formatDate", "(", "$", "field", ",", "&", "$", "attributes", ")", "{", "if", "(", "$", "this", "->", "timestamps", "&&", "$", "field", ")", "{", "switch", "(", "$", "this", "->", "dateFormat", ")", "{", "case", "'datetime'", ":", "$", "dateFormat", "=", "date", "(", "\"Y-m-d H:i:s\"", ")", ";", "break", ";", "case", "'unixtime'", ":", "default", ":", "$", "dateFormat", "=", "time", "(", ")", ";", "break", ";", "}", "$", "attributes", "[", "$", "field", "]", "=", "$", "dateFormat", ";", "}", "return", "$", "attributes", ";", "}" ]
Format a date for timestamps @param string Field name @param array Attributes @return array Addon $attributes of pointer
[ "Format", "a", "date", "for", "timestamps" ]
train
https://github.com/yidas/codeigniter-model/blob/14cd273bb0620dc0e2993fe924ee37f00301992f/src/Model.php#L1419-L1438
yidas/codeigniter-model
src/Model.php
Model._addSoftDeletedCondition
protected function _addSoftDeletedCondition() { if ($this->_withoutSoftDeletedScope) { // Reset SOFT_DELETED switch $this->_withoutSoftDeletedScope = false; } elseif (static::SOFT_DELETED && isset($this->softDeletedFalseValue)) { // Add condition $this->_dbr->where($this->_field(static::SOFT_DELETED), $this->softDeletedFalseValue); } return true; }
php
protected function _addSoftDeletedCondition() { if ($this->_withoutSoftDeletedScope) { $this->_withoutSoftDeletedScope = false; } elseif (static::SOFT_DELETED && isset($this->softDeletedFalseValue)) { $this->_dbr->where($this->_field(static::SOFT_DELETED), $this->softDeletedFalseValue); } return true; }
[ "protected", "function", "_addSoftDeletedCondition", "(", ")", "{", "if", "(", "$", "this", "->", "_withoutSoftDeletedScope", ")", "{", "// Reset SOFT_DELETED switch", "$", "this", "->", "_withoutSoftDeletedScope", "=", "false", ";", "}", "elseif", "(", "static", "::", "SOFT_DELETED", "&&", "isset", "(", "$", "this", "->", "softDeletedFalseValue", ")", ")", "{", "// Add condition", "$", "this", "->", "_dbr", "->", "where", "(", "$", "this", "->", "_field", "(", "static", "::", "SOFT_DELETED", ")", ",", "$", "this", "->", "softDeletedFalseValue", ")", ";", "}", "return", "true", ";", "}" ]
The scope which not been soft deleted @param bool $skip Skip @return bool Result
[ "The", "scope", "which", "not", "been", "soft", "deleted" ]
train
https://github.com/yidas/codeigniter-model/blob/14cd273bb0620dc0e2993fe924ee37f00301992f/src/Model.php#L1446-L1459
yidas/codeigniter-model
src/Model.php
Model._getDefaultDB
private function _getDefaultDB() { // For ReadDatabase checking Master first if ($this->_db) { return $this->_db; } if (!isset($this->db)) { get_instance()->load->database(); } // No need to set as reference because $this->db is refered to &DB already. return get_instance()->db; }
php
private function _getDefaultDB() { if ($this->_db) { return $this->_db; } if (!isset($this->db)) { get_instance()->load->database(); } return get_instance()->db; }
[ "private", "function", "_getDefaultDB", "(", ")", "{", "// For ReadDatabase checking Master first", "if", "(", "$", "this", "->", "_db", ")", "{", "return", "$", "this", "->", "_db", ";", "}", "if", "(", "!", "isset", "(", "$", "this", "->", "db", ")", ")", "{", "get_instance", "(", ")", "->", "load", "->", "database", "(", ")", ";", "}", "// No need to set as reference because $this->db is refered to &DB already.", "return", "get_instance", "(", ")", "->", "db", ";", "}" ]
Get & load $this->db in CI application @return object CI $this->db
[ "Get", "&", "load", "$this", "-", ">", "db", "in", "CI", "application" ]
train
https://github.com/yidas/codeigniter-model/blob/14cd273bb0620dc0e2993fe924ee37f00301992f/src/Model.php#L1497-L1509
yidas/codeigniter-model
src/Model.php
Model.__isset
public function __isset($name) { if (isset($this->_writeProperties[$name])) { return true; } return isset($this->_readProperties[$name]); }
php
public function __isset($name) { if (isset($this->_writeProperties[$name])) { return true; } return isset($this->_readProperties[$name]); }
[ "public", "function", "__isset", "(", "$", "name", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "_writeProperties", "[", "$", "name", "]", ")", ")", "{", "return", "true", ";", "}", "return", "isset", "(", "$", "this", "->", "_readProperties", "[", "$", "name", "]", ")", ";", "}" ]
ORM isset property @param string $name @return void
[ "ORM", "isset", "property" ]
train
https://github.com/yidas/codeigniter-model/blob/14cd273bb0620dc0e2993fe924ee37f00301992f/src/Model.php#L1627-L1635
yidas/codeigniter-model
src/Model.php
Model.offsetGet
public function offsetGet($offset) { if (isset($this->_writeProperties[$offset])) { return $this->_writeProperties[$offset]; } elseif (isset($this->_readProperties[$offset]) ) { return $this->_readProperties[$offset]; } else { // Trace debug $lastFile = debug_backtrace()[0]['file']; $lastLine = debug_backtrace()[0]['line']; trigger_error("Undefined index: " . get_called_class() . "->{$offset} called by {$lastFile}:{$lastLine}", E_USER_NOTICE); return null; } }
php
public function offsetGet($offset) { if (isset($this->_writeProperties[$offset])) { return $this->_writeProperties[$offset]; } elseif (isset($this->_readProperties[$offset]) ) { return $this->_readProperties[$offset]; } else { $lastFile = debug_backtrace()[0]['file']; $lastLine = debug_backtrace()[0]['line']; trigger_error("Undefined index: " . get_called_class() . "->{$offset} called by {$lastFile}:{$lastLine}", E_USER_NOTICE); return null; } }
[ "public", "function", "offsetGet", "(", "$", "offset", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "_writeProperties", "[", "$", "offset", "]", ")", ")", "{", "return", "$", "this", "->", "_writeProperties", "[", "$", "offset", "]", ";", "}", "elseif", "(", "isset", "(", "$", "this", "->", "_readProperties", "[", "$", "offset", "]", ")", ")", "{", "return", "$", "this", "->", "_readProperties", "[", "$", "offset", "]", ";", "}", "else", "{", "// Trace debug", "$", "lastFile", "=", "debug_backtrace", "(", ")", "[", "0", "]", "[", "'file'", "]", ";", "$", "lastLine", "=", "debug_backtrace", "(", ")", "[", "0", "]", "[", "'line'", "]", ";", "trigger_error", "(", "\"Undefined index: \"", ".", "get_called_class", "(", ")", ".", "\"->{$offset} called by {$lastFile}:{$lastLine}\"", ",", "E_USER_NOTICE", ")", ";", "return", "null", ";", "}", "}" ]
ArrayAccess offsetGet @param string $offset @return mixed Value of property
[ "ArrayAccess", "offsetGet" ]
train
https://github.com/yidas/codeigniter-model/blob/14cd273bb0620dc0e2993fe924ee37f00301992f/src/Model.php#L1689-L1707
phpDocumentor/phpDocumentor2
src/phpDocumentor/Descriptor/DescriptorAbstract.php
DescriptorAbstract.getSummary
public function getSummary() { if ($this->summary && strtolower(trim($this->summary)) !== '{@inheritdoc}') { return $this->summary; } $parent = $this->getInheritedElement(); if ($parent instanceof self) { return $parent->getSummary(); } return $this->summary; }
php
public function getSummary() { if ($this->summary && strtolower(trim($this->summary)) !== '{@inheritdoc}') { return $this->summary; } $parent = $this->getInheritedElement(); if ($parent instanceof self) { return $parent->getSummary(); } return $this->summary; }
[ "public", "function", "getSummary", "(", ")", "{", "if", "(", "$", "this", "->", "summary", "&&", "strtolower", "(", "trim", "(", "$", "this", "->", "summary", ")", ")", "!==", "'{@inheritdoc}'", ")", "{", "return", "$", "this", "->", "summary", ";", "}", "$", "parent", "=", "$", "this", "->", "getInheritedElement", "(", ")", ";", "if", "(", "$", "parent", "instanceof", "self", ")", "{", "return", "$", "parent", "->", "getSummary", "(", ")", ";", "}", "return", "$", "this", "->", "summary", ";", "}" ]
Returns the summary which describes this element. This method will automatically attempt to inherit the parent's summary if this one has none. @return string
[ "Returns", "the", "summary", "which", "describes", "this", "element", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/DescriptorAbstract.php#L146-L158
phpDocumentor/phpDocumentor2
src/phpDocumentor/Descriptor/DescriptorAbstract.php
DescriptorAbstract.getDescription
public function getDescription() { if ($this->description && strpos(strtolower((string) $this->description), '{@inheritdoc}') === false) { return $this->description; } $parentElement = $this->getInheritedElement(); if ($parentElement instanceof self) { $parentDescription = $parentElement->getDescription(); return $this->description ? str_ireplace('{@inheritdoc}', $parentDescription, $this->description) : $parentDescription; } return $this->description; }
php
public function getDescription() { if ($this->description && strpos(strtolower((string) $this->description), '{@inheritdoc}') === false) { return $this->description; } $parentElement = $this->getInheritedElement(); if ($parentElement instanceof self) { $parentDescription = $parentElement->getDescription(); return $this->description ? str_ireplace('{@inheritdoc}', $parentDescription, $this->description) : $parentDescription; } return $this->description; }
[ "public", "function", "getDescription", "(", ")", "{", "if", "(", "$", "this", "->", "description", "&&", "strpos", "(", "strtolower", "(", "(", "string", ")", "$", "this", "->", "description", ")", ",", "'{@inheritdoc}'", ")", "===", "false", ")", "{", "return", "$", "this", "->", "description", ";", "}", "$", "parentElement", "=", "$", "this", "->", "getInheritedElement", "(", ")", ";", "if", "(", "$", "parentElement", "instanceof", "self", ")", "{", "$", "parentDescription", "=", "$", "parentElement", "->", "getDescription", "(", ")", ";", "return", "$", "this", "->", "description", "?", "str_ireplace", "(", "'{@inheritdoc}'", ",", "$", "parentDescription", ",", "$", "this", "->", "description", ")", ":", "$", "parentDescription", ";", "}", "return", "$", "this", "->", "description", ";", "}" ]
Returns the description for this element. This method will automatically attempt to inherit the parent's description if this one has none. @return string
[ "Returns", "the", "description", "for", "this", "element", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/DescriptorAbstract.php#L177-L193
phpDocumentor/phpDocumentor2
src/phpDocumentor/Descriptor/DescriptorAbstract.php
DescriptorAbstract.setLocation
public function setLocation(FileDescriptor $file, $line = 0) { $this->setFile($file); $this->line = $line; }
php
public function setLocation(FileDescriptor $file, $line = 0) { $this->setFile($file); $this->line = $line; }
[ "public", "function", "setLocation", "(", "FileDescriptor", "$", "file", ",", "$", "line", "=", "0", ")", "{", "$", "this", "->", "setFile", "(", "$", "file", ")", ";", "$", "this", "->", "line", "=", "$", "line", ";", "}" ]
Sets the file and linenumber where this element is at. @param int $line
[ "Sets", "the", "file", "and", "linenumber", "where", "this", "element", "is", "at", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/DescriptorAbstract.php#L200-L204
phpDocumentor/phpDocumentor2
src/phpDocumentor/Descriptor/DescriptorAbstract.php
DescriptorAbstract.getVersion
public function getVersion() { /** @var Collection $version */ $version = $this->getTags()->get('version', new Collection()); if ($version->count() !== 0) { return $version; } $inheritedElement = $this->getInheritedElement(); if ($inheritedElement) { return $inheritedElement->getVersion(); } return new Collection(); }
php
public function getVersion() { $version = $this->getTags()->get('version', new Collection()); if ($version->count() !== 0) { return $version; } $inheritedElement = $this->getInheritedElement(); if ($inheritedElement) { return $inheritedElement->getVersion(); } return new Collection(); }
[ "public", "function", "getVersion", "(", ")", "{", "/** @var Collection $version */", "$", "version", "=", "$", "this", "->", "getTags", "(", ")", "->", "get", "(", "'version'", ",", "new", "Collection", "(", ")", ")", ";", "if", "(", "$", "version", "->", "count", "(", ")", "!==", "0", ")", "{", "return", "$", "version", ";", "}", "$", "inheritedElement", "=", "$", "this", "->", "getInheritedElement", "(", ")", ";", "if", "(", "$", "inheritedElement", ")", "{", "return", "$", "inheritedElement", "->", "getVersion", "(", ")", ";", "}", "return", "new", "Collection", "(", ")", ";", "}" ]
Returns the versions for this element. @return Collection
[ "Returns", "the", "versions", "for", "this", "element", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/DescriptorAbstract.php#L328-L342
phpDocumentor/phpDocumentor2
src/phpDocumentor/Descriptor/DescriptorAbstract.php
DescriptorAbstract.getCopyright
public function getCopyright() { /** @var Collection $copyright */ $copyright = $this->getTags()->get('copyright', new Collection()); if ($copyright->count() !== 0) { return $copyright; } $inheritedElement = $this->getInheritedElement(); if ($inheritedElement) { return $inheritedElement->getCopyright(); } return new Collection(); }
php
public function getCopyright() { $copyright = $this->getTags()->get('copyright', new Collection()); if ($copyright->count() !== 0) { return $copyright; } $inheritedElement = $this->getInheritedElement(); if ($inheritedElement) { return $inheritedElement->getCopyright(); } return new Collection(); }
[ "public", "function", "getCopyright", "(", ")", "{", "/** @var Collection $copyright */", "$", "copyright", "=", "$", "this", "->", "getTags", "(", ")", "->", "get", "(", "'copyright'", ",", "new", "Collection", "(", ")", ")", ";", "if", "(", "$", "copyright", "->", "count", "(", ")", "!==", "0", ")", "{", "return", "$", "copyright", ";", "}", "$", "inheritedElement", "=", "$", "this", "->", "getInheritedElement", "(", ")", ";", "if", "(", "$", "inheritedElement", ")", "{", "return", "$", "inheritedElement", "->", "getCopyright", "(", ")", ";", "}", "return", "new", "Collection", "(", ")", ";", "}" ]
Returns the copyrights for this element. @return Collection
[ "Returns", "the", "copyrights", "for", "this", "element", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/DescriptorAbstract.php#L349-L363
phpDocumentor/phpDocumentor2
src/phpDocumentor/Plugin/Core/Transformer/Behaviour/Tag/InternalTag.php
InternalTag.process
public function process(\DOMDocument $xml) { $ignoreQry = '//long-description[contains(., "{@internal")]'; $xpath = new \DOMXPath($xml); $nodes = $xpath->query($ignoreQry); // either replace it with nothing or with the 'stored' value $replacement = $this->internalAllowed ? '$1' : ''; /** @var \DOMElement $node */ foreach ($nodes as $node) { $node->nodeValue = preg_replace('/\{@internal\s(.+?)\}\}/', $replacement, $node->nodeValue); } return $xml; }
php
public function process(\DOMDocument $xml) { $ignoreQry = ' $xpath = new \DOMXPath($xml); $nodes = $xpath->query($ignoreQry); $replacement = $this->internalAllowed ? '$1' : ''; foreach ($nodes as $node) { $node->nodeValue = preg_replace('/\{@internal\s(.+?)\}\}/', $replacement, $node->nodeValue); } return $xml; }
[ "public", "function", "process", "(", "\\", "DOMDocument", "$", "xml", ")", "{", "$", "ignoreQry", "=", "'//long-description[contains(., \"{@internal\")]'", ";", "$", "xpath", "=", "new", "\\", "DOMXPath", "(", "$", "xml", ")", ";", "$", "nodes", "=", "$", "xpath", "->", "query", "(", "$", "ignoreQry", ")", ";", "// either replace it with nothing or with the 'stored' value", "$", "replacement", "=", "$", "this", "->", "internalAllowed", "?", "'$1'", ":", "''", ";", "/** @var \\DOMElement $node */", "foreach", "(", "$", "nodes", "as", "$", "node", ")", "{", "$", "node", "->", "nodeValue", "=", "preg_replace", "(", "'/\\{@internal\\s(.+?)\\}\\}/'", ",", "$", "replacement", ",", "$", "node", "->", "nodeValue", ")", ";", "}", "return", "$", "xml", ";", "}" ]
Converts the 'internal' tags in Long Descriptions. @param \DOMDocument $xml Structure source to apply behaviour onto. @todo This behaviours actions should be moved to the parser / Reflector builder so that it can be cached and is available to all writers. @return \DOMDocument
[ "Converts", "the", "internal", "tags", "in", "Long", "Descriptions", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Core/Transformer/Behaviour/Tag/InternalTag.php#L46-L62
phpDocumentor/phpDocumentor2
src/phpDocumentor/Plugin/Scrybe/Converter/Metadata/TableOfContents.php
TableOfContents.offsetSet
public function offsetSet($index, $newval) { if (!$newval instanceof TableOfContents\File) { throw new \InvalidArgumentException('A table of contents may only be filled with File objects'); } $basename = basename($newval->getFilename()); if (strpos($basename, '.') !== false) { $basename = substr($basename, 0, strpos($basename, '.')); } if (strtolower($basename) === 'index') { $this->modules[] = $newval; } parent::offsetSet($newval->getFilename(), $newval); }
php
public function offsetSet($index, $newval) { if (!$newval instanceof TableOfContents\File) { throw new \InvalidArgumentException('A table of contents may only be filled with File objects'); } $basename = basename($newval->getFilename()); if (strpos($basename, '.') !== false) { $basename = substr($basename, 0, strpos($basename, '.')); } if (strtolower($basename) === 'index') { $this->modules[] = $newval; } parent::offsetSet($newval->getFilename(), $newval); }
[ "public", "function", "offsetSet", "(", "$", "index", ",", "$", "newval", ")", "{", "if", "(", "!", "$", "newval", "instanceof", "TableOfContents", "\\", "File", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'A table of contents may only be filled with File objects'", ")", ";", "}", "$", "basename", "=", "basename", "(", "$", "newval", "->", "getFilename", "(", ")", ")", ";", "if", "(", "strpos", "(", "$", "basename", ",", "'.'", ")", "!==", "false", ")", "{", "$", "basename", "=", "substr", "(", "$", "basename", ",", "0", ",", "strpos", "(", "$", "basename", ",", "'.'", ")", ")", ";", "}", "if", "(", "strtolower", "(", "$", "basename", ")", "===", "'index'", ")", "{", "$", "this", "->", "modules", "[", "]", "=", "$", "newval", ";", "}", "parent", "::", "offsetSet", "(", "$", "newval", "->", "getFilename", "(", ")", ",", "$", "newval", ")", ";", "}" ]
Override offsetSet to force the use of the relative filename. @param void $index @param TableOfContents\File $newval @throws \InvalidArgumentException if something other than a file is provided.
[ "Override", "offsetSet", "to", "force", "the", "use", "of", "the", "relative", "filename", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Scrybe/Converter/Metadata/TableOfContents.php#L49-L65
phpDocumentor/phpDocumentor2
src/phpDocumentor/Plugin/Scrybe/Template/Twig.php
Twig.setPath
public function setPath(string $path): void { if (!file_exists($path) || !is_dir($path)) { throw new InvalidArgumentException( 'Expected the template path to be an existing directory, received: ' . $path ); } $this->path = $path; }
php
public function setPath(string $path): void { if (!file_exists($path) || !is_dir($path)) { throw new InvalidArgumentException( 'Expected the template path to be an existing directory, received: ' . $path ); } $this->path = $path; }
[ "public", "function", "setPath", "(", "string", "$", "path", ")", ":", "void", "{", "if", "(", "!", "file_exists", "(", "$", "path", ")", "||", "!", "is_dir", "(", "$", "path", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Expected the template path to be an existing directory, received: '", ".", "$", "path", ")", ";", "}", "$", "this", "->", "path", "=", "$", "path", ";", "}" ]
Sets the base path where the templates are stored. @throws InvalidArgumentException
[ "Sets", "the", "base", "path", "where", "the", "templates", "are", "stored", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Scrybe/Template/Twig.php#L75-L84
phpDocumentor/phpDocumentor2
src/phpDocumentor/Plugin/Scrybe/Template/Twig.php
Twig.setExtension
public function setExtension(string $extension): void { if (!preg_match('/^[a-zA-Z0-9]{2,4}$/', $extension)) { throw new InvalidArgumentException( 'Extension should be only be composed of alphanumeric characters' . ' and should be at least 2 but no more than 4 characters' ); } $this->extension = $extension; }
php
public function setExtension(string $extension): void { if (!preg_match('/^[a-zA-Z0-9]{2,4}$/', $extension)) { throw new InvalidArgumentException( 'Extension should be only be composed of alphanumeric characters' . ' and should be at least 2 but no more than 4 characters' ); } $this->extension = $extension; }
[ "public", "function", "setExtension", "(", "string", "$", "extension", ")", ":", "void", "{", "if", "(", "!", "preg_match", "(", "'/^[a-zA-Z0-9]{2,4}$/'", ",", "$", "extension", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Extension should be only be composed of alphanumeric characters'", ".", "' and should be at least 2 but no more than 4 characters'", ")", ";", "}", "$", "this", "->", "extension", "=", "$", "extension", ";", "}" ]
Sets the file extension used to determine the template filename. The file extension of the destination format needs to be set. This is used to retrieve the correct template. @param string $extension an extension (thus only containing alphanumeric characters and be between 2 and 4 characters in size). @throws InvalidArgumentException if the extension does not match the validation restrictions mentioned above.
[ "Sets", "the", "file", "extension", "used", "to", "determine", "the", "template", "filename", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Scrybe/Template/Twig.php#L104-L114
phpDocumentor/phpDocumentor2
src/phpDocumentor/Plugin/Scrybe/Template/Twig.php
Twig.getTemplateFilename
protected function getTemplateFilename() { $filename = $this->name . '/layout.' . $this->extension . '.twig'; $template_path = $this->path . DIRECTORY_SEPARATOR . $filename; if (!file_exists($template_path)) { throw new \DomainException('Template file "' . $template_path . '" could not be found'); } return $filename; }
php
protected function getTemplateFilename() { $filename = $this->name . '/layout.' . $this->extension . '.twig'; $template_path = $this->path . DIRECTORY_SEPARATOR . $filename; if (!file_exists($template_path)) { throw new \DomainException('Template file "' . $template_path . '" could not be found'); } return $filename; }
[ "protected", "function", "getTemplateFilename", "(", ")", "{", "$", "filename", "=", "$", "this", "->", "name", ".", "'/layout.'", ".", "$", "this", "->", "extension", ".", "'.twig'", ";", "$", "template_path", "=", "$", "this", "->", "path", ".", "DIRECTORY_SEPARATOR", ".", "$", "filename", ";", "if", "(", "!", "file_exists", "(", "$", "template_path", ")", ")", "{", "throw", "new", "\\", "DomainException", "(", "'Template file \"'", ".", "$", "template_path", ".", "'\" could not be found'", ")", ";", "}", "return", "$", "filename", ";", "}" ]
Returns the filename for the template. The filename is composed of the following components: - the template base folder - the template's name - a path separator - the literal 'layout' combined with the extension - and as final extension the literal '.twig' @throws \DomainException if the template does not exist. @return string
[ "Returns", "the", "filename", "for", "the", "template", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Scrybe/Template/Twig.php#L191-L201
phpDocumentor/phpDocumentor2
src/phpDocumentor/Descriptor/ClassDescriptor.php
ClassDescriptor.getInheritedConstants
public function getInheritedConstants() { if (!$this->getParent() || (!$this->getParent() instanceof self)) { return new Collection(); } $inheritedConstants = clone $this->getParent()->getConstants(); return $inheritedConstants->merge($this->getParent()->getInheritedConstants()); }
php
public function getInheritedConstants() { if (!$this->getParent() || (!$this->getParent() instanceof self)) { return new Collection(); } $inheritedConstants = clone $this->getParent()->getConstants(); return $inheritedConstants->merge($this->getParent()->getInheritedConstants()); }
[ "public", "function", "getInheritedConstants", "(", ")", "{", "if", "(", "!", "$", "this", "->", "getParent", "(", ")", "||", "(", "!", "$", "this", "->", "getParent", "(", ")", "instanceof", "self", ")", ")", "{", "return", "new", "Collection", "(", ")", ";", "}", "$", "inheritedConstants", "=", "clone", "$", "this", "->", "getParent", "(", ")", "->", "getConstants", "(", ")", ";", "return", "$", "inheritedConstants", "->", "merge", "(", "$", "this", "->", "getParent", "(", ")", "->", "getInheritedConstants", "(", ")", ")", ";", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/ClassDescriptor.php#L144-L153
phpDocumentor/phpDocumentor2
src/phpDocumentor/Descriptor/ClassDescriptor.php
ClassDescriptor.getInheritedMethods
public function getInheritedMethods() { $inheritedMethods = new Collection(); foreach ($this->getUsedTraits() as $trait) { if (!$trait instanceof TraitDescriptor) { continue; } $inheritedMethods = $inheritedMethods->merge(clone $trait->getMethods()); } if (!$this->getParent() || (!$this->getParent() instanceof self)) { return $inheritedMethods; } $inheritedMethods = $inheritedMethods->merge(clone $this->getParent()->getMethods()); return $inheritedMethods->merge($this->getParent()->getInheritedMethods()); }
php
public function getInheritedMethods() { $inheritedMethods = new Collection(); foreach ($this->getUsedTraits() as $trait) { if (!$trait instanceof TraitDescriptor) { continue; } $inheritedMethods = $inheritedMethods->merge(clone $trait->getMethods()); } if (!$this->getParent() || (!$this->getParent() instanceof self)) { return $inheritedMethods; } $inheritedMethods = $inheritedMethods->merge(clone $this->getParent()->getMethods()); return $inheritedMethods->merge($this->getParent()->getInheritedMethods()); }
[ "public", "function", "getInheritedMethods", "(", ")", "{", "$", "inheritedMethods", "=", "new", "Collection", "(", ")", ";", "foreach", "(", "$", "this", "->", "getUsedTraits", "(", ")", "as", "$", "trait", ")", "{", "if", "(", "!", "$", "trait", "instanceof", "TraitDescriptor", ")", "{", "continue", ";", "}", "$", "inheritedMethods", "=", "$", "inheritedMethods", "->", "merge", "(", "clone", "$", "trait", "->", "getMethods", "(", ")", ")", ";", "}", "if", "(", "!", "$", "this", "->", "getParent", "(", ")", "||", "(", "!", "$", "this", "->", "getParent", "(", ")", "instanceof", "self", ")", ")", "{", "return", "$", "inheritedMethods", ";", "}", "$", "inheritedMethods", "=", "$", "inheritedMethods", "->", "merge", "(", "clone", "$", "this", "->", "getParent", "(", ")", "->", "getMethods", "(", ")", ")", ";", "return", "$", "inheritedMethods", "->", "merge", "(", "$", "this", "->", "getParent", "(", ")", "->", "getInheritedMethods", "(", ")", ")", ";", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/ClassDescriptor.php#L174-L193
phpDocumentor/phpDocumentor2
src/phpDocumentor/Descriptor/MethodDescriptor.php
MethodDescriptor.setArguments
public function setArguments(Collection $arguments) { foreach ($arguments as $argument) { $argument->setMethod($this); } $this->arguments = $arguments; }
php
public function setArguments(Collection $arguments) { foreach ($arguments as $argument) { $argument->setMethod($this); } $this->arguments = $arguments; }
[ "public", "function", "setArguments", "(", "Collection", "$", "arguments", ")", "{", "foreach", "(", "$", "arguments", "as", "$", "argument", ")", "{", "$", "argument", "->", "setMethod", "(", "$", "this", ")", ";", "}", "$", "this", "->", "arguments", "=", "$", "arguments", ";", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/MethodDescriptor.php#L147-L154
phpDocumentor/phpDocumentor2
src/phpDocumentor/Plugin/Core/Transformer/Behaviour/Tag/IgnoreTag.php
IgnoreTag.process
public function process(\DOMDocument $xml) { $ignoreQry = '//tag[@name=\'' . $this->tag . '\']'; $xpath = new \DOMXPath($xml); $nodes = $xpath->query($ignoreQry); /** @var \DOMElement $node */ foreach ($nodes as $node) { $remove = $node->parentNode->parentNode; // sometimes the parent node of the entity-to-be-removed is already // gone; for instance when a File docblock contains an @internal and // the underlying class also contains an @internal. // Because the File Docblock is found sooner, it is removed first. // Without the following check the application would fatal since // it cannot find, and then remove, this node from the parent. if (!isset($remove->parentNode)) { continue; } $remove->parentNode->removeChild($remove); } return $xml; }
php
public function process(\DOMDocument $xml) { $ignoreQry = ' $xpath = new \DOMXPath($xml); $nodes = $xpath->query($ignoreQry); foreach ($nodes as $node) { $remove = $node->parentNode->parentNode; if (!isset($remove->parentNode)) { continue; } $remove->parentNode->removeChild($remove); } return $xml; }
[ "public", "function", "process", "(", "\\", "DOMDocument", "$", "xml", ")", "{", "$", "ignoreQry", "=", "'//tag[@name=\\''", ".", "$", "this", "->", "tag", ".", "'\\']'", ";", "$", "xpath", "=", "new", "\\", "DOMXPath", "(", "$", "xml", ")", ";", "$", "nodes", "=", "$", "xpath", "->", "query", "(", "$", "ignoreQry", ")", ";", "/** @var \\DOMElement $node */", "foreach", "(", "$", "nodes", "as", "$", "node", ")", "{", "$", "remove", "=", "$", "node", "->", "parentNode", "->", "parentNode", ";", "// sometimes the parent node of the entity-to-be-removed is already", "// gone; for instance when a File docblock contains an @internal and", "// the underlying class also contains an @internal.", "// Because the File Docblock is found sooner, it is removed first.", "// Without the following check the application would fatal since", "// it cannot find, and then remove, this node from the parent.", "if", "(", "!", "isset", "(", "$", "remove", "->", "parentNode", ")", ")", "{", "continue", ";", "}", "$", "remove", "->", "parentNode", "->", "removeChild", "(", "$", "remove", ")", ";", "}", "return", "$", "xml", ";", "}" ]
Removes DocBlocks marked with 'ignore' tag from the structure. @param \DOMDocument $xml Structure source to apply behaviour onto. @return \DOMDocument
[ "Removes", "DocBlocks", "marked", "with", "ignore", "tag", "from", "the", "structure", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Core/Transformer/Behaviour/Tag/IgnoreTag.php#L32-L57
phpDocumentor/phpDocumentor2
src/phpDocumentor/DomainModel/Dsn.php
Dsn.parse
private function parse(string $dsn): void { $dsnParts = explode(';', $dsn); $location = $dsnParts[0]; unset($dsnParts[0]); $locationParts = parse_url($location); if ($locationParts === false || (array_key_exists('scheme', $locationParts) && \strlen($locationParts['scheme']) === 1) ) { preg_match(static::WINDOWS_DSN, $dsn, $locationParts); } if (! array_key_exists('scheme', $locationParts) || ($locationParts['scheme'] === '' && array_key_exists('path', $locationParts)) ) { $locationParts['scheme'] = 'file'; $location = 'file://' . $location; } if (!filter_var($location, FILTER_VALIDATE_URL) && !preg_match(static::WINDOWS_DSN, $location)) { throw new InvalidArgumentException( sprintf('"%s" is not a valid DSN.', $dsn) ); } $this->parseDsn($location, $dsnParts); $this->parseScheme($locationParts); $this->parseHostAndPath($locationParts); $this->parsePort($locationParts); $this->user = $locationParts['user'] ?? ''; $this->password = $locationParts['pass'] ?? ''; $this->parseQuery($locationParts); $this->parseParameters($dsnParts); }
php
private function parse(string $dsn): void { $dsnParts = explode(';', $dsn); $location = $dsnParts[0]; unset($dsnParts[0]); $locationParts = parse_url($location); if ($locationParts === false || (array_key_exists('scheme', $locationParts) && \strlen($locationParts['scheme']) === 1) ) { preg_match(static::WINDOWS_DSN, $dsn, $locationParts); } if (! array_key_exists('scheme', $locationParts) || ($locationParts['scheme'] === '' && array_key_exists('path', $locationParts)) ) { $locationParts['scheme'] = 'file'; $location = 'file: } if (!filter_var($location, FILTER_VALIDATE_URL) && !preg_match(static::WINDOWS_DSN, $location)) { throw new InvalidArgumentException( sprintf('"%s" is not a valid DSN.', $dsn) ); } $this->parseDsn($location, $dsnParts); $this->parseScheme($locationParts); $this->parseHostAndPath($locationParts); $this->parsePort($locationParts); $this->user = $locationParts['user'] ?? ''; $this->password = $locationParts['pass'] ?? ''; $this->parseQuery($locationParts); $this->parseParameters($dsnParts); }
[ "private", "function", "parse", "(", "string", "$", "dsn", ")", ":", "void", "{", "$", "dsnParts", "=", "explode", "(", "';'", ",", "$", "dsn", ")", ";", "$", "location", "=", "$", "dsnParts", "[", "0", "]", ";", "unset", "(", "$", "dsnParts", "[", "0", "]", ")", ";", "$", "locationParts", "=", "parse_url", "(", "$", "location", ")", ";", "if", "(", "$", "locationParts", "===", "false", "||", "(", "array_key_exists", "(", "'scheme'", ",", "$", "locationParts", ")", "&&", "\\", "strlen", "(", "$", "locationParts", "[", "'scheme'", "]", ")", "===", "1", ")", ")", "{", "preg_match", "(", "static", "::", "WINDOWS_DSN", ",", "$", "dsn", ",", "$", "locationParts", ")", ";", "}", "if", "(", "!", "array_key_exists", "(", "'scheme'", ",", "$", "locationParts", ")", "||", "(", "$", "locationParts", "[", "'scheme'", "]", "===", "''", "&&", "array_key_exists", "(", "'path'", ",", "$", "locationParts", ")", ")", ")", "{", "$", "locationParts", "[", "'scheme'", "]", "=", "'file'", ";", "$", "location", "=", "'file://'", ".", "$", "location", ";", "}", "if", "(", "!", "filter_var", "(", "$", "location", ",", "FILTER_VALIDATE_URL", ")", "&&", "!", "preg_match", "(", "static", "::", "WINDOWS_DSN", ",", "$", "location", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'\"%s\" is not a valid DSN.'", ",", "$", "dsn", ")", ")", ";", "}", "$", "this", "->", "parseDsn", "(", "$", "location", ",", "$", "dsnParts", ")", ";", "$", "this", "->", "parseScheme", "(", "$", "locationParts", ")", ";", "$", "this", "->", "parseHostAndPath", "(", "$", "locationParts", ")", ";", "$", "this", "->", "parsePort", "(", "$", "locationParts", ")", ";", "$", "this", "->", "user", "=", "$", "locationParts", "[", "'user'", "]", "??", "''", ";", "$", "this", "->", "password", "=", "$", "locationParts", "[", "'pass'", "]", "??", "''", ";", "$", "this", "->", "parseQuery", "(", "$", "locationParts", ")", ";", "$", "this", "->", "parseParameters", "(", "$", "dsnParts", ")", ";", "}" ]
Parses the given DSN
[ "Parses", "the", "given", "DSN" ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/DomainModel/Dsn.php#L144-L185
phpDocumentor/phpDocumentor2
src/phpDocumentor/DomainModel/Dsn.php
Dsn.parseDsn
private function parseDsn(string $location, array $dsnParts): void { array_splice($dsnParts, 0, 0, $location); $this->dsn = implode(';', $dsnParts); }
php
private function parseDsn(string $location, array $dsnParts): void { array_splice($dsnParts, 0, 0, $location); $this->dsn = implode(';', $dsnParts); }
[ "private", "function", "parseDsn", "(", "string", "$", "location", ",", "array", "$", "dsnParts", ")", ":", "void", "{", "array_splice", "(", "$", "dsnParts", ",", "0", ",", "0", ",", "$", "location", ")", ";", "$", "this", "->", "dsn", "=", "implode", "(", "';'", ",", "$", "dsnParts", ")", ";", "}" ]
Reconstructs the original DSN but when scheme was omitted in the original DSN, it will now be file:// @param string[] $dsnParts
[ "Reconstructs", "the", "original", "DSN", "but", "when", "scheme", "was", "omitted", "in", "the", "original", "DSN", "it", "will", "now", "be", "file", ":", "//" ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/DomainModel/Dsn.php#L193-L197
phpDocumentor/phpDocumentor2
src/phpDocumentor/DomainModel/Dsn.php
Dsn.parseScheme
private function parseScheme(array $locationParts): void { if (! $this->isValidScheme($locationParts['scheme'])) { throw new InvalidArgumentException( sprintf('"%s" is not a valid scheme.', $locationParts['scheme']) ); } $this->scheme = strtolower($locationParts['scheme']); }
php
private function parseScheme(array $locationParts): void { if (! $this->isValidScheme($locationParts['scheme'])) { throw new InvalidArgumentException( sprintf('"%s" is not a valid scheme.', $locationParts['scheme']) ); } $this->scheme = strtolower($locationParts['scheme']); }
[ "private", "function", "parseScheme", "(", "array", "$", "locationParts", ")", ":", "void", "{", "if", "(", "!", "$", "this", "->", "isValidScheme", "(", "$", "locationParts", "[", "'scheme'", "]", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'\"%s\" is not a valid scheme.'", ",", "$", "locationParts", "[", "'scheme'", "]", ")", ")", ";", "}", "$", "this", "->", "scheme", "=", "strtolower", "(", "$", "locationParts", "[", "'scheme'", "]", ")", ";", "}" ]
validates and sets the scheme property @param string[] $locationParts @throws InvalidArgumentException
[ "validates", "and", "sets", "the", "scheme", "property" ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/DomainModel/Dsn.php#L205-L214
phpDocumentor/phpDocumentor2
src/phpDocumentor/DomainModel/Dsn.php
Dsn.isValidScheme
private function isValidScheme(string $scheme): bool { $validSchemes = ['file', 'git+http', 'git+https']; return \in_array(\strtolower($scheme), $validSchemes, true); }
php
private function isValidScheme(string $scheme): bool { $validSchemes = ['file', 'git+http', 'git+https']; return \in_array(\strtolower($scheme), $validSchemes, true); }
[ "private", "function", "isValidScheme", "(", "string", "$", "scheme", ")", ":", "bool", "{", "$", "validSchemes", "=", "[", "'file'", ",", "'git+http'", ",", "'git+https'", "]", ";", "return", "\\", "in_array", "(", "\\", "strtolower", "(", "$", "scheme", ")", ",", "$", "validSchemes", ",", "true", ")", ";", "}" ]
Validated provided scheme.
[ "Validated", "provided", "scheme", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/DomainModel/Dsn.php#L219-L223
phpDocumentor/phpDocumentor2
src/phpDocumentor/DomainModel/Dsn.php
Dsn.parseHostAndPath
private function parseHostAndPath(array $locationParts): void { $path = $locationParts['path'] ?? ''; $host = $locationParts['host'] ?? ''; if ($this->getScheme() === 'file') { $this->path = $host . $path; } else { $this->host = $host; $this->path = $path; } }
php
private function parseHostAndPath(array $locationParts): void { $path = $locationParts['path'] ?? ''; $host = $locationParts['host'] ?? ''; if ($this->getScheme() === 'file') { $this->path = $host . $path; } else { $this->host = $host; $this->path = $path; } }
[ "private", "function", "parseHostAndPath", "(", "array", "$", "locationParts", ")", ":", "void", "{", "$", "path", "=", "$", "locationParts", "[", "'path'", "]", "??", "''", ";", "$", "host", "=", "$", "locationParts", "[", "'host'", "]", "??", "''", ";", "if", "(", "$", "this", "->", "getScheme", "(", ")", "===", "'file'", ")", "{", "$", "this", "->", "path", "=", "$", "host", ".", "$", "path", ";", "}", "else", "{", "$", "this", "->", "host", "=", "$", "host", ";", "$", "this", "->", "path", "=", "$", "path", ";", "}", "}" ]
Validates and sets the host and path properties @param string[] $locationParts
[ "Validates", "and", "sets", "the", "host", "and", "path", "properties" ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/DomainModel/Dsn.php#L230-L241
phpDocumentor/phpDocumentor2
src/phpDocumentor/DomainModel/Dsn.php
Dsn.parsePort
private function parsePort(array $locationParts): void { if (! isset($locationParts['port'])) { if ($this->getScheme() === 'git+http') { $this->port = 80; } elseif ($this->getScheme() === 'git+https') { $this->port = 443; } else { $this->port = 0; } } else { $this->port = (int) $locationParts['port']; } }
php
private function parsePort(array $locationParts): void { if (! isset($locationParts['port'])) { if ($this->getScheme() === 'git+http') { $this->port = 80; } elseif ($this->getScheme() === 'git+https') { $this->port = 443; } else { $this->port = 0; } } else { $this->port = (int) $locationParts['port']; } }
[ "private", "function", "parsePort", "(", "array", "$", "locationParts", ")", ":", "void", "{", "if", "(", "!", "isset", "(", "$", "locationParts", "[", "'port'", "]", ")", ")", "{", "if", "(", "$", "this", "->", "getScheme", "(", ")", "===", "'git+http'", ")", "{", "$", "this", "->", "port", "=", "80", ";", "}", "elseif", "(", "$", "this", "->", "getScheme", "(", ")", "===", "'git+https'", ")", "{", "$", "this", "->", "port", "=", "443", ";", "}", "else", "{", "$", "this", "->", "port", "=", "0", ";", "}", "}", "else", "{", "$", "this", "->", "port", "=", "(", "int", ")", "$", "locationParts", "[", "'port'", "]", ";", "}", "}" ]
Validates and sets the port property @param string[] $locationParts
[ "Validates", "and", "sets", "the", "port", "property" ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/DomainModel/Dsn.php#L248-L261
phpDocumentor/phpDocumentor2
src/phpDocumentor/DomainModel/Dsn.php
Dsn.parseQuery
private function parseQuery(array $locationParts): void { if (isset($locationParts['query'])) { $queryParts = explode('&', $locationParts['query']); foreach ($queryParts as $part) { $option = $this->splitKeyValuePair($part); $this->query[$option[0]] = $option[1]; } } }
php
private function parseQuery(array $locationParts): void { if (isset($locationParts['query'])) { $queryParts = explode('&', $locationParts['query']); foreach ($queryParts as $part) { $option = $this->splitKeyValuePair($part); $this->query[$option[0]] = $option[1]; } } }
[ "private", "function", "parseQuery", "(", "array", "$", "locationParts", ")", ":", "void", "{", "if", "(", "isset", "(", "$", "locationParts", "[", "'query'", "]", ")", ")", "{", "$", "queryParts", "=", "explode", "(", "'&'", ",", "$", "locationParts", "[", "'query'", "]", ")", ";", "foreach", "(", "$", "queryParts", "as", "$", "part", ")", "{", "$", "option", "=", "$", "this", "->", "splitKeyValuePair", "(", "$", "part", ")", ";", "$", "this", "->", "query", "[", "$", "option", "[", "0", "]", "]", "=", "$", "option", "[", "1", "]", ";", "}", "}", "}" ]
validates and sets the query property @param string[] $locationParts
[ "validates", "and", "sets", "the", "query", "property" ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/DomainModel/Dsn.php#L268-L278
phpDocumentor/phpDocumentor2
src/phpDocumentor/DomainModel/Dsn.php
Dsn.parseParameters
private function parseParameters(array $dsnParts): void { foreach ($dsnParts as $part) { $option = $this->splitKeyValuePair($part); $this->parameters[$option[0]] = $option[1]; } }
php
private function parseParameters(array $dsnParts): void { foreach ($dsnParts as $part) { $option = $this->splitKeyValuePair($part); $this->parameters[$option[0]] = $option[1]; } }
[ "private", "function", "parseParameters", "(", "array", "$", "dsnParts", ")", ":", "void", "{", "foreach", "(", "$", "dsnParts", "as", "$", "part", ")", "{", "$", "option", "=", "$", "this", "->", "splitKeyValuePair", "(", "$", "part", ")", ";", "$", "this", "->", "parameters", "[", "$", "option", "[", "0", "]", "]", "=", "$", "option", "[", "1", "]", ";", "}", "}" ]
validates and sets the parameters property @param string[] $dsnParts
[ "validates", "and", "sets", "the", "parameters", "property" ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/DomainModel/Dsn.php#L285-L292
phpDocumentor/phpDocumentor2
src/phpDocumentor/DomainModel/Dsn.php
Dsn.splitKeyValuePair
private function splitKeyValuePair(string $pair): array { $option = explode('=', $pair); if (count($option) !== 2) { throw new InvalidArgumentException( sprintf('"%s" is not a valid query or parameter.', $pair) ); } return $option; }
php
private function splitKeyValuePair(string $pair): array { $option = explode('=', $pair); if (count($option) !== 2) { throw new InvalidArgumentException( sprintf('"%s" is not a valid query or parameter.', $pair) ); } return $option; }
[ "private", "function", "splitKeyValuePair", "(", "string", "$", "pair", ")", ":", "array", "{", "$", "option", "=", "explode", "(", "'='", ",", "$", "pair", ")", ";", "if", "(", "count", "(", "$", "option", ")", "!==", "2", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'\"%s\" is not a valid query or parameter.'", ",", "$", "pair", ")", ")", ";", "}", "return", "$", "option", ";", "}" ]
Splits a key-value pair @return string[] @throws InvalidArgumentException
[ "Splits", "a", "key", "-", "value", "pair" ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/DomainModel/Dsn.php#L300-L310
phpDocumentor/phpDocumentor2
src/phpDocumentor/Plugin/Core/Transformer/Writer/Xml/TagConverter.php
TagConverter.convert
public function convert(\DOMElement $parent, TagDescriptor $tag) { $description = $this->getDescription($tag); $child = new \DOMElement('tag'); $parent->appendChild($child); $child->setAttribute('name', str_replace('&', '&', $tag->getName())); $child->setAttribute('line', $parent->getAttribute('line')); $child->setAttribute('description', str_replace('&', '&', $description)); $this->addTypes($tag, $child); // TODO: make the tests below configurable from the outside so that more could be added using plugins if ($tag instanceof TypedVariableAbstract) { $child->setAttribute('variable', str_replace('&', '&', $tag->getVariableName())); } if ($tag instanceof SeeDescriptor || $tag instanceof UsesDescriptor) { $child->setAttribute('link', str_replace('&', '&', $tag->getReference())); } if ($tag instanceof LinkDescriptor) { $child->setAttribute('link', str_replace('&', '&', $tag->getLink())); } if ($tag instanceof MethodDescriptor) { $child->setAttribute('method_name', str_replace('&', '&', $tag->getMethodName())); } return $child; }
php
public function convert(\DOMElement $parent, TagDescriptor $tag) { $description = $this->getDescription($tag); $child = new \DOMElement('tag'); $parent->appendChild($child); $child->setAttribute('name', str_replace('&', '&', $tag->getName())); $child->setAttribute('line', $parent->getAttribute('line')); $child->setAttribute('description', str_replace('&', '&', $description)); $this->addTypes($tag, $child); if ($tag instanceof TypedVariableAbstract) { $child->setAttribute('variable', str_replace('&', '&', $tag->getVariableName())); } if ($tag instanceof SeeDescriptor || $tag instanceof UsesDescriptor) { $child->setAttribute('link', str_replace('&', '&', $tag->getReference())); } if ($tag instanceof LinkDescriptor) { $child->setAttribute('link', str_replace('&', '&', $tag->getLink())); } if ($tag instanceof MethodDescriptor) { $child->setAttribute('method_name', str_replace('&', '&', $tag->getMethodName())); } return $child; }
[ "public", "function", "convert", "(", "\\", "DOMElement", "$", "parent", ",", "TagDescriptor", "$", "tag", ")", "{", "$", "description", "=", "$", "this", "->", "getDescription", "(", "$", "tag", ")", ";", "$", "child", "=", "new", "\\", "DOMElement", "(", "'tag'", ")", ";", "$", "parent", "->", "appendChild", "(", "$", "child", ")", ";", "$", "child", "->", "setAttribute", "(", "'name'", ",", "str_replace", "(", "'&'", ",", "'&'", ",", "$", "tag", "->", "getName", "(", ")", ")", ")", ";", "$", "child", "->", "setAttribute", "(", "'line'", ",", "$", "parent", "->", "getAttribute", "(", "'line'", ")", ")", ";", "$", "child", "->", "setAttribute", "(", "'description'", ",", "str_replace", "(", "'&'", ",", "'&'", ",", "$", "description", ")", ")", ";", "$", "this", "->", "addTypes", "(", "$", "tag", ",", "$", "child", ")", ";", "// TODO: make the tests below configurable from the outside so that more could be added using plugins", "if", "(", "$", "tag", "instanceof", "TypedVariableAbstract", ")", "{", "$", "child", "->", "setAttribute", "(", "'variable'", ",", "str_replace", "(", "'&'", ",", "'&'", ",", "$", "tag", "->", "getVariableName", "(", ")", ")", ")", ";", "}", "if", "(", "$", "tag", "instanceof", "SeeDescriptor", "||", "$", "tag", "instanceof", "UsesDescriptor", ")", "{", "$", "child", "->", "setAttribute", "(", "'link'", ",", "str_replace", "(", "'&'", ",", "'&'", ",", "$", "tag", "->", "getReference", "(", ")", ")", ")", ";", "}", "if", "(", "$", "tag", "instanceof", "LinkDescriptor", ")", "{", "$", "child", "->", "setAttribute", "(", "'link'", ",", "str_replace", "(", "'&'", ",", "'&'", ",", "$", "tag", "->", "getLink", "(", ")", ")", ")", ";", "}", "if", "(", "$", "tag", "instanceof", "MethodDescriptor", ")", "{", "$", "child", "->", "setAttribute", "(", "'method_name'", ",", "str_replace", "(", "'&'", ",", "'&'", ",", "$", "tag", "->", "getMethodName", "(", ")", ")", ")", ";", "}", "return", "$", "child", ";", "}" ]
Export this tag to the given DocBlock. @param \DOMElement $parent Element to augment. @param TagDescriptor $tag The tag to export. @return \DOMElement
[ "Export", "this", "tag", "to", "the", "given", "DocBlock", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Core/Transformer/Writer/Xml/TagConverter.php#L48-L78
phpDocumentor/phpDocumentor2
src/phpDocumentor/Plugin/Core/Transformer/Writer/Xml/TagConverter.php
TagConverter.getDescription
protected function getDescription(TagDescriptor $tag) { $description = ''; if ($tag instanceof VersionDescriptor || $tag instanceof DeprecatedDescriptor || $tag instanceof SinceDescriptor ) { $description .= $tag->getVersion() . ' '; } $description .= $tag->getDescription(); return trim($description); }
php
protected function getDescription(TagDescriptor $tag) { $description = ''; if ($tag instanceof VersionDescriptor || $tag instanceof DeprecatedDescriptor || $tag instanceof SinceDescriptor ) { $description .= $tag->getVersion() . ' '; } $description .= $tag->getDescription(); return trim($description); }
[ "protected", "function", "getDescription", "(", "TagDescriptor", "$", "tag", ")", "{", "$", "description", "=", "''", ";", "if", "(", "$", "tag", "instanceof", "VersionDescriptor", "||", "$", "tag", "instanceof", "DeprecatedDescriptor", "||", "$", "tag", "instanceof", "SinceDescriptor", ")", "{", "$", "description", ".=", "$", "tag", "->", "getVersion", "(", ")", ".", "' '", ";", "}", "$", "description", ".=", "$", "tag", "->", "getDescription", "(", ")", ";", "return", "trim", "(", "$", "description", ")", ";", "}" ]
Returns the description from the Tag with the version prepended when applicable. @todo the version should not be prepended here but in templates; remove this. @return string
[ "Returns", "the", "description", "from", "the", "Tag", "with", "the", "version", "prepended", "when", "applicable", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Core/Transformer/Writer/Xml/TagConverter.php#L86-L100
phpDocumentor/phpDocumentor2
src/phpDocumentor/Plugin/Core/Transformer/Writer/Xml/TagConverter.php
TagConverter.addTypes
protected function addTypes(TagDescriptor $tag, \DOMElement $child) { $typeString = ''; if ($tag instanceof TypedAbstract) { $types = $tag->getType(); if ($types instanceof \IteratorAggregate) { foreach ($types as $type) { $typeString .= $type . '|'; /** @var \DOMElement $typeNode */ $typeNode = $child->appendChild(new \DOMElement('type')); $typeNode->appendChild(new \DOMText((string) $type)); } } else { $typeString .= $types . '|'; /** @var \DOMElement $typeNode */ $typeNode = $child->appendChild(new \DOMElement('type')); $typeNode->appendChild(new \DOMText((string) $types)); } $child->setAttribute('type', str_replace('&', '&', rtrim($typeString, '|'))); } }
php
protected function addTypes(TagDescriptor $tag, \DOMElement $child) { $typeString = ''; if ($tag instanceof TypedAbstract) { $types = $tag->getType(); if ($types instanceof \IteratorAggregate) { foreach ($types as $type) { $typeString .= $type . '|'; $typeNode = $child->appendChild(new \DOMElement('type')); $typeNode->appendChild(new \DOMText((string) $type)); } } else { $typeString .= $types . '|'; $typeNode = $child->appendChild(new \DOMElement('type')); $typeNode->appendChild(new \DOMText((string) $types)); } $child->setAttribute('type', str_replace('&', '&', rtrim($typeString, '|'))); } }
[ "protected", "function", "addTypes", "(", "TagDescriptor", "$", "tag", ",", "\\", "DOMElement", "$", "child", ")", "{", "$", "typeString", "=", "''", ";", "if", "(", "$", "tag", "instanceof", "TypedAbstract", ")", "{", "$", "types", "=", "$", "tag", "->", "getType", "(", ")", ";", "if", "(", "$", "types", "instanceof", "\\", "IteratorAggregate", ")", "{", "foreach", "(", "$", "types", "as", "$", "type", ")", "{", "$", "typeString", ".=", "$", "type", ".", "'|'", ";", "/** @var \\DOMElement $typeNode */", "$", "typeNode", "=", "$", "child", "->", "appendChild", "(", "new", "\\", "DOMElement", "(", "'type'", ")", ")", ";", "$", "typeNode", "->", "appendChild", "(", "new", "\\", "DOMText", "(", "(", "string", ")", "$", "type", ")", ")", ";", "}", "}", "else", "{", "$", "typeString", ".=", "$", "types", ".", "'|'", ";", "/** @var \\DOMElement $typeNode */", "$", "typeNode", "=", "$", "child", "->", "appendChild", "(", "new", "\\", "DOMElement", "(", "'type'", ")", ")", ";", "$", "typeNode", "->", "appendChild", "(", "new", "\\", "DOMText", "(", "(", "string", ")", "$", "types", ")", ")", ";", "}", "$", "child", "->", "setAttribute", "(", "'type'", ",", "str_replace", "(", "'&'", ",", "'&'", ",", "rtrim", "(", "$", "typeString", ",", "'|'", ")", ")", ")", ";", "}", "}" ]
Adds type elements and a type attribute to the tag if a method 'getTypes' is present.
[ "Adds", "type", "elements", "and", "a", "type", "attribute", "to", "the", "tag", "if", "a", "method", "getTypes", "is", "present", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Core/Transformer/Writer/Xml/TagConverter.php#L105-L130
phpDocumentor/phpDocumentor2
src/phpDocumentor/Descriptor/Builder/Reflector/Tags/GenericTagAssembler.php
GenericTagAssembler.create
public function create($data) { $descriptor = new TagDescriptor($data->getName()); if ($data instanceof BaseTag) { $descriptor->setDescription($data->getDescription()); } return $descriptor; }
php
public function create($data) { $descriptor = new TagDescriptor($data->getName()); if ($data instanceof BaseTag) { $descriptor->setDescription($data->getDescription()); } return $descriptor; }
[ "public", "function", "create", "(", "$", "data", ")", "{", "$", "descriptor", "=", "new", "TagDescriptor", "(", "$", "data", "->", "getName", "(", ")", ")", ";", "if", "(", "$", "data", "instanceof", "BaseTag", ")", "{", "$", "descriptor", "->", "setDescription", "(", "$", "data", "->", "getDescription", "(", ")", ")", ";", "}", "return", "$", "descriptor", ";", "}" ]
Creates a new Descriptor from the given Reflector. @param Tag $data @return TagDescriptor
[ "Creates", "a", "new", "Descriptor", "from", "the", "given", "Reflector", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/Builder/Reflector/Tags/GenericTagAssembler.php#L32-L41
phpDocumentor/phpDocumentor2
src/phpDocumentor/Plugin/Core/Transformer/Writer/Pathfinder.php
Pathfinder.find
public function find($object, $query) { if ($query) { $node = $this->walkObjectTree($object, $query); if (!is_array($node) && (!$node instanceof \Traversable)) { $node = [$node]; } return $node; } return [$object]; }
php
public function find($object, $query) { if ($query) { $node = $this->walkObjectTree($object, $query); if (!is_array($node) && (!$node instanceof \Traversable)) { $node = [$node]; } return $node; } return [$object]; }
[ "public", "function", "find", "(", "$", "object", ",", "$", "query", ")", "{", "if", "(", "$", "query", ")", "{", "$", "node", "=", "$", "this", "->", "walkObjectTree", "(", "$", "object", ",", "$", "query", ")", ";", "if", "(", "!", "is_array", "(", "$", "node", ")", "&&", "(", "!", "$", "node", "instanceof", "\\", "Traversable", ")", ")", "{", "$", "node", "=", "[", "$", "node", "]", ";", "}", "return", "$", "node", ";", "}", "return", "[", "$", "object", "]", ";", "}" ]
Combines the query and an object to retrieve a list of nodes that are to be used as node-point in a template. This method interprets the provided query string and walks through the given object to find the correct element. This method will silently fail if an invalid query was provided; in such a case the given object is returned. @param object $object @param string $query @return \Traversable|array
[ "Combines", "the", "query", "and", "an", "object", "to", "retrieve", "a", "list", "of", "nodes", "that", "are", "to", "be", "used", "as", "node", "-", "point", "in", "a", "template", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Core/Transformer/Writer/Pathfinder.php#L32-L45
phpDocumentor/phpDocumentor2
src/phpDocumentor/Plugin/Core/Transformer/Writer/Pathfinder.php
Pathfinder.walkObjectTree
private function walkObjectTree($objectOrArray, $query) { $node = $objectOrArray; $objectPath = explode('.', $query); // walk through the tree foreach ($objectPath as $pathNode) { if (is_array($node)) { if (isset($node[$pathNode])) { $node = $node[$pathNode]; continue; } } elseif (is_object($node)) { if (isset($node->{$pathNode}) || (method_exists($node, '__get') && $node->{$pathNode})) { $node = $node->{$pathNode}; continue; } elseif (method_exists($node, $pathNode)) { $node = $node->{$pathNode}(); continue; } elseif (method_exists($node, 'get' . $pathNode)) { $pathNode = 'get' . $pathNode; $node = $node->{$pathNode}(); continue; } elseif (method_exists($node, 'is' . $pathNode)) { $pathNode = 'is' . $pathNode; $node = $node->{$pathNode}(); continue; } } return null; } return $node; }
php
private function walkObjectTree($objectOrArray, $query) { $node = $objectOrArray; $objectPath = explode('.', $query); foreach ($objectPath as $pathNode) { if (is_array($node)) { if (isset($node[$pathNode])) { $node = $node[$pathNode]; continue; } } elseif (is_object($node)) { if (isset($node->{$pathNode}) || (method_exists($node, '__get') && $node->{$pathNode})) { $node = $node->{$pathNode}; continue; } elseif (method_exists($node, $pathNode)) { $node = $node->{$pathNode}(); continue; } elseif (method_exists($node, 'get' . $pathNode)) { $pathNode = 'get' . $pathNode; $node = $node->{$pathNode}(); continue; } elseif (method_exists($node, 'is' . $pathNode)) { $pathNode = 'is' . $pathNode; $node = $node->{$pathNode}(); continue; } } return null; } return $node; }
[ "private", "function", "walkObjectTree", "(", "$", "objectOrArray", ",", "$", "query", ")", "{", "$", "node", "=", "$", "objectOrArray", ";", "$", "objectPath", "=", "explode", "(", "'.'", ",", "$", "query", ")", ";", "// walk through the tree", "foreach", "(", "$", "objectPath", "as", "$", "pathNode", ")", "{", "if", "(", "is_array", "(", "$", "node", ")", ")", "{", "if", "(", "isset", "(", "$", "node", "[", "$", "pathNode", "]", ")", ")", "{", "$", "node", "=", "$", "node", "[", "$", "pathNode", "]", ";", "continue", ";", "}", "}", "elseif", "(", "is_object", "(", "$", "node", ")", ")", "{", "if", "(", "isset", "(", "$", "node", "->", "{", "$", "pathNode", "}", ")", "||", "(", "method_exists", "(", "$", "node", ",", "'__get'", ")", "&&", "$", "node", "->", "{", "$", "pathNode", "}", ")", ")", "{", "$", "node", "=", "$", "node", "->", "{", "$", "pathNode", "}", ";", "continue", ";", "}", "elseif", "(", "method_exists", "(", "$", "node", ",", "$", "pathNode", ")", ")", "{", "$", "node", "=", "$", "node", "->", "{", "$", "pathNode", "}", "(", ")", ";", "continue", ";", "}", "elseif", "(", "method_exists", "(", "$", "node", ",", "'get'", ".", "$", "pathNode", ")", ")", "{", "$", "pathNode", "=", "'get'", ".", "$", "pathNode", ";", "$", "node", "=", "$", "node", "->", "{", "$", "pathNode", "}", "(", ")", ";", "continue", ";", "}", "elseif", "(", "method_exists", "(", "$", "node", ",", "'is'", ".", "$", "pathNode", ")", ")", "{", "$", "pathNode", "=", "'is'", ".", "$", "pathNode", ";", "$", "node", "=", "$", "node", "->", "{", "$", "pathNode", "}", "(", ")", ";", "continue", ";", "}", "}", "return", "null", ";", "}", "return", "$", "node", ";", "}" ]
Walks an object graph and/or array using a twig query string. @param \Traversable|mixed $objectOrArray @param string $query A path to walk separated by dots, i.e. `namespace.namespaces`. @return mixed
[ "Walks", "an", "object", "graph", "and", "/", "or", "array", "using", "a", "twig", "query", "string", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Core/Transformer/Writer/Pathfinder.php#L55-L89
phpDocumentor/phpDocumentor2
src/phpDocumentor/Transformer/Transformer.php
Transformer.setTarget
public function setTarget(string $target): void { $path = realpath($target); if (false === $path) { if (@mkdir($target, 0755, true)) { $path = realpath($target); } else { throw new InvalidArgumentException( 'Target directory (' . $target . ') does not exist and could not be created' ); } } if (!is_dir($path) || !is_writable($path)) { throw new InvalidArgumentException('Given target (' . $target . ') is not a writable directory'); } $this->target = $path; }
php
public function setTarget(string $target): void { $path = realpath($target); if (false === $path) { if (@mkdir($target, 0755, true)) { $path = realpath($target); } else { throw new InvalidArgumentException( 'Target directory (' . $target . ') does not exist and could not be created' ); } } if (!is_dir($path) || !is_writable($path)) { throw new InvalidArgumentException('Given target (' . $target . ') is not a writable directory'); } $this->target = $path; }
[ "public", "function", "setTarget", "(", "string", "$", "target", ")", ":", "void", "{", "$", "path", "=", "realpath", "(", "$", "target", ")", ";", "if", "(", "false", "===", "$", "path", ")", "{", "if", "(", "@", "mkdir", "(", "$", "target", ",", "0755", ",", "true", ")", ")", "{", "$", "path", "=", "realpath", "(", "$", "target", ")", ";", "}", "else", "{", "throw", "new", "InvalidArgumentException", "(", "'Target directory ('", ".", "$", "target", ".", "') does not exist and could not be created'", ")", ";", "}", "}", "if", "(", "!", "is_dir", "(", "$", "path", ")", "||", "!", "is_writable", "(", "$", "path", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Given target ('", ".", "$", "target", ".", "') is not a writable directory'", ")", ";", "}", "$", "this", "->", "target", "=", "$", "path", ";", "}" ]
Sets the target location where to output the artifacts. @param string $target The target location where to output the artifacts. @throws InvalidArgumentException if the target is not a valid writable directory.
[ "Sets", "the", "target", "location", "where", "to", "output", "the", "artifacts", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Transformer/Transformer.php#L91-L109
phpDocumentor/phpDocumentor2
src/phpDocumentor/Plugin/Scrybe/ServiceProvider.php
ServiceProvider.register
public function register(Container $app): void { $app[self::TEMPLATE_FOLDER] = __DIR__ . '/data/templates/'; $app[self::CONVERTERS] = [ '\phpDocumentor\Plugin\Scrybe\Converter\RestructuredText\ToHtml' => [Format::RST, Format::HTML], ]; $app[self::FORMATS] = function () { return new Converter\Format\Collection(); }; $app[self::CONVERTER_DEFINITION_FACTORY] = function ($container) { return new Factory($container[self::FORMATS]); }; $app[self::CONVERTER_FACTORY] = function ($container) { return new Converter\Factory( $container['converters'], $container['converter_definition_factory'], $container['monolog'] ); }; $app[self::TEMPLATE_FACTORY] = function ($app) { return new Template\Factory( ['twig' => new Template\Twig($app[self::TEMPLATE_FOLDER])] ); }; $this->addCommands($app); }
php
public function register(Container $app): void { $app[self::TEMPLATE_FOLDER] = __DIR__ . '/data/templates/'; $app[self::CONVERTERS] = [ '\phpDocumentor\Plugin\Scrybe\Converter\RestructuredText\ToHtml' => [Format::RST, Format::HTML], ]; $app[self::FORMATS] = function () { return new Converter\Format\Collection(); }; $app[self::CONVERTER_DEFINITION_FACTORY] = function ($container) { return new Factory($container[self::FORMATS]); }; $app[self::CONVERTER_FACTORY] = function ($container) { return new Converter\Factory( $container['converters'], $container['converter_definition_factory'], $container['monolog'] ); }; $app[self::TEMPLATE_FACTORY] = function ($app) { return new Template\Factory( ['twig' => new Template\Twig($app[self::TEMPLATE_FOLDER])] ); }; $this->addCommands($app); }
[ "public", "function", "register", "(", "Container", "$", "app", ")", ":", "void", "{", "$", "app", "[", "self", "::", "TEMPLATE_FOLDER", "]", "=", "__DIR__", ".", "'/data/templates/'", ";", "$", "app", "[", "self", "::", "CONVERTERS", "]", "=", "[", "'\\phpDocumentor\\Plugin\\Scrybe\\Converter\\RestructuredText\\ToHtml'", "=>", "[", "Format", "::", "RST", ",", "Format", "::", "HTML", "]", ",", "]", ";", "$", "app", "[", "self", "::", "FORMATS", "]", "=", "function", "(", ")", "{", "return", "new", "Converter", "\\", "Format", "\\", "Collection", "(", ")", ";", "}", ";", "$", "app", "[", "self", "::", "CONVERTER_DEFINITION_FACTORY", "]", "=", "function", "(", "$", "container", ")", "{", "return", "new", "Factory", "(", "$", "container", "[", "self", "::", "FORMATS", "]", ")", ";", "}", ";", "$", "app", "[", "self", "::", "CONVERTER_FACTORY", "]", "=", "function", "(", "$", "container", ")", "{", "return", "new", "Converter", "\\", "Factory", "(", "$", "container", "[", "'converters'", "]", ",", "$", "container", "[", "'converter_definition_factory'", "]", ",", "$", "container", "[", "'monolog'", "]", ")", ";", "}", ";", "$", "app", "[", "self", "::", "TEMPLATE_FACTORY", "]", "=", "function", "(", "$", "app", ")", "{", "return", "new", "Template", "\\", "Factory", "(", "[", "'twig'", "=>", "new", "Template", "\\", "Twig", "(", "$", "app", "[", "self", "::", "TEMPLATE_FOLDER", "]", ")", "]", ")", ";", "}", ";", "$", "this", "->", "addCommands", "(", "$", "app", ")", ";", "}" ]
Registers services on the given app. @param Container $app An Application instance.
[ "Registers", "services", "on", "the", "given", "app", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Scrybe/ServiceProvider.php#L49-L79
phpDocumentor/phpDocumentor2
src/phpDocumentor/Parser/Middleware/EmittingMiddleware.php
EmittingMiddleware.execute
public function execute(Command $command, callable $next) { if (class_exists('phpDocumentor\Event\Dispatcher')) { Dispatcher::getInstance()->dispatch( 'parser.file.pre', PreFileEvent::createInstance($this)->setFile($command->getFile()->path()) ); } return $next($command); }
php
public function execute(Command $command, callable $next) { if (class_exists('phpDocumentor\Event\Dispatcher')) { Dispatcher::getInstance()->dispatch( 'parser.file.pre', PreFileEvent::createInstance($this)->setFile($command->getFile()->path()) ); } return $next($command); }
[ "public", "function", "execute", "(", "Command", "$", "command", ",", "callable", "$", "next", ")", "{", "if", "(", "class_exists", "(", "'phpDocumentor\\Event\\Dispatcher'", ")", ")", "{", "Dispatcher", "::", "getInstance", "(", ")", "->", "dispatch", "(", "'parser.file.pre'", ",", "PreFileEvent", "::", "createInstance", "(", "$", "this", ")", "->", "setFile", "(", "$", "command", "->", "getFile", "(", ")", "->", "path", "(", ")", ")", ")", ";", "}", "return", "$", "next", "(", "$", "command", ")", ";", "}" ]
Executes this middle ware class. @param callable $next @return object
[ "Executes", "this", "middle", "ware", "class", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Parser/Middleware/EmittingMiddleware.php#L31-L41
phpDocumentor/phpDocumentor2
src/phpDocumentor/Infrastructure/JmsSerializer/FileCache.php
FileCache.putClassMetadataInCache
public function putClassMetadataInCache(ClassMetadata $metadata) { $path = $this->getFileName($metadata); if (!is_writable(dirname($path))) { throw new \RuntimeException("Cache file {$path} is not writable."); } if (false === (@file_put_contents( $path, '<?php return unserialize(' . var_export(serialize($metadata), true) . ');' ) )) { throw new \RuntimeException("Can't not write new cache file to {$path}"); } // Let's not break filesystems which do not support chmod. @chmod($path, 0666 & ~umask()); }
php
public function putClassMetadataInCache(ClassMetadata $metadata) { $path = $this->getFileName($metadata); if (!is_writable(dirname($path))) { throw new \RuntimeException("Cache file {$path} is not writable."); } if (false === (@file_put_contents( $path, '<?php return unserialize(' . var_export(serialize($metadata), true) . ');' ) )) { throw new \RuntimeException("Can't not write new cache file to {$path}"); } @chmod($path, 0666 & ~umask()); }
[ "public", "function", "putClassMetadataInCache", "(", "ClassMetadata", "$", "metadata", ")", "{", "$", "path", "=", "$", "this", "->", "getFileName", "(", "$", "metadata", ")", ";", "if", "(", "!", "is_writable", "(", "dirname", "(", "$", "path", ")", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "\"Cache file {$path} is not writable.\"", ")", ";", "}", "if", "(", "false", "===", "(", "@", "file_put_contents", "(", "$", "path", ",", "'<?php return unserialize('", ".", "var_export", "(", "serialize", "(", "$", "metadata", ")", ",", "true", ")", ".", "');'", ")", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "\"Can't not write new cache file to {$path}\"", ")", ";", "}", "// Let's not break filesystems which do not support chmod.", "@", "chmod", "(", "$", "path", ",", "0666", "&", "~", "umask", "(", ")", ")", ";", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Infrastructure/JmsSerializer/FileCache.php#L58-L76
phpDocumentor/phpDocumentor2
src/phpDocumentor/Infrastructure/JmsSerializer/FileCache.php
FileCache.evictClassMetadataFromCache
public function evictClassMetadataFromCache(\ReflectionClass $class) { $path = $this->dir . '/' . strtr($class->name, '\\', '-') . '.cache.php'; if (file_exists($path)) { unlink($path); } }
php
public function evictClassMetadataFromCache(\ReflectionClass $class) { $path = $this->dir . '/' . strtr($class->name, '\\', '-') . '.cache.php'; if (file_exists($path)) { unlink($path); } }
[ "public", "function", "evictClassMetadataFromCache", "(", "\\", "ReflectionClass", "$", "class", ")", "{", "$", "path", "=", "$", "this", "->", "dir", ".", "'/'", ".", "strtr", "(", "$", "class", "->", "name", ",", "'\\\\'", ",", "'-'", ")", ".", "'.cache.php'", ";", "if", "(", "file_exists", "(", "$", "path", ")", ")", "{", "unlink", "(", "$", "path", ")", ";", "}", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Infrastructure/JmsSerializer/FileCache.php#L81-L87
phpDocumentor/phpDocumentor2
src/phpDocumentor/Compiler/Pass/PackageTreeBuilder.php
PackageTreeBuilder.createPackageDescriptorTree
protected function createPackageDescriptorTree(ProjectDescriptor $project, string $packageName): void { $parts = explode('\\', ltrim($packageName, '\\')); $fqnn = ''; // this method does not use recursion to traverse the tree but uses a pointer that will be overridden with the // next item that is to be traversed (child package) at the end of the loop. /** @var PackageDescriptor $pointer */ $pointer = $project->getIndexes()->packages['\\']; foreach ($parts as $part) { $fqnn .= '\\' . $part; if ($pointer->getChildren()->get($part)) { $pointer = $pointer->getChildren()->get($part); continue; } // package does not exist, create it $interimPackageDescriptor = new PackageDescriptor(); $interimPackageDescriptor->setParent($pointer); $interimPackageDescriptor->setName($part); $interimPackageDescriptor->setFullyQualifiedStructuralElementName($fqnn); // add to the pointer's list of children $pointer->getChildren()->set($part ?: 'UNKNOWN', $interimPackageDescriptor); // add to index $project->getIndexes()->packages[$fqnn] = $interimPackageDescriptor; // move pointer forward $pointer = $interimPackageDescriptor; } }
php
protected function createPackageDescriptorTree(ProjectDescriptor $project, string $packageName): void { $parts = explode('\\', ltrim($packageName, '\\')); $fqnn = ''; $pointer = $project->getIndexes()->packages['\\']; foreach ($parts as $part) { $fqnn .= '\\' . $part; if ($pointer->getChildren()->get($part)) { $pointer = $pointer->getChildren()->get($part); continue; } $interimPackageDescriptor = new PackageDescriptor(); $interimPackageDescriptor->setParent($pointer); $interimPackageDescriptor->setName($part); $interimPackageDescriptor->setFullyQualifiedStructuralElementName($fqnn); $pointer->getChildren()->set($part ?: 'UNKNOWN', $interimPackageDescriptor); $project->getIndexes()->packages[$fqnn] = $interimPackageDescriptor; $pointer = $interimPackageDescriptor; } }
[ "protected", "function", "createPackageDescriptorTree", "(", "ProjectDescriptor", "$", "project", ",", "string", "$", "packageName", ")", ":", "void", "{", "$", "parts", "=", "explode", "(", "'\\\\'", ",", "ltrim", "(", "$", "packageName", ",", "'\\\\'", ")", ")", ";", "$", "fqnn", "=", "''", ";", "// this method does not use recursion to traverse the tree but uses a pointer that will be overridden with the", "// next item that is to be traversed (child package) at the end of the loop.", "/** @var PackageDescriptor $pointer */", "$", "pointer", "=", "$", "project", "->", "getIndexes", "(", ")", "->", "packages", "[", "'\\\\'", "]", ";", "foreach", "(", "$", "parts", "as", "$", "part", ")", "{", "$", "fqnn", ".=", "'\\\\'", ".", "$", "part", ";", "if", "(", "$", "pointer", "->", "getChildren", "(", ")", "->", "get", "(", "$", "part", ")", ")", "{", "$", "pointer", "=", "$", "pointer", "->", "getChildren", "(", ")", "->", "get", "(", "$", "part", ")", ";", "continue", ";", "}", "// package does not exist, create it", "$", "interimPackageDescriptor", "=", "new", "PackageDescriptor", "(", ")", ";", "$", "interimPackageDescriptor", "->", "setParent", "(", "$", "pointer", ")", ";", "$", "interimPackageDescriptor", "->", "setName", "(", "$", "part", ")", ";", "$", "interimPackageDescriptor", "->", "setFullyQualifiedStructuralElementName", "(", "$", "fqnn", ")", ";", "// add to the pointer's list of children", "$", "pointer", "->", "getChildren", "(", ")", "->", "set", "(", "$", "part", "?", ":", "'UNKNOWN'", ",", "$", "interimPackageDescriptor", ")", ";", "// add to index", "$", "project", "->", "getIndexes", "(", ")", "->", "packages", "[", "$", "fqnn", "]", "=", "$", "interimPackageDescriptor", ";", "// move pointer forward", "$", "pointer", "=", "$", "interimPackageDescriptor", ";", "}", "}" ]
Creates a tree of PackageDescriptors based on the provided FQNN (package name). This method will examine the package name and create a package descriptor for each part of the FQNN if it doesn't exist in the packages field of the current package (starting with the root Package in the Project Descriptor), As an intended side effect this method also populates the *elements* index of the ProjectDescriptor with all created PackageDescriptors. Each index key is prefixed with a tilde (~) so that it will not conflict with other FQSEN's, such as classes or interfaces. @param string $packageName A FQNN of the package (and parents) to create. @see ProjectDescriptor::getPackage() for the root package. @see PackageDescriptor::getChildren() for the child packages of a given package.
[ "Creates", "a", "tree", "of", "PackageDescriptors", "based", "on", "the", "provided", "FQNN", "(", "package", "name", ")", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Compiler/Pass/PackageTreeBuilder.php#L128-L160
phpDocumentor/phpDocumentor2
src/phpDocumentor/Application/Console/Command/Project/RunCommand.php
RunCommand.configure
protected function configure(): void { $this->setName('project:run') ->setAliases(['run']) ->setDescription( 'Parses and transforms the given files to a specified location' ) ->setHelp( <<<HELP phpDocumentor creates documentation from PHP source files. The simplest way to use it is: <info>$ phpdoc run -d [directory to parse] -t [output directory]</info> This will parse every file ending with .php, .php3 and .phtml in <directory to parse> and then output a HTML site containing easily readable documentation in <output directory>. phpDocumentor will try to look for a phpdoc.dist.xml or phpdoc.xml file in your current working directory and use that to override the default settings if present. In the configuration file can you specify the same settings (and more) as the command line provides. <comment>Other commands</comment> In addition to this command phpDocumentor also supports additional commands: <comment>Available commands:</comment> <info> help list parse run transform <comment>project</comment> project:parse project:run project:transform <comment>template</comment> template:generate template:list template:package</info> You can get a more detailed listing of the commands using the <info>list</info> command and get help by prepending the word <info>help</info> to the command name. HELP ) ->addOption( 'target', 't', InputOption::VALUE_OPTIONAL, 'Path where to store the generated output' ) ->addOption( 'cache-folder', null, InputOption::VALUE_OPTIONAL, 'Path where to store the cache files' ) ->addOption( 'filename', 'f', InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'Comma-separated list of files to parse. The wildcards ? and * are supported' ) ->addOption( 'directory', 'd', InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'Comma-separated list of directories to (recursively) parse' ) ->addOption( 'encoding', null, InputOption::VALUE_OPTIONAL, 'encoding to be used to interpret source files with' ) ->addOption( 'extensions', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'Comma-separated list of extensions to parse, defaults to php, php3 and phtml' ) ->addOption( 'ignore', 'i', InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'Comma-separated list of file(s) and directories (relative to the source-code directory) that will be ' . 'ignored. Wildcards * and ? are supported' ) ->addOption( 'ignore-tags', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'Comma-separated list of tags that will be ignored, defaults to none. package, subpackage and ignore ' . 'may not be ignored.' ) ->addOption( 'hidden', null, InputOption::VALUE_NONE, 'Use this option to tell phpDocumentor to parse files and directories that begin with a period (.), ' . 'by default these are ignored' ) ->addOption( 'ignore-symlinks', null, InputOption::VALUE_NONE, 'Ignore symlinks to other files or directories, default is on' ) ->addOption( 'markers', 'm', InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'Comma-separated list of markers/tags to filter' ) ->addOption( 'title', null, InputOption::VALUE_OPTIONAL, 'Sets the title for this project; default is the phpDocumentor logo' ) ->addOption( 'force', null, InputOption::VALUE_NONE, 'Forces a full build of the documentation, does not increment existing documentation' ) ->addOption( 'validate', null, InputOption::VALUE_NONE, 'Validates every processed file using PHP Lint, costs a lot of performance' ) ->addOption( 'visibility', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'Specifies the parse visibility that should be displayed in the documentation (comma separated e.g. ' . '"public,protected")' ) ->addOption( 'defaultpackagename', null, InputOption::VALUE_OPTIONAL, 'Name to use for the default package.', 'Default' ) ->addOption( 'sourcecode', null, InputOption::VALUE_NONE, 'Whether to include syntax highlighted source code' ) ->addOption( 'template', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'Name of the template to use (optional)' ) ->addOption( 'parseprivate', null, InputOption::VALUE_NONE, 'Whether to parse DocBlocks marked with @internal tag' ); parent::configure(); }
php
protected function configure(): void { $this->setName('project:run') ->setAliases(['run']) ->setDescription( 'Parses and transforms the given files to a specified location' ) ->setHelp( <<<HELP phpDocumentor creates documentation from PHP source files. The simplest way to use it is: <info>$ phpdoc run -d [directory to parse] -t [output directory]</info> This will parse every file ending with .php, .php3 and .phtml in <directory to parse> and then output a HTML site containing easily readable documentation in <output directory>. phpDocumentor will try to look for a phpdoc.dist.xml or phpdoc.xml file in your current working directory and use that to override the default settings if present. In the configuration file can you specify the same settings (and more) as the command line provides. <comment>Other commands</comment> In addition to this command phpDocumentor also supports additional commands: <comment>Available commands:</comment> <info> help list parse run transform <comment>project</comment> project:parse project:run project:transform <comment>template</comment> template:generate template:list template:package</info> You can get a more detailed listing of the commands using the <info>list</info> command and get help by prepending the word <info>help</info> to the command name. HELP ) ->addOption( 'target', 't', InputOption::VALUE_OPTIONAL, 'Path where to store the generated output' ) ->addOption( 'cache-folder', null, InputOption::VALUE_OPTIONAL, 'Path where to store the cache files' ) ->addOption( 'filename', 'f', InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'Comma-separated list of files to parse. The wildcards ? and * are supported' ) ->addOption( 'directory', 'd', InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'Comma-separated list of directories to (recursively) parse' ) ->addOption( 'encoding', null, InputOption::VALUE_OPTIONAL, 'encoding to be used to interpret source files with' ) ->addOption( 'extensions', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'Comma-separated list of extensions to parse, defaults to php, php3 and phtml' ) ->addOption( 'ignore', 'i', InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'Comma-separated list of file(s) and directories (relative to the source-code directory) that will be ' . 'ignored. Wildcards * and ? are supported' ) ->addOption( 'ignore-tags', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'Comma-separated list of tags that will be ignored, defaults to none. package, subpackage and ignore ' . 'may not be ignored.' ) ->addOption( 'hidden', null, InputOption::VALUE_NONE, 'Use this option to tell phpDocumentor to parse files and directories that begin with a period (.), ' . 'by default these are ignored' ) ->addOption( 'ignore-symlinks', null, InputOption::VALUE_NONE, 'Ignore symlinks to other files or directories, default is on' ) ->addOption( 'markers', 'm', InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'Comma-separated list of markers/tags to filter' ) ->addOption( 'title', null, InputOption::VALUE_OPTIONAL, 'Sets the title for this project; default is the phpDocumentor logo' ) ->addOption( 'force', null, InputOption::VALUE_NONE, 'Forces a full build of the documentation, does not increment existing documentation' ) ->addOption( 'validate', null, InputOption::VALUE_NONE, 'Validates every processed file using PHP Lint, costs a lot of performance' ) ->addOption( 'visibility', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'Specifies the parse visibility that should be displayed in the documentation (comma separated e.g. ' . '"public,protected")' ) ->addOption( 'defaultpackagename', null, InputOption::VALUE_OPTIONAL, 'Name to use for the default package.', 'Default' ) ->addOption( 'sourcecode', null, InputOption::VALUE_NONE, 'Whether to include syntax highlighted source code' ) ->addOption( 'template', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'Name of the template to use (optional)' ) ->addOption( 'parseprivate', null, InputOption::VALUE_NONE, 'Whether to parse DocBlocks marked with @internal tag' ); parent::configure(); }
[ "protected", "function", "configure", "(", ")", ":", "void", "{", "$", "this", "->", "setName", "(", "'project:run'", ")", "->", "setAliases", "(", "[", "'run'", "]", ")", "->", "setDescription", "(", "'Parses and transforms the given files to a specified location'", ")", "->", "setHelp", "(", "\n <<<HELP\n phpDocumentor creates documentation from PHP source files. The simplest way\n to use it is:\n \n <info>$ phpdoc run -d [directory to parse] -t [output directory]</info>\n \n This will parse every file ending with .php, .php3 and .phtml in <directory\n to parse> and then output a HTML site containing easily readable documentation\n in <output directory>.\n \n phpDocumentor will try to look for a phpdoc.dist.xml or phpdoc.xml file in your\n current working directory and use that to override the default settings if\n present. In the configuration file can you specify the same settings (and\n more) as the command line provides.\n \n <comment>Other commands</comment>\n In addition to this command phpDocumentor also supports additional commands:\n \n <comment>Available commands:</comment>\n <info> help\n list\n parse\n run\n transform\n <comment>project</comment>\n project:parse\n project:run\n project:transform\n <comment>template</comment>\n template:generate\n template:list\n template:package</info>\n \n You can get a more detailed listing of the commands using the <info>list</info>\n command and get help by prepending the word <info>help</info> to the command\n name.\nHELP", ")", "->", "addOption", "(", "'target'", ",", "'t'", ",", "InputOption", "::", "VALUE_OPTIONAL", ",", "'Path where to store the generated output'", ")", "->", "addOption", "(", "'cache-folder'", ",", "null", ",", "InputOption", "::", "VALUE_OPTIONAL", ",", "'Path where to store the cache files'", ")", "->", "addOption", "(", "'filename'", ",", "'f'", ",", "InputOption", "::", "VALUE_OPTIONAL", "|", "InputOption", "::", "VALUE_IS_ARRAY", ",", "'Comma-separated list of files to parse. The wildcards ? and * are supported'", ")", "->", "addOption", "(", "'directory'", ",", "'d'", ",", "InputOption", "::", "VALUE_OPTIONAL", "|", "InputOption", "::", "VALUE_IS_ARRAY", ",", "'Comma-separated list of directories to (recursively) parse'", ")", "->", "addOption", "(", "'encoding'", ",", "null", ",", "InputOption", "::", "VALUE_OPTIONAL", ",", "'encoding to be used to interpret source files with'", ")", "->", "addOption", "(", "'extensions'", ",", "null", ",", "InputOption", "::", "VALUE_OPTIONAL", "|", "InputOption", "::", "VALUE_IS_ARRAY", ",", "'Comma-separated list of extensions to parse, defaults to php, php3 and phtml'", ")", "->", "addOption", "(", "'ignore'", ",", "'i'", ",", "InputOption", "::", "VALUE_OPTIONAL", "|", "InputOption", "::", "VALUE_IS_ARRAY", ",", "'Comma-separated list of file(s) and directories (relative to the source-code directory) that will be '", ".", "'ignored. Wildcards * and ? are supported'", ")", "->", "addOption", "(", "'ignore-tags'", ",", "null", ",", "InputOption", "::", "VALUE_OPTIONAL", "|", "InputOption", "::", "VALUE_IS_ARRAY", ",", "'Comma-separated list of tags that will be ignored, defaults to none. package, subpackage and ignore '", ".", "'may not be ignored.'", ")", "->", "addOption", "(", "'hidden'", ",", "null", ",", "InputOption", "::", "VALUE_NONE", ",", "'Use this option to tell phpDocumentor to parse files and directories that begin with a period (.), '", ".", "'by default these are ignored'", ")", "->", "addOption", "(", "'ignore-symlinks'", ",", "null", ",", "InputOption", "::", "VALUE_NONE", ",", "'Ignore symlinks to other files or directories, default is on'", ")", "->", "addOption", "(", "'markers'", ",", "'m'", ",", "InputOption", "::", "VALUE_OPTIONAL", "|", "InputOption", "::", "VALUE_IS_ARRAY", ",", "'Comma-separated list of markers/tags to filter'", ")", "->", "addOption", "(", "'title'", ",", "null", ",", "InputOption", "::", "VALUE_OPTIONAL", ",", "'Sets the title for this project; default is the phpDocumentor logo'", ")", "->", "addOption", "(", "'force'", ",", "null", ",", "InputOption", "::", "VALUE_NONE", ",", "'Forces a full build of the documentation, does not increment existing documentation'", ")", "->", "addOption", "(", "'validate'", ",", "null", ",", "InputOption", "::", "VALUE_NONE", ",", "'Validates every processed file using PHP Lint, costs a lot of performance'", ")", "->", "addOption", "(", "'visibility'", ",", "null", ",", "InputOption", "::", "VALUE_OPTIONAL", "|", "InputOption", "::", "VALUE_IS_ARRAY", ",", "'Specifies the parse visibility that should be displayed in the documentation (comma separated e.g. '", ".", "'\"public,protected\")'", ")", "->", "addOption", "(", "'defaultpackagename'", ",", "null", ",", "InputOption", "::", "VALUE_OPTIONAL", ",", "'Name to use for the default package.'", ",", "'Default'", ")", "->", "addOption", "(", "'sourcecode'", ",", "null", ",", "InputOption", "::", "VALUE_NONE", ",", "'Whether to include syntax highlighted source code'", ")", "->", "addOption", "(", "'template'", ",", "null", ",", "InputOption", "::", "VALUE_OPTIONAL", "|", "InputOption", "::", "VALUE_IS_ARRAY", ",", "'Name of the template to use (optional)'", ")", "->", "addOption", "(", "'parseprivate'", ",", "null", ",", "InputOption", "::", "VALUE_NONE", ",", "'Whether to parse DocBlocks marked with @internal tag'", ")", ";", "parent", "::", "configure", "(", ")", ";", "}" ]
Initializes this command and sets the name, description, options and arguments.
[ "Initializes", "this", "command", "and", "sets", "the", "name", "description", "options", "and", "arguments", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Application/Console/Command/Project/RunCommand.php#L86-L253
phpDocumentor/phpDocumentor2
src/phpDocumentor/Application/Console/Command/Project/RunCommand.php
RunCommand.execute
protected function execute(InputInterface $input, OutputInterface $output): int { $output->writeln('phpDocumentor ' . $this->getApplication()->getVersion()); $output->writeln(''); $this->observeProgressToShowProgressBars($output); $pipeLine = $this->pipeline; $pipeLine($input->getOptions()); if ($output->getVerbosity() === OutputInterface::VERBOSITY_DEBUG) { file_put_contents('ast.dump', serialize($this->projectDescriptorBuilder->getProjectDescriptor())); } $output->writeln(''); $output->writeln('All done!'); return 0; }
php
protected function execute(InputInterface $input, OutputInterface $output): int { $output->writeln('phpDocumentor ' . $this->getApplication()->getVersion()); $output->writeln(''); $this->observeProgressToShowProgressBars($output); $pipeLine = $this->pipeline; $pipeLine($input->getOptions()); if ($output->getVerbosity() === OutputInterface::VERBOSITY_DEBUG) { file_put_contents('ast.dump', serialize($this->projectDescriptorBuilder->getProjectDescriptor())); } $output->writeln(''); $output->writeln('All done!'); return 0; }
[ "protected", "function", "execute", "(", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ")", ":", "int", "{", "$", "output", "->", "writeln", "(", "'phpDocumentor '", ".", "$", "this", "->", "getApplication", "(", ")", "->", "getVersion", "(", ")", ")", ";", "$", "output", "->", "writeln", "(", "''", ")", ";", "$", "this", "->", "observeProgressToShowProgressBars", "(", "$", "output", ")", ";", "$", "pipeLine", "=", "$", "this", "->", "pipeline", ";", "$", "pipeLine", "(", "$", "input", "->", "getOptions", "(", ")", ")", ";", "if", "(", "$", "output", "->", "getVerbosity", "(", ")", "===", "OutputInterface", "::", "VERBOSITY_DEBUG", ")", "{", "file_put_contents", "(", "'ast.dump'", ",", "serialize", "(", "$", "this", "->", "projectDescriptorBuilder", "->", "getProjectDescriptor", "(", ")", ")", ")", ";", "}", "$", "output", "->", "writeln", "(", "''", ")", ";", "$", "output", "->", "writeln", "(", "'All done!'", ")", ";", "return", "0", ";", "}" ]
Executes the business logic involved with this command.
[ "Executes", "the", "business", "logic", "involved", "with", "this", "command", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Application/Console/Command/Project/RunCommand.php#L258-L276
phpDocumentor/phpDocumentor2
src/phpDocumentor/Plugin/Core/Transformer/Writer/FileIo.php
FileIo.transform
public function transform(ProjectDescriptor $project, Transformation $transformation) { $artifact = $transformation->getTransformer()->getTarget() . DIRECTORY_SEPARATOR . $transformation->getArtifact(); $transformation->setArtifact($artifact); $method = 'executeQuery' . ucfirst($transformation->getQuery()); if (!method_exists($this, $method)) { throw new \InvalidArgumentException( 'The query ' . $method . ' is not supported by the FileIo writer, supported operation is "copy"' ); } $this->{$method}($transformation); }
php
public function transform(ProjectDescriptor $project, Transformation $transformation) { $artifact = $transformation->getTransformer()->getTarget() . DIRECTORY_SEPARATOR . $transformation->getArtifact(); $transformation->setArtifact($artifact); $method = 'executeQuery' . ucfirst($transformation->getQuery()); if (!method_exists($this, $method)) { throw new \InvalidArgumentException( 'The query ' . $method . ' is not supported by the FileIo writer, supported operation is "copy"' ); } $this->{$method}($transformation); }
[ "public", "function", "transform", "(", "ProjectDescriptor", "$", "project", ",", "Transformation", "$", "transformation", ")", "{", "$", "artifact", "=", "$", "transformation", "->", "getTransformer", "(", ")", "->", "getTarget", "(", ")", ".", "DIRECTORY_SEPARATOR", ".", "$", "transformation", "->", "getArtifact", "(", ")", ";", "$", "transformation", "->", "setArtifact", "(", "$", "artifact", ")", ";", "$", "method", "=", "'executeQuery'", ".", "ucfirst", "(", "$", "transformation", "->", "getQuery", "(", ")", ")", ";", "if", "(", "!", "method_exists", "(", "$", "this", ",", "$", "method", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'The query '", ".", "$", "method", ".", "' is not supported by the FileIo writer, supported operation is \"copy\"'", ")", ";", "}", "$", "this", "->", "{", "$", "method", "}", "(", "$", "transformation", ")", ";", "}" ]
Invokes the query method contained in this class. @param ProjectDescriptor $project Document containing the structure. @param Transformation $transformation Transformation to execute. @throws \InvalidArgumentException if the query is not supported.
[ "Invokes", "the", "query", "method", "contained", "in", "this", "class", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Core/Transformer/Writer/FileIo.php#L45-L59
phpDocumentor/phpDocumentor2
src/phpDocumentor/Plugin/Scrybe/Converter/BaseConverter.php
BaseConverter.setOption
public function setOption(string $name, string $value): void { $this->options[$name] = $value; }
php
public function setOption(string $name, string $value): void { $this->options[$name] = $value; }
[ "public", "function", "setOption", "(", "string", "$", "name", ",", "string", "$", "value", ")", ":", "void", "{", "$", "this", "->", "options", "[", "$", "name", "]", "=", "$", "value", ";", "}" ]
Sets an option with the given name.
[ "Sets", "an", "option", "with", "the", "given", "name", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Scrybe/Converter/BaseConverter.php#L106-L109
phpDocumentor/phpDocumentor2
src/phpDocumentor/Plugin/Scrybe/Converter/BaseConverter.php
BaseConverter.getDestinationFilename
protected function getDestinationFilename(Metadata\TableOfContents\File $file): string { return $this->definition->getOutputFormat()->convertFilename($file->getRealPath()); }
php
protected function getDestinationFilename(Metadata\TableOfContents\File $file): string { return $this->definition->getOutputFormat()->convertFilename($file->getRealPath()); }
[ "protected", "function", "getDestinationFilename", "(", "Metadata", "\\", "TableOfContents", "\\", "File", "$", "file", ")", ":", "string", "{", "return", "$", "this", "->", "definition", "->", "getOutputFormat", "(", ")", "->", "convertFilename", "(", "$", "file", "->", "getRealPath", "(", ")", ")", ";", "}" ]
Returns the filename used for the output path.
[ "Returns", "the", "filename", "used", "for", "the", "output", "path", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Scrybe/Converter/BaseConverter.php#L199-L202
phpDocumentor/phpDocumentor2
src/phpDocumentor/Plugin/Scrybe/Converter/BaseConverter.php
BaseConverter.getDestinationFilenameRelativeToProjectRoot
public function getDestinationFilenameRelativeToProjectRoot(Metadata\TableOfContents\File $file): string { return substr($this->getDestinationFilename($file), strlen($this->fileset->getProjectRoot())); }
php
public function getDestinationFilenameRelativeToProjectRoot(Metadata\TableOfContents\File $file): string { return substr($this->getDestinationFilename($file), strlen($this->fileset->getProjectRoot())); }
[ "public", "function", "getDestinationFilenameRelativeToProjectRoot", "(", "Metadata", "\\", "TableOfContents", "\\", "File", "$", "file", ")", ":", "string", "{", "return", "substr", "(", "$", "this", "->", "getDestinationFilename", "(", "$", "file", ")", ",", "strlen", "(", "$", "this", "->", "fileset", "->", "getProjectRoot", "(", ")", ")", ")", ";", "}" ]
Returns the filename relative to the Project Root of the fileset.
[ "Returns", "the", "filename", "relative", "to", "the", "Project", "Root", "of", "the", "fileset", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Scrybe/Converter/BaseConverter.php#L207-L210
phpDocumentor/phpDocumentor2
src/phpDocumentor/Plugin/Graphs/Writer/Graph.php
Graph.createEdge
protected function createEdge($graph, $from_name, $to) { $to_name = (string) ($to instanceof DescriptorAbstract ? $to->getFullyQualifiedStructuralElementName() : $to); if (!isset($this->nodeCache[$from_name])) { $namespaceParts = explode('\\', $from_name); $this->nodeCache[$from_name] = $this->createEmptyNode( array_pop($namespaceParts), $this->createNamespaceGraph($from_name) ); } if (!isset($this->nodeCache[$to_name])) { $namespaceParts = explode('\\', $to_name); $this->nodeCache[$to_name] = $this->createEmptyNode( array_pop($namespaceParts), $this->createNamespaceGraph($to_name) ); } $fromNode = $this->nodeCache[$from_name]; $toNode = $this->nodeCache[$to_name]; if ($fromNode !== null && $toNode !== null) { return Edge::create($fromNode, $toNode); } return null; }
php
protected function createEdge($graph, $from_name, $to) { $to_name = (string) ($to instanceof DescriptorAbstract ? $to->getFullyQualifiedStructuralElementName() : $to); if (!isset($this->nodeCache[$from_name])) { $namespaceParts = explode('\\', $from_name); $this->nodeCache[$from_name] = $this->createEmptyNode( array_pop($namespaceParts), $this->createNamespaceGraph($from_name) ); } if (!isset($this->nodeCache[$to_name])) { $namespaceParts = explode('\\', $to_name); $this->nodeCache[$to_name] = $this->createEmptyNode( array_pop($namespaceParts), $this->createNamespaceGraph($to_name) ); } $fromNode = $this->nodeCache[$from_name]; $toNode = $this->nodeCache[$to_name]; if ($fromNode !== null && $toNode !== null) { return Edge::create($fromNode, $toNode); } return null; }
[ "protected", "function", "createEdge", "(", "$", "graph", ",", "$", "from_name", ",", "$", "to", ")", "{", "$", "to_name", "=", "(", "string", ")", "(", "$", "to", "instanceof", "DescriptorAbstract", "?", "$", "to", "->", "getFullyQualifiedStructuralElementName", "(", ")", ":", "$", "to", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "nodeCache", "[", "$", "from_name", "]", ")", ")", "{", "$", "namespaceParts", "=", "explode", "(", "'\\\\'", ",", "$", "from_name", ")", ";", "$", "this", "->", "nodeCache", "[", "$", "from_name", "]", "=", "$", "this", "->", "createEmptyNode", "(", "array_pop", "(", "$", "namespaceParts", ")", ",", "$", "this", "->", "createNamespaceGraph", "(", "$", "from_name", ")", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "this", "->", "nodeCache", "[", "$", "to_name", "]", ")", ")", "{", "$", "namespaceParts", "=", "explode", "(", "'\\\\'", ",", "$", "to_name", ")", ";", "$", "this", "->", "nodeCache", "[", "$", "to_name", "]", "=", "$", "this", "->", "createEmptyNode", "(", "array_pop", "(", "$", "namespaceParts", ")", ",", "$", "this", "->", "createNamespaceGraph", "(", "$", "to_name", ")", ")", ";", "}", "$", "fromNode", "=", "$", "this", "->", "nodeCache", "[", "$", "from_name", "]", ";", "$", "toNode", "=", "$", "this", "->", "nodeCache", "[", "$", "to_name", "]", ";", "if", "(", "$", "fromNode", "!==", "null", "&&", "$", "toNode", "!==", "null", ")", "{", "return", "Edge", "::", "create", "(", "$", "fromNode", ",", "$", "toNode", ")", ";", "}", "return", "null", ";", "}" ]
Creates a GraphViz Edge between two nodes. @param Graph $graph @param string $from_name @param string|ClassDescriptor|InterfaceDescriptor|TraitDescriptor $to @return Edge|null
[ "Creates", "a", "GraphViz", "Edge", "between", "two", "nodes", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Graphs/Writer/Graph.php#L154-L181
phpDocumentor/phpDocumentor2
src/phpDocumentor/Plugin/Graphs/Writer/Graph.php
Graph.buildNamespaceTree
protected function buildNamespaceTree(GraphVizGraph $graph, NamespaceDescriptor $namespace) { $full_namespace_name = (string) $namespace->getFullyQualifiedStructuralElementName(); if ($full_namespace_name === '\\') { $full_namespace_name = 'Global'; } $label = $namespace->getName() === '\\' ? 'Global' : $namespace->getName(); $sub_graph = $this->createGraphForNamespace($full_namespace_name, $label); $this->namespaceCache[$full_namespace_name] = $sub_graph; $elements = array_merge( $namespace->getClasses()->getAll(), $namespace->getInterfaces()->getAll(), $namespace->getTraits()->getAll() ); /** @var ClassDescriptor|InterfaceDescriptor|TraitDescriptor $sub_element */ foreach ($elements as $sub_element) { $node = Node::create( (string) $sub_element->getFullyQualifiedStructuralElementName(), $sub_element->getName() ) ->setShape('box') ->setFontName($this->nodeFont) ->setFontSize('11'); if ($sub_element instanceof ClassDescriptor && $sub_element->isAbstract()) { $node->setLabel('<«abstract»<br/>' . $sub_element->getName() . '>'); } //$full_name = $sub_element->getFullyQualifiedStructuralElementName(); //$node->setURL($this->class_paths[$full_name]); //$node->setTarget('_parent'); $this->nodeCache[(string) $sub_element->getFullyQualifiedStructuralElementName()] = $node; $sub_graph->setNode($node); } foreach ($namespace->getChildren()->getAll() as $element) { $this->buildNamespaceTree($sub_graph, $element); } $graph->addGraph($sub_graph); }
php
protected function buildNamespaceTree(GraphVizGraph $graph, NamespaceDescriptor $namespace) { $full_namespace_name = (string) $namespace->getFullyQualifiedStructuralElementName(); if ($full_namespace_name === '\\') { $full_namespace_name = 'Global'; } $label = $namespace->getName() === '\\' ? 'Global' : $namespace->getName(); $sub_graph = $this->createGraphForNamespace($full_namespace_name, $label); $this->namespaceCache[$full_namespace_name] = $sub_graph; $elements = array_merge( $namespace->getClasses()->getAll(), $namespace->getInterfaces()->getAll(), $namespace->getTraits()->getAll() ); foreach ($elements as $sub_element) { $node = Node::create( (string) $sub_element->getFullyQualifiedStructuralElementName(), $sub_element->getName() ) ->setShape('box') ->setFontName($this->nodeFont) ->setFontSize('11'); if ($sub_element instanceof ClassDescriptor && $sub_element->isAbstract()) { $node->setLabel('<«abstract»<br/>' . $sub_element->getName() . '>'); } $this->nodeCache[(string) $sub_element->getFullyQualifiedStructuralElementName()] = $node; $sub_graph->setNode($node); } foreach ($namespace->getChildren()->getAll() as $element) { $this->buildNamespaceTree($sub_graph, $element); } $graph->addGraph($sub_graph); }
[ "protected", "function", "buildNamespaceTree", "(", "GraphVizGraph", "$", "graph", ",", "NamespaceDescriptor", "$", "namespace", ")", "{", "$", "full_namespace_name", "=", "(", "string", ")", "$", "namespace", "->", "getFullyQualifiedStructuralElementName", "(", ")", ";", "if", "(", "$", "full_namespace_name", "===", "'\\\\'", ")", "{", "$", "full_namespace_name", "=", "'Global'", ";", "}", "$", "label", "=", "$", "namespace", "->", "getName", "(", ")", "===", "'\\\\'", "?", "'Global'", ":", "$", "namespace", "->", "getName", "(", ")", ";", "$", "sub_graph", "=", "$", "this", "->", "createGraphForNamespace", "(", "$", "full_namespace_name", ",", "$", "label", ")", ";", "$", "this", "->", "namespaceCache", "[", "$", "full_namespace_name", "]", "=", "$", "sub_graph", ";", "$", "elements", "=", "array_merge", "(", "$", "namespace", "->", "getClasses", "(", ")", "->", "getAll", "(", ")", ",", "$", "namespace", "->", "getInterfaces", "(", ")", "->", "getAll", "(", ")", ",", "$", "namespace", "->", "getTraits", "(", ")", "->", "getAll", "(", ")", ")", ";", "/** @var ClassDescriptor|InterfaceDescriptor|TraitDescriptor $sub_element */", "foreach", "(", "$", "elements", "as", "$", "sub_element", ")", "{", "$", "node", "=", "Node", "::", "create", "(", "(", "string", ")", "$", "sub_element", "->", "getFullyQualifiedStructuralElementName", "(", ")", ",", "$", "sub_element", "->", "getName", "(", ")", ")", "->", "setShape", "(", "'box'", ")", "->", "setFontName", "(", "$", "this", "->", "nodeFont", ")", "->", "setFontSize", "(", "'11'", ")", ";", "if", "(", "$", "sub_element", "instanceof", "ClassDescriptor", "&&", "$", "sub_element", "->", "isAbstract", "(", ")", ")", "{", "$", "node", "->", "setLabel", "(", "'<«abstract»<br/>' .", "$", "u", "b_element->", "ge", "tName()", " ", ".", "'", "');", "", "", "}", "//$full_name = $sub_element->getFullyQualifiedStructuralElementName();", "//$node->setURL($this->class_paths[$full_name]);", "//$node->setTarget('_parent');", "$", "this", "->", "nodeCache", "[", "(", "string", ")", "$", "sub_element", "->", "getFullyQualifiedStructuralElementName", "(", ")", "]", "=", "$", "node", ";", "$", "sub_graph", "->", "setNode", "(", "$", "node", ")", ";", "}", "foreach", "(", "$", "namespace", "->", "getChildren", "(", ")", "->", "getAll", "(", ")", "as", "$", "element", ")", "{", "$", "this", "->", "buildNamespaceTree", "(", "$", "sub_graph", ",", "$", "element", ")", ";", "}", "$", "graph", "->", "addGraph", "(", "$", "sub_graph", ")", ";", "}" ]
Builds a tree of namespace subgraphs with their classes associated.
[ "Builds", "a", "tree", "of", "namespace", "subgraphs", "with", "their", "classes", "associated", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Graphs/Writer/Graph.php#L235-L279
phpDocumentor/phpDocumentor2
src/phpDocumentor/Plugin/Graphs/Writer/Graph.php
Graph.createGraphForNamespace
protected function createGraphForNamespace($full_namespace_name, $label) { return GraphVizGraph::create('cluster_' . $full_namespace_name) ->setLabel($label) ->setStyle('rounded') ->setColor('gray') ->setFontColor('gray') ->setFontSize('11') ->setRankDir('LR'); }
php
protected function createGraphForNamespace($full_namespace_name, $label) { return GraphVizGraph::create('cluster_' . $full_namespace_name) ->setLabel($label) ->setStyle('rounded') ->setColor('gray') ->setFontColor('gray') ->setFontSize('11') ->setRankDir('LR'); }
[ "protected", "function", "createGraphForNamespace", "(", "$", "full_namespace_name", ",", "$", "label", ")", "{", "return", "GraphVizGraph", "::", "create", "(", "'cluster_'", ".", "$", "full_namespace_name", ")", "->", "setLabel", "(", "$", "label", ")", "->", "setStyle", "(", "'rounded'", ")", "->", "setColor", "(", "'gray'", ")", "->", "setFontColor", "(", "'gray'", ")", "->", "setFontSize", "(", "'11'", ")", "->", "setRankDir", "(", "'LR'", ")", ";", "}" ]
@param string $full_namespace_name @param string $label @return mixed
[ "@param", "string", "$full_namespace_name", "@param", "string", "$label" ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Graphs/Writer/Graph.php#L310-L319
phpDocumentor/phpDocumentor2
src/phpDocumentor/Descriptor/PropertyDescriptor.php
PropertyDescriptor.getInheritedElement
public function getInheritedElement() { /** @var ClassDescriptor|InterfaceDescriptor|null $associatedClass */ $associatedClass = $this->getParent(); if (($associatedClass instanceof ClassDescriptor || $associatedClass instanceof InterfaceDescriptor) && ($associatedClass->getParent() instanceof ClassDescriptor || $associatedClass->getParent() instanceof InterfaceDescriptor ) ) { /** @var ClassDescriptor|InterfaceDescriptor $parentClass */ $parentClass = $associatedClass->getParent(); return $parentClass->getProperties()->get($this->getName()); } return null; }
php
public function getInheritedElement() { $associatedClass = $this->getParent(); if (($associatedClass instanceof ClassDescriptor || $associatedClass instanceof InterfaceDescriptor) && ($associatedClass->getParent() instanceof ClassDescriptor || $associatedClass->getParent() instanceof InterfaceDescriptor ) ) { $parentClass = $associatedClass->getParent(); return $parentClass->getProperties()->get($this->getName()); } return null; }
[ "public", "function", "getInheritedElement", "(", ")", "{", "/** @var ClassDescriptor|InterfaceDescriptor|null $associatedClass */", "$", "associatedClass", "=", "$", "this", "->", "getParent", "(", ")", ";", "if", "(", "(", "$", "associatedClass", "instanceof", "ClassDescriptor", "||", "$", "associatedClass", "instanceof", "InterfaceDescriptor", ")", "&&", "(", "$", "associatedClass", "->", "getParent", "(", ")", "instanceof", "ClassDescriptor", "||", "$", "associatedClass", "->", "getParent", "(", ")", "instanceof", "InterfaceDescriptor", ")", ")", "{", "/** @var ClassDescriptor|InterfaceDescriptor $parentClass */", "$", "parentClass", "=", "$", "associatedClass", "->", "getParent", "(", ")", ";", "return", "$", "parentClass", "->", "getProperties", "(", ")", "->", "get", "(", "$", "this", "->", "getName", "(", ")", ")", ";", "}", "return", "null", ";", "}" ]
Returns the property from which this one should inherit, if any. @return PropertyDescriptor|null
[ "Returns", "the", "property", "from", "which", "this", "one", "should", "inherit", "if", "any", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/PropertyDescriptor.php#L174-L191
phpDocumentor/phpDocumentor2
src/phpDocumentor/Plugin/Core/Transformer/Behaviour/Tag/ParamTag.php
ParamTag.process
public function process(\DOMDocument $xml) { $qry = '//tag[@name=\'' . $this->element_name . '\']/@description[. != ""]'; $xpath = new \DOMXPath($xml); $nodes = $xpath->query($qry); /** @var \DOMElement $node */ foreach ($nodes as $node) { // only transform using markdown if the text contains characters // other than word characters, whitespaces and punctuation characters. // This is because Markdown is a huge performance hit on the system if (!preg_match('/^[\w|\s|\.|,|;|\:|\&|\#]+$/', $node->nodeValue)) { $md = \Parsedown::instance(); $node->nodeValue = $md->parse($node->nodeValue); } else { // markdown will always surround the element with a paragraph; // we do the same here to make it consistent $node->nodeValue = '&lt;p&gt;' . $node->nodeValue . '&lt;/p&gt;'; } } return $xml; }
php
public function process(\DOMDocument $xml) { $qry = ' $xpath = new \DOMXPath($xml); $nodes = $xpath->query($qry); foreach ($nodes as $node) { if (!preg_match('/^[\w|\s|\.|,|;|\:|\&|\ $md = \Parsedown::instance(); $node->nodeValue = $md->parse($node->nodeValue); } else { $node->nodeValue = '&lt;p&gt;' . $node->nodeValue . '&lt;/p&gt;'; } } return $xml; }
[ "public", "function", "process", "(", "\\", "DOMDocument", "$", "xml", ")", "{", "$", "qry", "=", "'//tag[@name=\\''", ".", "$", "this", "->", "element_name", ".", "'\\']/@description[. != \"\"]'", ";", "$", "xpath", "=", "new", "\\", "DOMXPath", "(", "$", "xml", ")", ";", "$", "nodes", "=", "$", "xpath", "->", "query", "(", "$", "qry", ")", ";", "/** @var \\DOMElement $node */", "foreach", "(", "$", "nodes", "as", "$", "node", ")", "{", "// only transform using markdown if the text contains characters", "// other than word characters, whitespaces and punctuation characters.", "// This is because Markdown is a huge performance hit on the system", "if", "(", "!", "preg_match", "(", "'/^[\\w|\\s|\\.|,|;|\\:|\\&|\\#]+$/'", ",", "$", "node", "->", "nodeValue", ")", ")", "{", "$", "md", "=", "\\", "Parsedown", "::", "instance", "(", ")", ";", "$", "node", "->", "nodeValue", "=", "$", "md", "->", "parse", "(", "$", "node", "->", "nodeValue", ")", ";", "}", "else", "{", "// markdown will always surround the element with a paragraph;", "// we do the same here to make it consistent", "$", "node", "->", "nodeValue", "=", "'&lt;p&gt;'", ".", "$", "node", "->", "nodeValue", ".", "'&lt;/p&gt;'", ";", "}", "}", "return", "$", "xml", ";", "}" ]
Find all the param tags and if using special characters transform using markdown otherwise just add a <p> tag to be consistent. @param \DOMDocument $xml Structure source to apply behaviour onto. @return \DOMDocument
[ "Find", "all", "the", "param", "tags", "and", "if", "using", "special", "characters", "transform", "using", "markdown", "otherwise", "just", "add", "a", "<p", ">", "tag", "to", "be", "consistent", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Core/Transformer/Behaviour/Tag/ParamTag.php#L34-L57
phpDocumentor/phpDocumentor2
src/phpDocumentor/Descriptor/Builder/Reflector/Tags/UsesAssembler.php
UsesAssembler.create
public function create($data) { $descriptor = new UsesDescriptor($data->getName()); $descriptor->setDescription($data->getDescription()); $reference = $data->getReference(); $descriptor->setReference($reference); return $descriptor; }
php
public function create($data) { $descriptor = new UsesDescriptor($data->getName()); $descriptor->setDescription($data->getDescription()); $reference = $data->getReference(); $descriptor->setReference($reference); return $descriptor; }
[ "public", "function", "create", "(", "$", "data", ")", "{", "$", "descriptor", "=", "new", "UsesDescriptor", "(", "$", "data", "->", "getName", "(", ")", ")", ";", "$", "descriptor", "->", "setDescription", "(", "$", "data", "->", "getDescription", "(", ")", ")", ";", "$", "reference", "=", "$", "data", "->", "getReference", "(", ")", ";", "$", "descriptor", "->", "setReference", "(", "$", "reference", ")", ";", "return", "$", "descriptor", ";", "}" ]
Creates a new Descriptor from the given Reflector. @param Uses $data @return UsesDescriptor
[ "Creates", "a", "new", "Descriptor", "from", "the", "given", "Reflector", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/Builder/Reflector/Tags/UsesAssembler.php#L31-L40
phpDocumentor/phpDocumentor2
src/phpDocumentor/AutoloaderLocator.php
AutoloaderLocator.findVendorPath
public static function findVendorPath($baseDir = __DIR__): string { // default installation $vendorDir = $baseDir . '/../../vendor'; // Composerised installation, vendor/phpdocumentor/phpdocumentor/src/phpDocumentor is __DIR__ $rootFolderWhenInstalledWithComposer = $baseDir . '/../../../../../'; $composerConfigurationPath = $rootFolderWhenInstalledWithComposer .'composer.json'; if (file_exists($composerConfigurationPath)) { $vendorDir = $rootFolderWhenInstalledWithComposer . self::getCustomVendorPathFromComposer($composerConfigurationPath); } return $vendorDir; }
php
public static function findVendorPath($baseDir = __DIR__): string { $vendorDir = $baseDir . '/../../vendor'; $rootFolderWhenInstalledWithComposer = $baseDir . '/../../../../../'; $composerConfigurationPath = $rootFolderWhenInstalledWithComposer .'composer.json'; if (file_exists($composerConfigurationPath)) { $vendorDir = $rootFolderWhenInstalledWithComposer . self::getCustomVendorPathFromComposer($composerConfigurationPath); } return $vendorDir; }
[ "public", "static", "function", "findVendorPath", "(", "$", "baseDir", "=", "__DIR__", ")", ":", "string", "{", "// default installation", "$", "vendorDir", "=", "$", "baseDir", ".", "'/../../vendor'", ";", "// Composerised installation, vendor/phpdocumentor/phpdocumentor/src/phpDocumentor is __DIR__", "$", "rootFolderWhenInstalledWithComposer", "=", "$", "baseDir", ".", "'/../../../../../'", ";", "$", "composerConfigurationPath", "=", "$", "rootFolderWhenInstalledWithComposer", ".", "'composer.json'", ";", "if", "(", "file_exists", "(", "$", "composerConfigurationPath", ")", ")", "{", "$", "vendorDir", "=", "$", "rootFolderWhenInstalledWithComposer", ".", "self", "::", "getCustomVendorPathFromComposer", "(", "$", "composerConfigurationPath", ")", ";", "}", "return", "$", "vendorDir", ";", "}" ]
Attempts to find the location of the vendor folder. This method tries to check for a composer.json in a directory 5 levels below the folder of this Bootstrap file. This is the expected location if phpDocumentor is installed using composer because the current directory for this file is expected to be 'vendor/phpdocumentor/phpdocumentor/src/phpDocumentor'. If a composer.json is found we will try to extract the vendor folder name using the 'vendor-dir' configuration option of composer or assume it is vendor if that option is not set. If no custom composer.json can be found, then we assume that the vendor folder is that of phpDocumentor itself, which is `../../vendor` starting from this folder. If neither locations exist, then this method returns null because no vendor path could be found. @param string $baseDir parameter for test purposes only. @return string
[ "Attempts", "to", "find", "the", "location", "of", "the", "vendor", "folder", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/AutoloaderLocator.php#L47-L59
phpDocumentor/phpDocumentor2
src/phpDocumentor/AutoloaderLocator.php
AutoloaderLocator.getCustomVendorPathFromComposer
private static function getCustomVendorPathFromComposer($composerConfigurationPath): string { $composerFile = file_get_contents($composerConfigurationPath); $composerJson = json_decode($composerFile, true); return $composerJson['config']['vendor-dir'] ?? 'vendor'; }
php
private static function getCustomVendorPathFromComposer($composerConfigurationPath): string { $composerFile = file_get_contents($composerConfigurationPath); $composerJson = json_decode($composerFile, true); return $composerJson['config']['vendor-dir'] ?? 'vendor'; }
[ "private", "static", "function", "getCustomVendorPathFromComposer", "(", "$", "composerConfigurationPath", ")", ":", "string", "{", "$", "composerFile", "=", "file_get_contents", "(", "$", "composerConfigurationPath", ")", ";", "$", "composerJson", "=", "json_decode", "(", "$", "composerFile", ",", "true", ")", ";", "return", "$", "composerJson", "[", "'config'", "]", "[", "'vendor-dir'", "]", "??", "'vendor'", ";", "}" ]
Retrieves the custom vendor-dir from the given composer.json or returns 'vendor'. @param string $composerConfigurationPath the path pointing to the composer.json @return string
[ "Retrieves", "the", "custom", "vendor", "-", "dir", "from", "the", "given", "composer", ".", "json", "or", "returns", "vendor", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/AutoloaderLocator.php#L67-L72
phpDocumentor/phpDocumentor2
src/phpDocumentor/Configuration/ConfigurationFactory.php
ConfigurationFactory.fromDefaultLocations
public function fromDefaultLocations(): Configuration { foreach ($this->defaultFiles as $file) { try { return $this->fromUri(new Uri($file)); } catch (\InvalidArgumentException $e) { continue; } } return new Configuration($this->applyMiddleware(Version3::buildDefault())); }
php
public function fromDefaultLocations(): Configuration { foreach ($this->defaultFiles as $file) { try { return $this->fromUri(new Uri($file)); } catch (\InvalidArgumentException $e) { continue; } } return new Configuration($this->applyMiddleware(Version3::buildDefault())); }
[ "public", "function", "fromDefaultLocations", "(", ")", ":", "Configuration", "{", "foreach", "(", "$", "this", "->", "defaultFiles", "as", "$", "file", ")", "{", "try", "{", "return", "$", "this", "->", "fromUri", "(", "new", "Uri", "(", "$", "file", ")", ")", ";", "}", "catch", "(", "\\", "InvalidArgumentException", "$", "e", ")", "{", "continue", ";", "}", "}", "return", "new", "Configuration", "(", "$", "this", "->", "applyMiddleware", "(", "Version3", "::", "buildDefault", "(", ")", ")", ")", ";", "}" ]
Attempts to load a configuration from the default locations for phpDocumentor @return Configuration
[ "Attempts", "to", "load", "a", "configuration", "from", "the", "default", "locations", "for", "phpDocumentor" ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Configuration/ConfigurationFactory.php#L75-L86
phpDocumentor/phpDocumentor2
src/phpDocumentor/Configuration/ConfigurationFactory.php
ConfigurationFactory.fromUri
public function fromUri(Uri $uri): Configuration { $filename = (string) $uri; if (!file_exists($filename)) { throw new \InvalidArgumentException(sprintf('File %s could not be found', $filename)); } $xml = new \SimpleXMLElement($filename, 0, true); foreach ($this->strategies as $strategy) { if ($strategy->supports($xml) !== true) { continue; } return new Configuration($this->applyMiddleware($strategy->convert($xml))); } throw new RuntimeException('No supported configuration files were found'); }
php
public function fromUri(Uri $uri): Configuration { $filename = (string) $uri; if (!file_exists($filename)) { throw new \InvalidArgumentException(sprintf('File %s could not be found', $filename)); } $xml = new \SimpleXMLElement($filename, 0, true); foreach ($this->strategies as $strategy) { if ($strategy->supports($xml) !== true) { continue; } return new Configuration($this->applyMiddleware($strategy->convert($xml))); } throw new RuntimeException('No supported configuration files were found'); }
[ "public", "function", "fromUri", "(", "Uri", "$", "uri", ")", ":", "Configuration", "{", "$", "filename", "=", "(", "string", ")", "$", "uri", ";", "if", "(", "!", "file_exists", "(", "$", "filename", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'File %s could not be found'", ",", "$", "filename", ")", ")", ";", "}", "$", "xml", "=", "new", "\\", "SimpleXMLElement", "(", "$", "filename", ",", "0", ",", "true", ")", ";", "foreach", "(", "$", "this", "->", "strategies", "as", "$", "strategy", ")", "{", "if", "(", "$", "strategy", "->", "supports", "(", "$", "xml", ")", "!==", "true", ")", "{", "continue", ";", "}", "return", "new", "Configuration", "(", "$", "this", "->", "applyMiddleware", "(", "$", "strategy", "->", "convert", "(", "$", "xml", ")", ")", ")", ";", "}", "throw", "new", "RuntimeException", "(", "'No supported configuration files were found'", ")", ";", "}" ]
Converts the phpDocumentor configuration xml to an array. @param Uri $uri The location of the file to be loaded. @return Configuration @throws RuntimeException if no matching strategy can be found.
[ "Converts", "the", "phpDocumentor", "configuration", "xml", "to", "an", "array", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Configuration/ConfigurationFactory.php#L96-L114
phpDocumentor/phpDocumentor2
src/phpDocumentor/Configuration/ConfigurationFactory.php
ConfigurationFactory.applyMiddleware
private function applyMiddleware(array $configuration): array { foreach ($this->middlewares as $middleware) { $configuration = $middleware($configuration); } return $configuration; }
php
private function applyMiddleware(array $configuration): array { foreach ($this->middlewares as $middleware) { $configuration = $middleware($configuration); } return $configuration; }
[ "private", "function", "applyMiddleware", "(", "array", "$", "configuration", ")", ":", "array", "{", "foreach", "(", "$", "this", "->", "middlewares", "as", "$", "middleware", ")", "{", "$", "configuration", "=", "$", "middleware", "(", "$", "configuration", ")", ";", "}", "return", "$", "configuration", ";", "}" ]
Applies all middleware callbacks onto the configuration. @param array $configuration @return array
[ "Applies", "all", "middleware", "callbacks", "onto", "the", "configuration", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Configuration/ConfigurationFactory.php#L133-L140
phpDocumentor/phpDocumentor2
src/phpDocumentor/Application/Stage/Parser.php
Parser.getFileCollection
private function getFileCollection(array $apiConfig): array { $ignorePaths = array_map( function ($value) { if (substr((string) $value, -1) === '*') { return substr($value, 0, -1); } return $value; }, $apiConfig['ignore']['paths'] ); return $this->fileCollector->getFiles( $apiConfig['source']['dsn'], $apiConfig['source']['paths'], [ 'paths' => $ignorePaths, 'hidden' => $apiConfig['ignore']['hidden'], ], $apiConfig['extensions'] ); }
php
private function getFileCollection(array $apiConfig): array { $ignorePaths = array_map( function ($value) { if (substr((string) $value, -1) === '*') { return substr($value, 0, -1); } return $value; }, $apiConfig['ignore']['paths'] ); return $this->fileCollector->getFiles( $apiConfig['source']['dsn'], $apiConfig['source']['paths'], [ 'paths' => $ignorePaths, 'hidden' => $apiConfig['ignore']['hidden'], ], $apiConfig['extensions'] ); }
[ "private", "function", "getFileCollection", "(", "array", "$", "apiConfig", ")", ":", "array", "{", "$", "ignorePaths", "=", "array_map", "(", "function", "(", "$", "value", ")", "{", "if", "(", "substr", "(", "(", "string", ")", "$", "value", ",", "-", "1", ")", "===", "'*'", ")", "{", "return", "substr", "(", "$", "value", ",", "0", ",", "-", "1", ")", ";", "}", "return", "$", "value", ";", "}", ",", "$", "apiConfig", "[", "'ignore'", "]", "[", "'paths'", "]", ")", ";", "return", "$", "this", "->", "fileCollector", "->", "getFiles", "(", "$", "apiConfig", "[", "'source'", "]", "[", "'dsn'", "]", ",", "$", "apiConfig", "[", "'source'", "]", "[", "'paths'", "]", ",", "[", "'paths'", "=>", "$", "ignorePaths", ",", "'hidden'", "=>", "$", "apiConfig", "[", "'ignore'", "]", "[", "'hidden'", "]", ",", "]", ",", "$", "apiConfig", "[", "'extensions'", "]", ")", ";", "}" ]
Returns the collection of files based on the input and configuration.
[ "Returns", "the", "collection", "of", "files", "based", "on", "the", "input", "and", "configuration", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Application/Stage/Parser.php#L179-L201
phpDocumentor/phpDocumentor2
src/phpDocumentor/Application/Stage/Parser.php
Parser.log
private function log(string $message, string $priority = LogLevel::INFO, array $parameters = []): void { $this->logger->log($priority, $message, $parameters); }
php
private function log(string $message, string $priority = LogLevel::INFO, array $parameters = []): void { $this->logger->log($priority, $message, $parameters); }
[ "private", "function", "log", "(", "string", "$", "message", ",", "string", "$", "priority", "=", "LogLevel", "::", "INFO", ",", "array", "$", "parameters", "=", "[", "]", ")", ":", "void", "{", "$", "this", "->", "logger", "->", "log", "(", "$", "priority", ",", "$", "message", ",", "$", "parameters", ")", ";", "}" ]
Dispatches a logging request. @param string $priority The logging priority as declared in the LogLevel PSR-3 class. @param string[] $parameters
[ "Dispatches", "a", "logging", "request", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Application/Stage/Parser.php#L229-L232
phpDocumentor/phpDocumentor2
src/phpDocumentor/Descriptor/Builder/Reflector/InterfaceAssembler.php
InterfaceAssembler.create
public function create($data) { $interfaceDescriptor = new InterfaceDescriptor(); $interfaceDescriptor->setFullyQualifiedStructuralElementName($data->getFqsen()); $interfaceDescriptor->setName($data->getName()); $interfaceDescriptor->setLine($data->getLocation()->getLineNumber()); $interfaceDescriptor->setPackage($this->extractPackageFromDocBlock($data->getDocBlock()) ?: ''); // Reflection library formulates namespace as global but this is not wanted for phpDocumentor itself $interfaceDescriptor->setNamespace(substr((string) $data->getFqsen(), 0, -strlen($data->getName()) - 1)); $this->assembleDocBlock($data->getDocBlock(), $interfaceDescriptor); $this->addConstants($data->getConstants(), $interfaceDescriptor); $this->addMethods($data->getMethods(), $interfaceDescriptor); foreach ($data->getParents() as $interfaceClassName) { $interfaceDescriptor->getParent()->set((string) $interfaceClassName, $interfaceClassName); } return $interfaceDescriptor; }
php
public function create($data) { $interfaceDescriptor = new InterfaceDescriptor(); $interfaceDescriptor->setFullyQualifiedStructuralElementName($data->getFqsen()); $interfaceDescriptor->setName($data->getName()); $interfaceDescriptor->setLine($data->getLocation()->getLineNumber()); $interfaceDescriptor->setPackage($this->extractPackageFromDocBlock($data->getDocBlock()) ?: ''); $interfaceDescriptor->setNamespace(substr((string) $data->getFqsen(), 0, -strlen($data->getName()) - 1)); $this->assembleDocBlock($data->getDocBlock(), $interfaceDescriptor); $this->addConstants($data->getConstants(), $interfaceDescriptor); $this->addMethods($data->getMethods(), $interfaceDescriptor); foreach ($data->getParents() as $interfaceClassName) { $interfaceDescriptor->getParent()->set((string) $interfaceClassName, $interfaceClassName); } return $interfaceDescriptor; }
[ "public", "function", "create", "(", "$", "data", ")", "{", "$", "interfaceDescriptor", "=", "new", "InterfaceDescriptor", "(", ")", ";", "$", "interfaceDescriptor", "->", "setFullyQualifiedStructuralElementName", "(", "$", "data", "->", "getFqsen", "(", ")", ")", ";", "$", "interfaceDescriptor", "->", "setName", "(", "$", "data", "->", "getName", "(", ")", ")", ";", "$", "interfaceDescriptor", "->", "setLine", "(", "$", "data", "->", "getLocation", "(", ")", "->", "getLineNumber", "(", ")", ")", ";", "$", "interfaceDescriptor", "->", "setPackage", "(", "$", "this", "->", "extractPackageFromDocBlock", "(", "$", "data", "->", "getDocBlock", "(", ")", ")", "?", ":", "''", ")", ";", "// Reflection library formulates namespace as global but this is not wanted for phpDocumentor itself", "$", "interfaceDescriptor", "->", "setNamespace", "(", "substr", "(", "(", "string", ")", "$", "data", "->", "getFqsen", "(", ")", ",", "0", ",", "-", "strlen", "(", "$", "data", "->", "getName", "(", ")", ")", "-", "1", ")", ")", ";", "$", "this", "->", "assembleDocBlock", "(", "$", "data", "->", "getDocBlock", "(", ")", ",", "$", "interfaceDescriptor", ")", ";", "$", "this", "->", "addConstants", "(", "$", "data", "->", "getConstants", "(", ")", ",", "$", "interfaceDescriptor", ")", ";", "$", "this", "->", "addMethods", "(", "$", "data", "->", "getMethods", "(", ")", ",", "$", "interfaceDescriptor", ")", ";", "foreach", "(", "$", "data", "->", "getParents", "(", ")", "as", "$", "interfaceClassName", ")", "{", "$", "interfaceDescriptor", "->", "getParent", "(", ")", "->", "set", "(", "(", "string", ")", "$", "interfaceClassName", ",", "$", "interfaceClassName", ")", ";", "}", "return", "$", "interfaceDescriptor", ";", "}" ]
Creates a Descriptor from the provided data. @param Interface_ $data @return InterfaceDescriptor
[ "Creates", "a", "Descriptor", "from", "the", "provided", "data", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/Builder/Reflector/InterfaceAssembler.php#L37-L58
phpDocumentor/phpDocumentor2
src/phpDocumentor/Descriptor/Builder/Reflector/FileAssembler.php
FileAssembler.create
public function create($data) { $fileDescriptor = new FileDescriptor($data->getHash()); $fileDescriptor->setPackage( $this->extractPackageFromDocBlock($data->getDocBlock()) ?: $this->getBuilder()->getDefaultPackage() ); $fileDescriptor->setName($data->getName()); $fileDescriptor->setPath($data->getPath()); if ($this->getBuilder()->getProjectDescriptor()->getSettings()->shouldIncludeSource()) { $fileDescriptor->setSource($data->getSource()); } $fileDescriptor->setIncludes(new Collection($data->getIncludes())); $fileDescriptor->setNamespaceAliases(new Collection($data->getNamespaces())); $this->assembleDocBlock($data->getDocBlock(), $fileDescriptor); $this->overridePackageTag($data, $fileDescriptor); //$this->addMarkers($data->getMarkers(), $fileDescriptor); $this->addConstants($data->getConstants(), $fileDescriptor); $this->addFunctions($data->getFunctions(), $fileDescriptor); $this->addClasses($data->getClasses(), $fileDescriptor); $this->addInterfaces($data->getInterfaces(), $fileDescriptor); $this->addTraits($data->getTraits(), $fileDescriptor); return $fileDescriptor; }
php
public function create($data) { $fileDescriptor = new FileDescriptor($data->getHash()); $fileDescriptor->setPackage( $this->extractPackageFromDocBlock($data->getDocBlock()) ?: $this->getBuilder()->getDefaultPackage() ); $fileDescriptor->setName($data->getName()); $fileDescriptor->setPath($data->getPath()); if ($this->getBuilder()->getProjectDescriptor()->getSettings()->shouldIncludeSource()) { $fileDescriptor->setSource($data->getSource()); } $fileDescriptor->setIncludes(new Collection($data->getIncludes())); $fileDescriptor->setNamespaceAliases(new Collection($data->getNamespaces())); $this->assembleDocBlock($data->getDocBlock(), $fileDescriptor); $this->overridePackageTag($data, $fileDescriptor); $this->addConstants($data->getConstants(), $fileDescriptor); $this->addFunctions($data->getFunctions(), $fileDescriptor); $this->addClasses($data->getClasses(), $fileDescriptor); $this->addInterfaces($data->getInterfaces(), $fileDescriptor); $this->addTraits($data->getTraits(), $fileDescriptor); return $fileDescriptor; }
[ "public", "function", "create", "(", "$", "data", ")", "{", "$", "fileDescriptor", "=", "new", "FileDescriptor", "(", "$", "data", "->", "getHash", "(", ")", ")", ";", "$", "fileDescriptor", "->", "setPackage", "(", "$", "this", "->", "extractPackageFromDocBlock", "(", "$", "data", "->", "getDocBlock", "(", ")", ")", "?", ":", "$", "this", "->", "getBuilder", "(", ")", "->", "getDefaultPackage", "(", ")", ")", ";", "$", "fileDescriptor", "->", "setName", "(", "$", "data", "->", "getName", "(", ")", ")", ";", "$", "fileDescriptor", "->", "setPath", "(", "$", "data", "->", "getPath", "(", ")", ")", ";", "if", "(", "$", "this", "->", "getBuilder", "(", ")", "->", "getProjectDescriptor", "(", ")", "->", "getSettings", "(", ")", "->", "shouldIncludeSource", "(", ")", ")", "{", "$", "fileDescriptor", "->", "setSource", "(", "$", "data", "->", "getSource", "(", ")", ")", ";", "}", "$", "fileDescriptor", "->", "setIncludes", "(", "new", "Collection", "(", "$", "data", "->", "getIncludes", "(", ")", ")", ")", ";", "$", "fileDescriptor", "->", "setNamespaceAliases", "(", "new", "Collection", "(", "$", "data", "->", "getNamespaces", "(", ")", ")", ")", ";", "$", "this", "->", "assembleDocBlock", "(", "$", "data", "->", "getDocBlock", "(", ")", ",", "$", "fileDescriptor", ")", ";", "$", "this", "->", "overridePackageTag", "(", "$", "data", ",", "$", "fileDescriptor", ")", ";", "//$this->addMarkers($data->getMarkers(), $fileDescriptor);", "$", "this", "->", "addConstants", "(", "$", "data", "->", "getConstants", "(", ")", ",", "$", "fileDescriptor", ")", ";", "$", "this", "->", "addFunctions", "(", "$", "data", "->", "getFunctions", "(", ")", ",", "$", "fileDescriptor", ")", ";", "$", "this", "->", "addClasses", "(", "$", "data", "->", "getClasses", "(", ")", ",", "$", "fileDescriptor", ")", ";", "$", "this", "->", "addInterfaces", "(", "$", "data", "->", "getInterfaces", "(", ")", ",", "$", "fileDescriptor", ")", ";", "$", "this", "->", "addTraits", "(", "$", "data", "->", "getTraits", "(", ")", ",", "$", "fileDescriptor", ")", ";", "return", "$", "fileDescriptor", ";", "}" ]
Creates a Descriptor from the provided data. @param File $data @return FileDescriptor
[ "Creates", "a", "Descriptor", "from", "the", "provided", "data", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/Builder/Reflector/FileAssembler.php#L40-L67
phpDocumentor/phpDocumentor2
src/phpDocumentor/Descriptor/Builder/Reflector/FileAssembler.php
FileAssembler.addClasses
protected function addClasses(array $classes, FileDescriptor $fileDescriptor): void { foreach ($classes as $class) { $classDescriptor = $this->getBuilder()->buildDescriptor($class); if ($classDescriptor) { $classDescriptor->setLocation($fileDescriptor, $class->getLocation()->getLineNumber()); if (count($classDescriptor->getTags()->get('package', new Collection())) === 0) { $classDescriptor->getTags()->set( 'package', $fileDescriptor->getTags()->get('package', new Collection()) ); } $fileDescriptor->getClasses()->set( (string) ($classDescriptor->getFullyQualifiedStructuralElementName()), $classDescriptor ); } } }
php
protected function addClasses(array $classes, FileDescriptor $fileDescriptor): void { foreach ($classes as $class) { $classDescriptor = $this->getBuilder()->buildDescriptor($class); if ($classDescriptor) { $classDescriptor->setLocation($fileDescriptor, $class->getLocation()->getLineNumber()); if (count($classDescriptor->getTags()->get('package', new Collection())) === 0) { $classDescriptor->getTags()->set( 'package', $fileDescriptor->getTags()->get('package', new Collection()) ); } $fileDescriptor->getClasses()->set( (string) ($classDescriptor->getFullyQualifiedStructuralElementName()), $classDescriptor ); } } }
[ "protected", "function", "addClasses", "(", "array", "$", "classes", ",", "FileDescriptor", "$", "fileDescriptor", ")", ":", "void", "{", "foreach", "(", "$", "classes", "as", "$", "class", ")", "{", "$", "classDescriptor", "=", "$", "this", "->", "getBuilder", "(", ")", "->", "buildDescriptor", "(", "$", "class", ")", ";", "if", "(", "$", "classDescriptor", ")", "{", "$", "classDescriptor", "->", "setLocation", "(", "$", "fileDescriptor", ",", "$", "class", "->", "getLocation", "(", ")", "->", "getLineNumber", "(", ")", ")", ";", "if", "(", "count", "(", "$", "classDescriptor", "->", "getTags", "(", ")", "->", "get", "(", "'package'", ",", "new", "Collection", "(", ")", ")", ")", "===", "0", ")", "{", "$", "classDescriptor", "->", "getTags", "(", ")", "->", "set", "(", "'package'", ",", "$", "fileDescriptor", "->", "getTags", "(", ")", "->", "get", "(", "'package'", ",", "new", "Collection", "(", ")", ")", ")", ";", "}", "$", "fileDescriptor", "->", "getClasses", "(", ")", "->", "set", "(", "(", "string", ")", "(", "$", "classDescriptor", "->", "getFullyQualifiedStructuralElementName", "(", ")", ")", ",", "$", "classDescriptor", ")", ";", "}", "}", "}" ]
Registers the child classes with the generated File Descriptor. @param Class_[] $classes
[ "Registers", "the", "child", "classes", "with", "the", "generated", "File", "Descriptor", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/Builder/Reflector/FileAssembler.php#L122-L141
phpDocumentor/phpDocumentor2
src/phpDocumentor/Descriptor/ProjectDescriptor.php
ProjectDescriptor.isVisibilityAllowed
public function isVisibilityAllowed($visibility) { $visibilityAllowed = $this->getSettings() ? $this->getSettings()->getVisibility() : Settings::VISIBILITY_DEFAULT; return (bool) ($visibilityAllowed & $visibility); }
php
public function isVisibilityAllowed($visibility) { $visibilityAllowed = $this->getSettings() ? $this->getSettings()->getVisibility() : Settings::VISIBILITY_DEFAULT; return (bool) ($visibilityAllowed & $visibility); }
[ "public", "function", "isVisibilityAllowed", "(", "$", "visibility", ")", "{", "$", "visibilityAllowed", "=", "$", "this", "->", "getSettings", "(", ")", "?", "$", "this", "->", "getSettings", "(", ")", "->", "getVisibility", "(", ")", ":", "Settings", "::", "VISIBILITY_DEFAULT", ";", "return", "(", "bool", ")", "(", "$", "visibilityAllowed", "&", "$", "visibility", ")", ";", "}" ]
Checks whether the Project supports the given visibility. @param integer $visibility One of the VISIBILITY_* constants of the Settings class. @see Settings for a list of the available VISIBILITY_* constants. @return boolean
[ "Checks", "whether", "the", "Project", "supports", "the", "given", "visibility", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/ProjectDescriptor.php#L198-L205
phpDocumentor/phpDocumentor2
src/phpDocumentor/Application/Stage/Transform.php
Transform.connectOutputToEvents
private function connectOutputToEvents(): void { Dispatcher::getInstance()->addListener( Transformer::EVENT_PRE_TRANSFORM, function (PreTransformEvent $event) { /** @var Transformer $transformer */ $transformer = $event->getSubject(); $templates = $transformer->getTemplates(); $transformations = $templates->getTransformations(); $this->logger->info(sprintf("\nApplying %d transformations", count($transformations))); } ); Dispatcher::getInstance()->addListener( Transformer::EVENT_PRE_INITIALIZATION, function (WriterInitializationEvent $event) { if ($event->getWriter() instanceof WriterAbstract) { $this->logger->info(' Initialize writer "' . get_class($event->getWriter()) . '"'); } } ); Dispatcher::getInstance()->addListener( Transformer::EVENT_PRE_TRANSFORMATION, function (PreTransformationEvent $event) { if ($event->getTransformation()->getWriter() instanceof WriterAbstract) { $this->logger->info( ' Execute transformation using writer "' . $event->getTransformation()->getWriter() . '"' ); } } ); }
php
private function connectOutputToEvents(): void { Dispatcher::getInstance()->addListener( Transformer::EVENT_PRE_TRANSFORM, function (PreTransformEvent $event) { $transformer = $event->getSubject(); $templates = $transformer->getTemplates(); $transformations = $templates->getTransformations(); $this->logger->info(sprintf("\nApplying %d transformations", count($transformations))); } ); Dispatcher::getInstance()->addListener( Transformer::EVENT_PRE_INITIALIZATION, function (WriterInitializationEvent $event) { if ($event->getWriter() instanceof WriterAbstract) { $this->logger->info(' Initialize writer "' . get_class($event->getWriter()) . '"'); } } ); Dispatcher::getInstance()->addListener( Transformer::EVENT_PRE_TRANSFORMATION, function (PreTransformationEvent $event) { if ($event->getTransformation()->getWriter() instanceof WriterAbstract) { $this->logger->info( ' Execute transformation using writer "' . $event->getTransformation()->getWriter() . '"' ); } } ); }
[ "private", "function", "connectOutputToEvents", "(", ")", ":", "void", "{", "Dispatcher", "::", "getInstance", "(", ")", "->", "addListener", "(", "Transformer", "::", "EVENT_PRE_TRANSFORM", ",", "function", "(", "PreTransformEvent", "$", "event", ")", "{", "/** @var Transformer $transformer */", "$", "transformer", "=", "$", "event", "->", "getSubject", "(", ")", ";", "$", "templates", "=", "$", "transformer", "->", "getTemplates", "(", ")", ";", "$", "transformations", "=", "$", "templates", "->", "getTransformations", "(", ")", ";", "$", "this", "->", "logger", "->", "info", "(", "sprintf", "(", "\"\\nApplying %d transformations\"", ",", "count", "(", "$", "transformations", ")", ")", ")", ";", "}", ")", ";", "Dispatcher", "::", "getInstance", "(", ")", "->", "addListener", "(", "Transformer", "::", "EVENT_PRE_INITIALIZATION", ",", "function", "(", "WriterInitializationEvent", "$", "event", ")", "{", "if", "(", "$", "event", "->", "getWriter", "(", ")", "instanceof", "WriterAbstract", ")", "{", "$", "this", "->", "logger", "->", "info", "(", "' Initialize writer \"'", ".", "get_class", "(", "$", "event", "->", "getWriter", "(", ")", ")", ".", "'\"'", ")", ";", "}", "}", ")", ";", "Dispatcher", "::", "getInstance", "(", ")", "->", "addListener", "(", "Transformer", "::", "EVENT_PRE_TRANSFORMATION", ",", "function", "(", "PreTransformationEvent", "$", "event", ")", "{", "if", "(", "$", "event", "->", "getTransformation", "(", ")", "->", "getWriter", "(", ")", "instanceof", "WriterAbstract", ")", "{", "$", "this", "->", "logger", "->", "info", "(", "' Execute transformation using writer \"'", ".", "$", "event", "->", "getTransformation", "(", ")", "->", "getWriter", "(", ")", ".", "'\"'", ")", ";", "}", "}", ")", ";", "}" ]
Connect a series of output messages to various events to display progress.
[ "Connect", "a", "series", "of", "output", "messages", "to", "various", "events", "to", "display", "progress", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Application/Stage/Transform.php#L170-L200
phpDocumentor/phpDocumentor2
src/phpDocumentor/Descriptor/Builder/Reflector/Tags/LinkAssembler.php
LinkAssembler.create
public function create($data) { $descriptor = new LinkDescriptor($data->getName()); $descriptor->setLink($data->getLink()); $descriptor->setDescription($data->getDescription()); return $descriptor; }
php
public function create($data) { $descriptor = new LinkDescriptor($data->getName()); $descriptor->setLink($data->getLink()); $descriptor->setDescription($data->getDescription()); return $descriptor; }
[ "public", "function", "create", "(", "$", "data", ")", "{", "$", "descriptor", "=", "new", "LinkDescriptor", "(", "$", "data", "->", "getName", "(", ")", ")", ";", "$", "descriptor", "->", "setLink", "(", "$", "data", "->", "getLink", "(", ")", ")", ";", "$", "descriptor", "->", "setDescription", "(", "$", "data", "->", "getDescription", "(", ")", ")", ";", "return", "$", "descriptor", ";", "}" ]
Creates a new Descriptor from the given Reflector. @param Link $data @return LinkDescriptor
[ "Creates", "a", "new", "Descriptor", "from", "the", "given", "Reflector", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/Builder/Reflector/Tags/LinkAssembler.php#L37-L44
phpDocumentor/phpDocumentor2
src/phpDocumentor/Plugin/Scrybe/Converter/Definition/Factory.php
Factory.get
public function get($input_format, $output_format) { return new Definition( $this->format_collection[$input_format], $this->format_collection[$output_format] ); }
php
public function get($input_format, $output_format) { return new Definition( $this->format_collection[$input_format], $this->format_collection[$output_format] ); }
[ "public", "function", "get", "(", "$", "input_format", ",", "$", "output_format", ")", "{", "return", "new", "Definition", "(", "$", "this", "->", "format_collection", "[", "$", "input_format", "]", ",", "$", "this", "->", "format_collection", "[", "$", "output_format", "]", ")", ";", "}" ]
Creates a definition of the given input and output formats. @param string $input_format @param string $output_format @return Definition
[ "Creates", "a", "definition", "of", "the", "given", "input", "and", "output", "formats", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Scrybe/Converter/Definition/Factory.php#L44-L50
phpDocumentor/phpDocumentor2
src/phpDocumentor/Descriptor/ConstantDescriptor.php
ConstantDescriptor.setParent
public function setParent($parent) { if (!$parent instanceof ClassDescriptor && !$parent instanceof InterfaceDescriptor && $parent !== null) { throw new \InvalidArgumentException('Constants can only have an interface or class as parent'); } $fqsen = $parent !== null ? $parent->getFullyQualifiedStructuralElementName() . '::' . $this->getName() : $this->getName(); $this->setFullyQualifiedStructuralElementName($fqsen); $this->parent = $parent; }
php
public function setParent($parent) { if (!$parent instanceof ClassDescriptor && !$parent instanceof InterfaceDescriptor && $parent !== null) { throw new \InvalidArgumentException('Constants can only have an interface or class as parent'); } $fqsen = $parent !== null ? $parent->getFullyQualifiedStructuralElementName() . '::' . $this->getName() : $this->getName(); $this->setFullyQualifiedStructuralElementName($fqsen); $this->parent = $parent; }
[ "public", "function", "setParent", "(", "$", "parent", ")", "{", "if", "(", "!", "$", "parent", "instanceof", "ClassDescriptor", "&&", "!", "$", "parent", "instanceof", "InterfaceDescriptor", "&&", "$", "parent", "!==", "null", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Constants can only have an interface or class as parent'", ")", ";", "}", "$", "fqsen", "=", "$", "parent", "!==", "null", "?", "$", "parent", "->", "getFullyQualifiedStructuralElementName", "(", ")", ".", "'::'", ".", "$", "this", "->", "getName", "(", ")", ":", "$", "this", "->", "getName", "(", ")", ";", "$", "this", "->", "setFullyQualifiedStructuralElementName", "(", "$", "fqsen", ")", ";", "$", "this", "->", "parent", "=", "$", "parent", ";", "}" ]
Registers a parent class or interface with this constant. @param ClassDescriptor|InterfaceDescriptor|null $parent @throws \InvalidArgumentException if anything other than a class, interface or null was passed.
[ "Registers", "a", "parent", "class", "or", "interface", "with", "this", "constant", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/ConstantDescriptor.php#L42-L55
phpDocumentor/phpDocumentor2
src/phpDocumentor/Descriptor/Builder/AssemblerFactory.php
AssemblerFactory.register
public function register(callable $matcher, AssemblerInterface $assembler): void { $this->assemblers[] = new AssemblerMatcher($matcher, $assembler); }
php
public function register(callable $matcher, AssemblerInterface $assembler): void { $this->assemblers[] = new AssemblerMatcher($matcher, $assembler); }
[ "public", "function", "register", "(", "callable", "$", "matcher", ",", "AssemblerInterface", "$", "assembler", ")", ":", "void", "{", "$", "this", "->", "assemblers", "[", "]", "=", "new", "AssemblerMatcher", "(", "$", "matcher", ",", "$", "assembler", ")", ";", "}" ]
Registers an assembler instance to this factory. @param callable $matcher A callback function accepting the criteria as only parameter and which must return a boolean. @param AssemblerInterface $assembler An instance of the Assembler that will be returned if the callback returns true with the provided criteria.
[ "Registers", "an", "assembler", "instance", "to", "this", "factory", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/Builder/AssemblerFactory.php#L89-L92
phpDocumentor/phpDocumentor2
src/phpDocumentor/Descriptor/Builder/AssemblerFactory.php
AssemblerFactory.registerFallback
public function registerFallback(callable $matcher, AssemblerInterface $assembler): void { $this->fallbackAssemblers[] = new AssemblerMatcher($matcher, $assembler); }
php
public function registerFallback(callable $matcher, AssemblerInterface $assembler): void { $this->fallbackAssemblers[] = new AssemblerMatcher($matcher, $assembler); }
[ "public", "function", "registerFallback", "(", "callable", "$", "matcher", ",", "AssemblerInterface", "$", "assembler", ")", ":", "void", "{", "$", "this", "->", "fallbackAssemblers", "[", "]", "=", "new", "AssemblerMatcher", "(", "$", "matcher", ",", "$", "assembler", ")", ";", "}" ]
Registers an assembler instance to this factory that is to be executed after all other assemblers have been checked. @param callable $matcher A callback function accepting the criteria as only parameter and which must return a boolean. @param AssemblerInterface $assembler An instance of the Assembler that will be returned if the callback returns true with the provided criteria.
[ "Registers", "an", "assembler", "instance", "to", "this", "factory", "that", "is", "to", "be", "executed", "after", "all", "other", "assemblers", "have", "been", "checked", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/Builder/AssemblerFactory.php#L103-L106
phpDocumentor/phpDocumentor2
src/phpDocumentor/Descriptor/Builder/AssemblerFactory.php
AssemblerFactory.get
public function get($criteria) { /** @var AssemblerMatcher $candidate */ foreach (array_merge($this->assemblers, $this->fallbackAssemblers) as $candidate) { if ($candidate->match($criteria) === true) { return $candidate->getAssembler(); } } return null; }
php
public function get($criteria) { foreach (array_merge($this->assemblers, $this->fallbackAssemblers) as $candidate) { if ($candidate->match($criteria) === true) { return $candidate->getAssembler(); } } return null; }
[ "public", "function", "get", "(", "$", "criteria", ")", "{", "/** @var AssemblerMatcher $candidate */", "foreach", "(", "array_merge", "(", "$", "this", "->", "assemblers", ",", "$", "this", "->", "fallbackAssemblers", ")", "as", "$", "candidate", ")", "{", "if", "(", "$", "candidate", "->", "match", "(", "$", "criteria", ")", "===", "true", ")", "{", "return", "$", "candidate", "->", "getAssembler", "(", ")", ";", "}", "}", "return", "null", ";", "}" ]
Retrieves a matching Assembler based on the provided criteria or null if none was found. @param mixed $criteria @return AssemblerInterface|null
[ "Retrieves", "a", "matching", "Assembler", "based", "on", "the", "provided", "criteria", "or", "null", "if", "none", "was", "found", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/Builder/AssemblerFactory.php#L115-L125
phpDocumentor/phpDocumentor2
src/phpDocumentor/Descriptor/Builder/Reflector/MethodAssembler.php
MethodAssembler.create
public function create($data) { $methodDescriptor = new MethodDescriptor(); $methodDescriptor->setNamespace( substr( (string) $data->getFqsen(), 0, -strlen($data->getName()) - 4 ) ); $this->mapReflectorToDescriptor($data, $methodDescriptor); $this->assembleDocBlock($data->getDocBlock(), $methodDescriptor); $this->addArguments($data, $methodDescriptor); $this->addVariadicArgument($data, $methodDescriptor); return $methodDescriptor; }
php
public function create($data) { $methodDescriptor = new MethodDescriptor(); $methodDescriptor->setNamespace( substr( (string) $data->getFqsen(), 0, -strlen($data->getName()) - 4 ) ); $this->mapReflectorToDescriptor($data, $methodDescriptor); $this->assembleDocBlock($data->getDocBlock(), $methodDescriptor); $this->addArguments($data, $methodDescriptor); $this->addVariadicArgument($data, $methodDescriptor); return $methodDescriptor; }
[ "public", "function", "create", "(", "$", "data", ")", "{", "$", "methodDescriptor", "=", "new", "MethodDescriptor", "(", ")", ";", "$", "methodDescriptor", "->", "setNamespace", "(", "substr", "(", "(", "string", ")", "$", "data", "->", "getFqsen", "(", ")", ",", "0", ",", "-", "strlen", "(", "$", "data", "->", "getName", "(", ")", ")", "-", "4", ")", ")", ";", "$", "this", "->", "mapReflectorToDescriptor", "(", "$", "data", ",", "$", "methodDescriptor", ")", ";", "$", "this", "->", "assembleDocBlock", "(", "$", "data", "->", "getDocBlock", "(", ")", ",", "$", "methodDescriptor", ")", ";", "$", "this", "->", "addArguments", "(", "$", "data", ",", "$", "methodDescriptor", ")", ";", "$", "this", "->", "addVariadicArgument", "(", "$", "data", ",", "$", "methodDescriptor", ")", ";", "return", "$", "methodDescriptor", ";", "}" ]
Creates a Descriptor from the provided data. @param Method $data @return MethodDescriptor
[ "Creates", "a", "Descriptor", "from", "the", "provided", "data", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/Builder/Reflector/MethodAssembler.php#L47-L64
phpDocumentor/phpDocumentor2
src/phpDocumentor/Descriptor/Builder/Reflector/MethodAssembler.php
MethodAssembler.mapReflectorToDescriptor
protected function mapReflectorToDescriptor(Method $reflector, MethodDescriptor $descriptor): void { $descriptor->setFullyQualifiedStructuralElementName($reflector->getFqsen()); $descriptor->setName($reflector->getName()); $descriptor->setVisibility((string) $reflector->getVisibility() ?: 'public'); $descriptor->setFinal($reflector->isFinal()); $descriptor->setAbstract($reflector->isAbstract()); $descriptor->setStatic($reflector->isStatic()); $descriptor->setLine($reflector->getLocation()->getLineNumber()); $descriptor->setReturnType($reflector->getReturnType()); }
php
protected function mapReflectorToDescriptor(Method $reflector, MethodDescriptor $descriptor): void { $descriptor->setFullyQualifiedStructuralElementName($reflector->getFqsen()); $descriptor->setName($reflector->getName()); $descriptor->setVisibility((string) $reflector->getVisibility() ?: 'public'); $descriptor->setFinal($reflector->isFinal()); $descriptor->setAbstract($reflector->isAbstract()); $descriptor->setStatic($reflector->isStatic()); $descriptor->setLine($reflector->getLocation()->getLineNumber()); $descriptor->setReturnType($reflector->getReturnType()); }
[ "protected", "function", "mapReflectorToDescriptor", "(", "Method", "$", "reflector", ",", "MethodDescriptor", "$", "descriptor", ")", ":", "void", "{", "$", "descriptor", "->", "setFullyQualifiedStructuralElementName", "(", "$", "reflector", "->", "getFqsen", "(", ")", ")", ";", "$", "descriptor", "->", "setName", "(", "$", "reflector", "->", "getName", "(", ")", ")", ";", "$", "descriptor", "->", "setVisibility", "(", "(", "string", ")", "$", "reflector", "->", "getVisibility", "(", ")", "?", ":", "'public'", ")", ";", "$", "descriptor", "->", "setFinal", "(", "$", "reflector", "->", "isFinal", "(", ")", ")", ";", "$", "descriptor", "->", "setAbstract", "(", "$", "reflector", "->", "isAbstract", "(", ")", ")", ";", "$", "descriptor", "->", "setStatic", "(", "$", "reflector", "->", "isStatic", "(", ")", ")", ";", "$", "descriptor", "->", "setLine", "(", "$", "reflector", "->", "getLocation", "(", ")", "->", "getLineNumber", "(", ")", ")", ";", "$", "descriptor", "->", "setReturnType", "(", "$", "reflector", "->", "getReturnType", "(", ")", ")", ";", "}" ]
Maps the fields to the reflector to the descriptor.
[ "Maps", "the", "fields", "to", "the", "reflector", "to", "the", "descriptor", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/Builder/Reflector/MethodAssembler.php#L69-L79
phpDocumentor/phpDocumentor2
src/phpDocumentor/Descriptor/Builder/Reflector/MethodAssembler.php
MethodAssembler.addArguments
protected function addArguments(Method $reflector, MethodDescriptor $descriptor): void { foreach ($reflector->getArguments() as $argument) { $this->addArgument($argument, $descriptor); } }
php
protected function addArguments(Method $reflector, MethodDescriptor $descriptor): void { foreach ($reflector->getArguments() as $argument) { $this->addArgument($argument, $descriptor); } }
[ "protected", "function", "addArguments", "(", "Method", "$", "reflector", ",", "MethodDescriptor", "$", "descriptor", ")", ":", "void", "{", "foreach", "(", "$", "reflector", "->", "getArguments", "(", ")", "as", "$", "argument", ")", "{", "$", "this", "->", "addArgument", "(", "$", "argument", ",", "$", "descriptor", ")", ";", "}", "}" ]
Adds the reflected Arguments to the Descriptor.
[ "Adds", "the", "reflected", "Arguments", "to", "the", "Descriptor", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/Builder/Reflector/MethodAssembler.php#L84-L89
phpDocumentor/phpDocumentor2
src/phpDocumentor/Descriptor/Builder/Reflector/MethodAssembler.php
MethodAssembler.addVariadicArgument
protected function addVariadicArgument(Method $data, MethodDescriptor $methodDescriptor): void { if (!$data->getDocBlock()) { return; } $paramTags = $data->getDocBlock()->getTagsByName('param'); /** @var Param $lastParamTag */ $lastParamTag = end($paramTags); if (!$lastParamTag) { return; } if ($lastParamTag->isVariadic() && array_key_exists($lastParamTag->getVariableName(), $methodDescriptor->getArguments()->getAll()) ) { $types = $lastParamTag->getType(); $argument = new ArgumentDescriptor(); $argument->setName($lastParamTag->getVariableName()); $argument->setType($types); $argument->setDescription($lastParamTag->getDescription()); $argument->setLine($methodDescriptor->getLine()); $argument->setVariadic(true); $methodDescriptor->getArguments()->set($argument->getName(), $argument); } }
php
protected function addVariadicArgument(Method $data, MethodDescriptor $methodDescriptor): void { if (!$data->getDocBlock()) { return; } $paramTags = $data->getDocBlock()->getTagsByName('param'); $lastParamTag = end($paramTags); if (!$lastParamTag) { return; } if ($lastParamTag->isVariadic() && array_key_exists($lastParamTag->getVariableName(), $methodDescriptor->getArguments()->getAll()) ) { $types = $lastParamTag->getType(); $argument = new ArgumentDescriptor(); $argument->setName($lastParamTag->getVariableName()); $argument->setType($types); $argument->setDescription($lastParamTag->getDescription()); $argument->setLine($methodDescriptor->getLine()); $argument->setVariadic(true); $methodDescriptor->getArguments()->set($argument->getName(), $argument); } }
[ "protected", "function", "addVariadicArgument", "(", "Method", "$", "data", ",", "MethodDescriptor", "$", "methodDescriptor", ")", ":", "void", "{", "if", "(", "!", "$", "data", "->", "getDocBlock", "(", ")", ")", "{", "return", ";", "}", "$", "paramTags", "=", "$", "data", "->", "getDocBlock", "(", ")", "->", "getTagsByName", "(", "'param'", ")", ";", "/** @var Param $lastParamTag */", "$", "lastParamTag", "=", "end", "(", "$", "paramTags", ")", ";", "if", "(", "!", "$", "lastParamTag", ")", "{", "return", ";", "}", "if", "(", "$", "lastParamTag", "->", "isVariadic", "(", ")", "&&", "array_key_exists", "(", "$", "lastParamTag", "->", "getVariableName", "(", ")", ",", "$", "methodDescriptor", "->", "getArguments", "(", ")", "->", "getAll", "(", ")", ")", ")", "{", "$", "types", "=", "$", "lastParamTag", "->", "getType", "(", ")", ";", "$", "argument", "=", "new", "ArgumentDescriptor", "(", ")", ";", "$", "argument", "->", "setName", "(", "$", "lastParamTag", "->", "getVariableName", "(", ")", ")", ";", "$", "argument", "->", "setType", "(", "$", "types", ")", ";", "$", "argument", "->", "setDescription", "(", "$", "lastParamTag", "->", "getDescription", "(", ")", ")", ";", "$", "argument", "->", "setLine", "(", "$", "methodDescriptor", "->", "getLine", "(", ")", ")", ";", "$", "argument", "->", "setVariadic", "(", "true", ")", ";", "$", "methodDescriptor", "->", "getArguments", "(", ")", "->", "set", "(", "$", "argument", "->", "getName", "(", ")", ",", "$", "argument", ")", ";", "}", "}" ]
Checks if there is a variadic argument in the `@param` tags and adds it to the list of Arguments in the Descriptor unless there is already one present.
[ "Checks", "if", "there", "is", "a", "variadic", "argument", "in", "the" ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/Builder/Reflector/MethodAssembler.php#L111-L139
phpDocumentor/phpDocumentor2
src/phpDocumentor/Transformer/Writer/Collection.php
Collection.offsetSet
public function offsetSet($index, $newval) { if (!$newval instanceof WriterAbstract) { throw new \InvalidArgumentException( 'The Writer Collection may only contain objects descending from WriterAbstract' ); } if (!preg_match('/^[a-zA-Z0-9\-\_\/]{3,}$/', $index)) { throw new \InvalidArgumentException( 'The name of a Writer may only contain alphanumeric characters, one or more hyphens, underscores and ' . 'forward slashes and must be at least three characters wide' ); } // if the writer supports routes, provide them with the router queue if ($newval instanceof Routable) { $newval->setRouters($this->routers); } parent::offsetSet($index, $newval); }
php
public function offsetSet($index, $newval) { if (!$newval instanceof WriterAbstract) { throw new \InvalidArgumentException( 'The Writer Collection may only contain objects descending from WriterAbstract' ); } if (!preg_match('/^[a-zA-Z0-9\-\_\/]{3,}$/', $index)) { throw new \InvalidArgumentException( 'The name of a Writer may only contain alphanumeric characters, one or more hyphens, underscores and ' . 'forward slashes and must be at least three characters wide' ); } if ($newval instanceof Routable) { $newval->setRouters($this->routers); } parent::offsetSet($index, $newval); }
[ "public", "function", "offsetSet", "(", "$", "index", ",", "$", "newval", ")", "{", "if", "(", "!", "$", "newval", "instanceof", "WriterAbstract", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'The Writer Collection may only contain objects descending from WriterAbstract'", ")", ";", "}", "if", "(", "!", "preg_match", "(", "'/^[a-zA-Z0-9\\-\\_\\/]{3,}$/'", ",", "$", "index", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'The name of a Writer may only contain alphanumeric characters, one or more hyphens, underscores and '", ".", "'forward slashes and must be at least three characters wide'", ")", ";", "}", "// if the writer supports routes, provide them with the router queue", "if", "(", "$", "newval", "instanceof", "Routable", ")", "{", "$", "newval", "->", "setRouters", "(", "$", "this", "->", "routers", ")", ";", "}", "parent", "::", "offsetSet", "(", "$", "index", ",", "$", "newval", ")", ";", "}" ]
Registers a writer with a given name. @param string $index a Writer's name, must be at least 3 characters, alphanumeric and/or contain one or more hyphens, underscores and forward slashes. @param WriterAbstract $newval The Writer object to register to this name. @throws \InvalidArgumentException if either of the above restrictions is not met.
[ "Registers", "a", "writer", "with", "a", "given", "name", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Transformer/Writer/Collection.php#L56-L77
phpDocumentor/phpDocumentor2
src/phpDocumentor/Transformer/Writer/Collection.php
Collection.offsetGet
public function offsetGet($index) { if (!$this->offsetExists($index)) { throw new \InvalidArgumentException('Writer "' . $index . '" does not exist'); } return parent::offsetGet($index); }
php
public function offsetGet($index) { if (!$this->offsetExists($index)) { throw new \InvalidArgumentException('Writer "' . $index . '" does not exist'); } return parent::offsetGet($index); }
[ "public", "function", "offsetGet", "(", "$", "index", ")", "{", "if", "(", "!", "$", "this", "->", "offsetExists", "(", "$", "index", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Writer \"'", ".", "$", "index", ".", "'\" does not exist'", ")", ";", "}", "return", "parent", "::", "offsetGet", "(", "$", "index", ")", ";", "}" ]
Retrieves a writer from the collection. @param string $index the name of the writer to retrieve. @throws \InvalidArgumentException if the writer is not in the collection. @return WriterAbstract
[ "Retrieves", "a", "writer", "from", "the", "collection", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Transformer/Writer/Collection.php#L88-L95
phpDocumentor/phpDocumentor2
src/phpDocumentor/Plugin/Scrybe/Converter/RestructuredText/Directives/Toctree.php
Toctree.toXhtml
public function toXhtml(\DOMDocument $document, \DOMElement $root) { $this->addLinksToTableOfContents(); // if the hidden flag is set then this item should not be rendered but still processed (see above) if (isset($this->node->options['hidden'])) { return; } $list = $document->createElement('ol'); $root->appendChild($list); foreach ($this->links as $link) { $list_item = $document->createElement('li'); $list->appendChild($list_item); $link_element = $document->createElement('a'); $list_item->appendChild($link_element); $link_element->appendChild($document->createTextNode($this->getCaption($link))); $link_element->setAttribute('href', str_replace('\\', '/', $link) . '.html'); } }
php
public function toXhtml(\DOMDocument $document, \DOMElement $root) { $this->addLinksToTableOfContents(); if (isset($this->node->options['hidden'])) { return; } $list = $document->createElement('ol'); $root->appendChild($list); foreach ($this->links as $link) { $list_item = $document->createElement('li'); $list->appendChild($list_item); $link_element = $document->createElement('a'); $list_item->appendChild($link_element); $link_element->appendChild($document->createTextNode($this->getCaption($link))); $link_element->setAttribute('href', str_replace('\\', '/', $link) . '.html'); } }
[ "public", "function", "toXhtml", "(", "\\", "DOMDocument", "$", "document", ",", "\\", "DOMElement", "$", "root", ")", "{", "$", "this", "->", "addLinksToTableOfContents", "(", ")", ";", "// if the hidden flag is set then this item should not be rendered but still processed (see above)", "if", "(", "isset", "(", "$", "this", "->", "node", "->", "options", "[", "'hidden'", "]", ")", ")", "{", "return", ";", "}", "$", "list", "=", "$", "document", "->", "createElement", "(", "'ol'", ")", ";", "$", "root", "->", "appendChild", "(", "$", "list", ")", ";", "foreach", "(", "$", "this", "->", "links", "as", "$", "link", ")", "{", "$", "list_item", "=", "$", "document", "->", "createElement", "(", "'li'", ")", ";", "$", "list", "->", "appendChild", "(", "$", "list_item", ")", ";", "$", "link_element", "=", "$", "document", "->", "createElement", "(", "'a'", ")", ";", "$", "list_item", "->", "appendChild", "(", "$", "link_element", ")", ";", "$", "link_element", "->", "appendChild", "(", "$", "document", "->", "createTextNode", "(", "$", "this", "->", "getCaption", "(", "$", "link", ")", ")", ")", ";", "$", "link_element", "->", "setAttribute", "(", "'href'", ",", "str_replace", "(", "'\\\\'", ",", "'/'", ",", "$", "link", ")", ".", "'.html'", ")", ";", "}", "}" ]
Transform directive to HTML Create a XHTML structure at the directives position in the document. @todo use the TableofContents collection to extract a sublisting up to the given depth or 2 if none is provided
[ "Transform", "directive", "to", "HTML" ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Scrybe/Converter/RestructuredText/Directives/Toctree.php#L81-L102
phpDocumentor/phpDocumentor2
src/phpDocumentor/Plugin/Scrybe/Converter/RestructuredText/Directives/Toctree.php
Toctree.getCaption
protected function getCaption($file_name) { if ($this->visitor instanceof Creator) { $toc = $this->visitor->getTableOfContents(); $name = $toc[$file_name]->getName(); return $name ?: $file_name; } return $file_name; }
php
protected function getCaption($file_name) { if ($this->visitor instanceof Creator) { $toc = $this->visitor->getTableOfContents(); $name = $toc[$file_name]->getName(); return $name ?: $file_name; } return $file_name; }
[ "protected", "function", "getCaption", "(", "$", "file_name", ")", "{", "if", "(", "$", "this", "->", "visitor", "instanceof", "Creator", ")", "{", "$", "toc", "=", "$", "this", "->", "visitor", "->", "getTableOfContents", "(", ")", ";", "$", "name", "=", "$", "toc", "[", "$", "file_name", "]", "->", "getName", "(", ")", ";", "return", "$", "name", "?", ":", "$", "file_name", ";", "}", "return", "$", "file_name", ";", "}" ]
Retrieves the caption for the given $token. The caption is retrieved by converting the filename to a human-readable format. @param \ezcDocumentRstToken $file_name @return string
[ "Retrieves", "the", "caption", "for", "the", "given", "$token", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Scrybe/Converter/RestructuredText/Directives/Toctree.php#L127-L136
phpDocumentor/phpDocumentor2
src/phpDocumentor/Plugin/Scrybe/Converter/RestructuredText/Document.php
Document.logStats
public function logStats($fatal, Logger $logger) { if (!$this->getErrors() && !$fatal) { return; } /** @var \Exception $error */ foreach ($this->getErrors() as $error) { $logger->warning(' ' . $error->getMessage()); } if ($fatal) { $logger->error(' ' . $fatal->getMessage()); } }
php
public function logStats($fatal, Logger $logger) { if (!$this->getErrors() && !$fatal) { return; } foreach ($this->getErrors() as $error) { $logger->warning(' ' . $error->getMessage()); } if ($fatal) { $logger->error(' ' . $fatal->getMessage()); } }
[ "public", "function", "logStats", "(", "$", "fatal", ",", "Logger", "$", "logger", ")", "{", "if", "(", "!", "$", "this", "->", "getErrors", "(", ")", "&&", "!", "$", "fatal", ")", "{", "return", ";", "}", "/** @var \\Exception $error */", "foreach", "(", "$", "this", "->", "getErrors", "(", ")", "as", "$", "error", ")", "{", "$", "logger", "->", "warning", "(", "' '", ".", "$", "error", "->", "getMessage", "(", ")", ")", ";", "}", "if", "(", "$", "fatal", ")", "{", "$", "logger", "->", "error", "(", "' '", ".", "$", "fatal", "->", "getMessage", "(", ")", ")", ";", "}", "}" ]
Sends the errors of the given Rst document to the logger as a block. If a fatal error occurred then this can be passed as the $fatal argument and is shown as such. @param \Exception|null $fatal
[ "Sends", "the", "errors", "of", "the", "given", "Rst", "document", "to", "the", "logger", "as", "a", "block", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Scrybe/Converter/RestructuredText/Document.php#L114-L128
phpDocumentor/phpDocumentor2
src/phpDocumentor/Descriptor/InterfaceDescriptor.php
InterfaceDescriptor.getInheritedConstants
public function getInheritedConstants() { if (!$this->getParent() || !$this->getParent() instanceof Collection || $this->getParent()->count() === 0) { return new Collection(); } $inheritedConstants = new Collection(); /** @var self $parent */ foreach ($this->getParent() as $parent) { if (!$parent instanceof Interfaces\InterfaceInterface) { continue; } $inheritedConstants = $inheritedConstants->merge($parent->getConstants()); $inheritedConstants = $inheritedConstants->merge($parent->getInheritedConstants()); } return $inheritedConstants; }
php
public function getInheritedConstants() { if (!$this->getParent() || !$this->getParent() instanceof Collection || $this->getParent()->count() === 0) { return new Collection(); } $inheritedConstants = new Collection(); foreach ($this->getParent() as $parent) { if (!$parent instanceof Interfaces\InterfaceInterface) { continue; } $inheritedConstants = $inheritedConstants->merge($parent->getConstants()); $inheritedConstants = $inheritedConstants->merge($parent->getInheritedConstants()); } return $inheritedConstants; }
[ "public", "function", "getInheritedConstants", "(", ")", "{", "if", "(", "!", "$", "this", "->", "getParent", "(", ")", "||", "!", "$", "this", "->", "getParent", "(", ")", "instanceof", "Collection", "||", "$", "this", "->", "getParent", "(", ")", "->", "count", "(", ")", "===", "0", ")", "{", "return", "new", "Collection", "(", ")", ";", "}", "$", "inheritedConstants", "=", "new", "Collection", "(", ")", ";", "/** @var self $parent */", "foreach", "(", "$", "this", "->", "getParent", "(", ")", "as", "$", "parent", ")", "{", "if", "(", "!", "$", "parent", "instanceof", "Interfaces", "\\", "InterfaceInterface", ")", "{", "continue", ";", "}", "$", "inheritedConstants", "=", "$", "inheritedConstants", "->", "merge", "(", "$", "parent", "->", "getConstants", "(", ")", ")", ";", "$", "inheritedConstants", "=", "$", "inheritedConstants", "->", "merge", "(", "$", "parent", "->", "getInheritedConstants", "(", ")", ")", ";", "}", "return", "$", "inheritedConstants", ";", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/InterfaceDescriptor.php#L79-L98
phpDocumentor/phpDocumentor2
src/phpDocumentor/Descriptor/InterfaceDescriptor.php
InterfaceDescriptor.getInheritedMethods
public function getInheritedMethods() { if (!$this->getParent() || !$this->getParent() instanceof Collection || $this->getParent()->count() === 0) { return new Collection(); } $inheritedMethods = new Collection(); /** @var self $parent */ foreach ($this->getParent() as $parent) { if (!$parent instanceof Interfaces\InterfaceInterface) { continue; } $inheritedMethods = $inheritedMethods->merge($parent->getMethods()); $inheritedMethods = $inheritedMethods->merge($parent->getInheritedMethods()); } return $inheritedMethods; }
php
public function getInheritedMethods() { if (!$this->getParent() || !$this->getParent() instanceof Collection || $this->getParent()->count() === 0) { return new Collection(); } $inheritedMethods = new Collection(); foreach ($this->getParent() as $parent) { if (!$parent instanceof Interfaces\InterfaceInterface) { continue; } $inheritedMethods = $inheritedMethods->merge($parent->getMethods()); $inheritedMethods = $inheritedMethods->merge($parent->getInheritedMethods()); } return $inheritedMethods; }
[ "public", "function", "getInheritedMethods", "(", ")", "{", "if", "(", "!", "$", "this", "->", "getParent", "(", ")", "||", "!", "$", "this", "->", "getParent", "(", ")", "instanceof", "Collection", "||", "$", "this", "->", "getParent", "(", ")", "->", "count", "(", ")", "===", "0", ")", "{", "return", "new", "Collection", "(", ")", ";", "}", "$", "inheritedMethods", "=", "new", "Collection", "(", ")", ";", "/** @var self $parent */", "foreach", "(", "$", "this", "->", "getParent", "(", ")", "as", "$", "parent", ")", "{", "if", "(", "!", "$", "parent", "instanceof", "Interfaces", "\\", "InterfaceInterface", ")", "{", "continue", ";", "}", "$", "inheritedMethods", "=", "$", "inheritedMethods", "->", "merge", "(", "$", "parent", "->", "getMethods", "(", ")", ")", ";", "$", "inheritedMethods", "=", "$", "inheritedMethods", "->", "merge", "(", "$", "parent", "->", "getInheritedMethods", "(", ")", ")", ";", "}", "return", "$", "inheritedMethods", ";", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/InterfaceDescriptor.php#L119-L138
phpDocumentor/phpDocumentor2
src/phpDocumentor/Descriptor/Builder/Reflector/Tags/MethodAssembler.php
MethodAssembler.create
public function create($data) { $descriptor = new MethodDescriptor($data->getName()); $descriptor->setDescription($data->getDescription()); $descriptor->setMethodName($data->getMethodName()); $descriptor->setStatic($data->isStatic()); $response = new ReturnDescriptor('return'); $response->setType($data->getReturnType()); $descriptor->setResponse($response); foreach ($data->getArguments() as $argument) { if (array_key_exists('name', $argument) && array_key_exists('type', $argument)) { $argumentDescriptor = $this->createArgumentDescriptorForMagicMethod( $argument['name'], $argument['type'] ); $descriptor->getArguments()->set($argumentDescriptor->getName(), $argumentDescriptor); } } return $descriptor; }
php
public function create($data) { $descriptor = new MethodDescriptor($data->getName()); $descriptor->setDescription($data->getDescription()); $descriptor->setMethodName($data->getMethodName()); $descriptor->setStatic($data->isStatic()); $response = new ReturnDescriptor('return'); $response->setType($data->getReturnType()); $descriptor->setResponse($response); foreach ($data->getArguments() as $argument) { if (array_key_exists('name', $argument) && array_key_exists('type', $argument)) { $argumentDescriptor = $this->createArgumentDescriptorForMagicMethod( $argument['name'], $argument['type'] ); $descriptor->getArguments()->set($argumentDescriptor->getName(), $argumentDescriptor); } } return $descriptor; }
[ "public", "function", "create", "(", "$", "data", ")", "{", "$", "descriptor", "=", "new", "MethodDescriptor", "(", "$", "data", "->", "getName", "(", ")", ")", ";", "$", "descriptor", "->", "setDescription", "(", "$", "data", "->", "getDescription", "(", ")", ")", ";", "$", "descriptor", "->", "setMethodName", "(", "$", "data", "->", "getMethodName", "(", ")", ")", ";", "$", "descriptor", "->", "setStatic", "(", "$", "data", "->", "isStatic", "(", ")", ")", ";", "$", "response", "=", "new", "ReturnDescriptor", "(", "'return'", ")", ";", "$", "response", "->", "setType", "(", "$", "data", "->", "getReturnType", "(", ")", ")", ";", "$", "descriptor", "->", "setResponse", "(", "$", "response", ")", ";", "foreach", "(", "$", "data", "->", "getArguments", "(", ")", "as", "$", "argument", ")", "{", "if", "(", "array_key_exists", "(", "'name'", ",", "$", "argument", ")", "&&", "array_key_exists", "(", "'type'", ",", "$", "argument", ")", ")", "{", "$", "argumentDescriptor", "=", "$", "this", "->", "createArgumentDescriptorForMagicMethod", "(", "$", "argument", "[", "'name'", "]", ",", "$", "argument", "[", "'type'", "]", ")", ";", "$", "descriptor", "->", "getArguments", "(", ")", "->", "set", "(", "$", "argumentDescriptor", "->", "getName", "(", ")", ",", "$", "argumentDescriptor", ")", ";", "}", "}", "return", "$", "descriptor", ";", "}" ]
Creates a new Descriptor from the given Reflector. @param Method $data @return MethodDescriptor
[ "Creates", "a", "new", "Descriptor", "from", "the", "given", "Reflector", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/Builder/Reflector/Tags/MethodAssembler.php#L40-L62
phpDocumentor/phpDocumentor2
src/phpDocumentor/Descriptor/Builder/Reflector/Tags/MethodAssembler.php
MethodAssembler.createArgumentDescriptorForMagicMethod
private function createArgumentDescriptorForMagicMethod(string $name, Type $type): ArgumentDescriptor { $argumentDescriptor = new ArgumentDescriptor(); $argumentDescriptor->setType(AssemblerAbstract::deduplicateTypes($type)); $argumentDescriptor->setName($name); return $argumentDescriptor; }
php
private function createArgumentDescriptorForMagicMethod(string $name, Type $type): ArgumentDescriptor { $argumentDescriptor = new ArgumentDescriptor(); $argumentDescriptor->setType(AssemblerAbstract::deduplicateTypes($type)); $argumentDescriptor->setName($name); return $argumentDescriptor; }
[ "private", "function", "createArgumentDescriptorForMagicMethod", "(", "string", "$", "name", ",", "Type", "$", "type", ")", ":", "ArgumentDescriptor", "{", "$", "argumentDescriptor", "=", "new", "ArgumentDescriptor", "(", ")", ";", "$", "argumentDescriptor", "->", "setType", "(", "AssemblerAbstract", "::", "deduplicateTypes", "(", "$", "type", ")", ")", ";", "$", "argumentDescriptor", "->", "setName", "(", "$", "name", ")", ";", "return", "$", "argumentDescriptor", ";", "}" ]
Construct an argument descriptor given the array representing an argument with a Method Tag in the Reflection component.
[ "Construct", "an", "argument", "descriptor", "given", "the", "array", "representing", "an", "argument", "with", "a", "Method", "Tag", "in", "the", "Reflection", "component", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Descriptor/Builder/Reflector/Tags/MethodAssembler.php#L68-L75
phpDocumentor/phpDocumentor2
src/phpDocumentor/Plugin/Core/Transformer/Writer/Statistics.php
Statistics.transform
public function transform(ProjectDescriptor $project, Transformation $transformation) { $artifact = $this->getDestinationPath($transformation); $now = new \DateTime('now'); $date = $now->format(DATE_ATOM); $document = new \DOMDocument(); $document->formatOutput = true; $document->preserveWhiteSpace = false; if (is_file($artifact)) { $document->load($artifact); } else { $document = $this->appendPhpdocStatsElement($document); } $document = $this->appendStatElement($document, $project, $date); $this->saveCheckstyleReport($artifact, $document); }
php
public function transform(ProjectDescriptor $project, Transformation $transformation) { $artifact = $this->getDestinationPath($transformation); $now = new \DateTime('now'); $date = $now->format(DATE_ATOM); $document = new \DOMDocument(); $document->formatOutput = true; $document->preserveWhiteSpace = false; if (is_file($artifact)) { $document->load($artifact); } else { $document = $this->appendPhpdocStatsElement($document); } $document = $this->appendStatElement($document, $project, $date); $this->saveCheckstyleReport($artifact, $document); }
[ "public", "function", "transform", "(", "ProjectDescriptor", "$", "project", ",", "Transformation", "$", "transformation", ")", "{", "$", "artifact", "=", "$", "this", "->", "getDestinationPath", "(", "$", "transformation", ")", ";", "$", "now", "=", "new", "\\", "DateTime", "(", "'now'", ")", ";", "$", "date", "=", "$", "now", "->", "format", "(", "DATE_ATOM", ")", ";", "$", "document", "=", "new", "\\", "DOMDocument", "(", ")", ";", "$", "document", "->", "formatOutput", "=", "true", ";", "$", "document", "->", "preserveWhiteSpace", "=", "false", ";", "if", "(", "is_file", "(", "$", "artifact", ")", ")", "{", "$", "document", "->", "load", "(", "$", "artifact", ")", ";", "}", "else", "{", "$", "document", "=", "$", "this", "->", "appendPhpdocStatsElement", "(", "$", "document", ")", ";", "}", "$", "document", "=", "$", "this", "->", "appendStatElement", "(", "$", "document", ",", "$", "project", ",", "$", "date", ")", ";", "$", "this", "->", "saveCheckstyleReport", "(", "$", "artifact", ",", "$", "document", ")", ";", "}" ]
This method generates the checkstyle.xml report @param ProjectDescriptor $project Document containing the structure. @param Transformation $transformation Transformation to execute.
[ "This", "method", "generates", "the", "checkstyle", ".", "xml", "report" ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Core/Transformer/Writer/Statistics.php#L51-L71
phpDocumentor/phpDocumentor2
src/phpDocumentor/Plugin/Core/Transformer/Writer/Statistics.php
Statistics.appendPhpdocStatsElement
protected function appendPhpdocStatsElement(\DOMDocument $document) { $stats = $document->createElement('phpdoc-stats'); $stats->setAttribute('version', Application::VERSION()); $document->appendChild($stats); return $document; }
php
protected function appendPhpdocStatsElement(\DOMDocument $document) { $stats = $document->createElement('phpdoc-stats'); $stats->setAttribute('version', Application::VERSION()); $document->appendChild($stats); return $document; }
[ "protected", "function", "appendPhpdocStatsElement", "(", "\\", "DOMDocument", "$", "document", ")", "{", "$", "stats", "=", "$", "document", "->", "createElement", "(", "'phpdoc-stats'", ")", ";", "$", "stats", "->", "setAttribute", "(", "'version'", ",", "Application", "::", "VERSION", "(", ")", ")", ";", "$", "document", "->", "appendChild", "(", "$", "stats", ")", ";", "return", "$", "document", ";", "}" ]
Append phpdoc-stats element to the document. @return \DOMDocument
[ "Append", "phpdoc", "-", "stats", "element", "to", "the", "document", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Core/Transformer/Writer/Statistics.php#L78-L85
phpDocumentor/phpDocumentor2
src/phpDocumentor/Plugin/Core/Transformer/Writer/Statistics.php
Statistics.appendStatElement
protected function appendStatElement(\DOMDocument $document, ProjectDescriptor $project, $date) { $stat = $document->createDocumentFragment(); $stat->appendXML( <<<STAT <stat date="${date}"> <counters> <files>{$this->getFilesCounter($project)}</files> <deprecated>{$this->getDeprecatedCounter($project)}</deprecated> <errors>{$this->getErrorCounter($project)}</errors> <markers>{$this->getMarkerCounter($project)}</markers> </counters> </stat> STAT ); $document->documentElement->appendChild($stat); return $document; }
php
protected function appendStatElement(\DOMDocument $document, ProjectDescriptor $project, $date) { $stat = $document->createDocumentFragment(); $stat->appendXML( <<<STAT <stat date="${date}"> <counters> <files>{$this->getFilesCounter($project)}</files> <deprecated>{$this->getDeprecatedCounter($project)}</deprecated> <errors>{$this->getErrorCounter($project)}</errors> <markers>{$this->getMarkerCounter($project)}</markers> </counters> </stat> STAT ); $document->documentElement->appendChild($stat); return $document; }
[ "protected", "function", "appendStatElement", "(", "\\", "DOMDocument", "$", "document", ",", "ProjectDescriptor", "$", "project", ",", "$", "date", ")", "{", "$", "stat", "=", "$", "document", "->", "createDocumentFragment", "(", ")", ";", "$", "stat", "->", "appendXML", "(", "\n <<<STAT\n<stat date=\"${date}\">\n <counters>\n <files>{$this->getFilesCounter($project)}</files>\n <deprecated>{$this->getDeprecatedCounter($project)}</deprecated>\n <errors>{$this->getErrorCounter($project)}</errors>\n <markers>{$this->getMarkerCounter($project)}</markers>\n </counters>\n</stat>\nSTAT", ")", ";", "$", "document", "->", "documentElement", "->", "appendChild", "(", "$", "stat", ")", ";", "return", "$", "document", ";", "}" ]
Appends a stat fragment. @param string $date @return \DOMDocument
[ "Appends", "a", "stat", "fragment", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Core/Transformer/Writer/Statistics.php#L93-L111
phpDocumentor/phpDocumentor2
src/phpDocumentor/Plugin/Core/Transformer/Writer/Statistics.php
Statistics.getErrorCounter
protected function getErrorCounter(ProjectDescriptor $project) { $errorCounter = 0; /* @var FileDescriptor $fileDescriptor */ foreach ($project->getFiles()->getAll() as $fileDescriptor) { $errorCounter += count($fileDescriptor->getAllErrors()->getAll()); } return $errorCounter; }
php
protected function getErrorCounter(ProjectDescriptor $project) { $errorCounter = 0; foreach ($project->getFiles()->getAll() as $fileDescriptor) { $errorCounter += count($fileDescriptor->getAllErrors()->getAll()); } return $errorCounter; }
[ "protected", "function", "getErrorCounter", "(", "ProjectDescriptor", "$", "project", ")", "{", "$", "errorCounter", "=", "0", ";", "/* @var FileDescriptor $fileDescriptor */", "foreach", "(", "$", "project", "->", "getFiles", "(", ")", "->", "getAll", "(", ")", "as", "$", "fileDescriptor", ")", "{", "$", "errorCounter", "+=", "count", "(", "$", "fileDescriptor", "->", "getAllErrors", "(", ")", "->", "getAll", "(", ")", ")", ";", "}", "return", "$", "errorCounter", ";", "}" ]
Get number of errors. @return int
[ "Get", "number", "of", "errors", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Core/Transformer/Writer/Statistics.php#L147-L157
phpDocumentor/phpDocumentor2
src/phpDocumentor/Plugin/Core/Transformer/Writer/Statistics.php
Statistics.getMarkerCounter
protected function getMarkerCounter(ProjectDescriptor $project) { $markerCounter = 0; /* @var $fileDescriptor FileDescriptor */ foreach ($project->getFiles()->getAll() as $fileDescriptor) { $markerCounter += $fileDescriptor->getMarkers()->count(); } return $markerCounter; }
php
protected function getMarkerCounter(ProjectDescriptor $project) { $markerCounter = 0; foreach ($project->getFiles()->getAll() as $fileDescriptor) { $markerCounter += $fileDescriptor->getMarkers()->count(); } return $markerCounter; }
[ "protected", "function", "getMarkerCounter", "(", "ProjectDescriptor", "$", "project", ")", "{", "$", "markerCounter", "=", "0", ";", "/* @var $fileDescriptor FileDescriptor */", "foreach", "(", "$", "project", "->", "getFiles", "(", ")", "->", "getAll", "(", ")", "as", "$", "fileDescriptor", ")", "{", "$", "markerCounter", "+=", "$", "fileDescriptor", "->", "getMarkers", "(", ")", "->", "count", "(", ")", ";", "}", "return", "$", "markerCounter", ";", "}" ]
Get number of markers. @return int
[ "Get", "number", "of", "markers", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Core/Transformer/Writer/Statistics.php#L164-L174
phpDocumentor/phpDocumentor2
src/phpDocumentor/Application/Console/Command/Phar/UpdateCommand.php
UpdateCommand.execute
protected function execute(InputInterface $input, OutputInterface $output): int { $output->writeln('Looking for updates...'); $allowPreRelease = $input->getOption('pre'); if (PHP_VERSION_ID < 50600) { $message = 'Self updating is not available in PHP versions under 5.6.' . "\n"; $message .= 'The latest version can be found at ' . self::PHAR_URL; $output->writeln(sprintf('<error>%s</error>', $message)); return 1; } elseif (Application::VERSION() === ('@package_version@')) { $output->writeln('<error>Self updating has been disabled in source version.</error>'); return 1; } $exitCode = 1; $updater = new Updater(); $updater->setStrategy(Updater::STRATEGY_GITHUB); $updater->getStrategy()->setPackageName('phpdocumentor/phpDocumentor2'); $updater->getStrategy()->setPharName('phpDocumentor.phar'); $updater->getStrategy()->getCurrentLocalVersion(Application::VERSION()); if ($allowPreRelease) { $updater->getStrategy()->setStability(GithubStrategy::ANY); } try { if ($input->getOption('rollback')) { $output->writeln('Rolling back to previous version...'); $result = $updater->rollback(); } else { if (!$updater->hasUpdate()) { $output->writeln('No new version available.'); return 0; } $output->writeln('Updating to newer version...'); $result = $updater->update(); } if ($result) { $new = $updater->getNewVersion(); $old = $updater->getOldVersion(); $output->writeln(sprintf('Updated from %s to %s', $old, $new)); $exitCode = 0; } } catch (Exception $e) { $output->writeln(sprintf('<error>%s</error>', $e->getMessage())); } return $exitCode; }
php
protected function execute(InputInterface $input, OutputInterface $output): int { $output->writeln('Looking for updates...'); $allowPreRelease = $input->getOption('pre'); if (PHP_VERSION_ID < 50600) { $message = 'Self updating is not available in PHP versions under 5.6.' . "\n"; $message .= 'The latest version can be found at ' . self::PHAR_URL; $output->writeln(sprintf('<error>%s</error>', $message)); return 1; } elseif (Application::VERSION() === ('@package_version@')) { $output->writeln('<error>Self updating has been disabled in source version.</error>'); return 1; } $exitCode = 1; $updater = new Updater(); $updater->setStrategy(Updater::STRATEGY_GITHUB); $updater->getStrategy()->setPackageName('phpdocumentor/phpDocumentor2'); $updater->getStrategy()->setPharName('phpDocumentor.phar'); $updater->getStrategy()->getCurrentLocalVersion(Application::VERSION()); if ($allowPreRelease) { $updater->getStrategy()->setStability(GithubStrategy::ANY); } try { if ($input->getOption('rollback')) { $output->writeln('Rolling back to previous version...'); $result = $updater->rollback(); } else { if (!$updater->hasUpdate()) { $output->writeln('No new version available.'); return 0; } $output->writeln('Updating to newer version...'); $result = $updater->update(); } if ($result) { $new = $updater->getNewVersion(); $old = $updater->getOldVersion(); $output->writeln(sprintf('Updated from %s to %s', $old, $new)); $exitCode = 0; } } catch (Exception $e) { $output->writeln(sprintf('<error>%s</error>', $e->getMessage())); } return $exitCode; }
[ "protected", "function", "execute", "(", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ")", ":", "int", "{", "$", "output", "->", "writeln", "(", "'Looking for updates...'", ")", ";", "$", "allowPreRelease", "=", "$", "input", "->", "getOption", "(", "'pre'", ")", ";", "if", "(", "PHP_VERSION_ID", "<", "50600", ")", "{", "$", "message", "=", "'Self updating is not available in PHP versions under 5.6.'", ".", "\"\\n\"", ";", "$", "message", ".=", "'The latest version can be found at '", ".", "self", "::", "PHAR_URL", ";", "$", "output", "->", "writeln", "(", "sprintf", "(", "'<error>%s</error>'", ",", "$", "message", ")", ")", ";", "return", "1", ";", "}", "elseif", "(", "Application", "::", "VERSION", "(", ")", "===", "(", "'@package_version@'", ")", ")", "{", "$", "output", "->", "writeln", "(", "'<error>Self updating has been disabled in source version.</error>'", ")", ";", "return", "1", ";", "}", "$", "exitCode", "=", "1", ";", "$", "updater", "=", "new", "Updater", "(", ")", ";", "$", "updater", "->", "setStrategy", "(", "Updater", "::", "STRATEGY_GITHUB", ")", ";", "$", "updater", "->", "getStrategy", "(", ")", "->", "setPackageName", "(", "'phpdocumentor/phpDocumentor2'", ")", ";", "$", "updater", "->", "getStrategy", "(", ")", "->", "setPharName", "(", "'phpDocumentor.phar'", ")", ";", "$", "updater", "->", "getStrategy", "(", ")", "->", "getCurrentLocalVersion", "(", "Application", "::", "VERSION", "(", ")", ")", ";", "if", "(", "$", "allowPreRelease", ")", "{", "$", "updater", "->", "getStrategy", "(", ")", "->", "setStability", "(", "GithubStrategy", "::", "ANY", ")", ";", "}", "try", "{", "if", "(", "$", "input", "->", "getOption", "(", "'rollback'", ")", ")", "{", "$", "output", "->", "writeln", "(", "'Rolling back to previous version...'", ")", ";", "$", "result", "=", "$", "updater", "->", "rollback", "(", ")", ";", "}", "else", "{", "if", "(", "!", "$", "updater", "->", "hasUpdate", "(", ")", ")", "{", "$", "output", "->", "writeln", "(", "'No new version available.'", ")", ";", "return", "0", ";", "}", "$", "output", "->", "writeln", "(", "'Updating to newer version...'", ")", ";", "$", "result", "=", "$", "updater", "->", "update", "(", ")", ";", "}", "if", "(", "$", "result", ")", "{", "$", "new", "=", "$", "updater", "->", "getNewVersion", "(", ")", ";", "$", "old", "=", "$", "updater", "->", "getOldVersion", "(", ")", ";", "$", "output", "->", "writeln", "(", "sprintf", "(", "'Updated from %s to %s'", ",", "$", "old", ",", "$", "new", ")", ")", ";", "$", "exitCode", "=", "0", ";", "}", "}", "catch", "(", "Exception", "$", "e", ")", "{", "$", "output", "->", "writeln", "(", "sprintf", "(", "'<error>%s</error>'", ",", "$", "e", "->", "getMessage", "(", ")", ")", ")", ";", "}", "return", "$", "exitCode", ";", "}" ]
Executes the business logic involved with this command.
[ "Executes", "the", "business", "logic", "involved", "with", "this", "command", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Application/Console/Command/Phar/UpdateCommand.php#L60-L114
phpDocumentor/phpDocumentor2
src/phpDocumentor/Plugin/Core/Transformer/Writer/Xml/PropertyConverter.php
PropertyConverter.convert
public function convert(\DOMElement $parent, PropertyDescriptor $property) { $fullyQualifiedNamespaceName = $property->getNamespace() instanceof NamespaceDescriptor ? $property->getNamespace()->getFullyQualifiedStructuralElementName() : $parent->getAttribute('namespace'); $child = new \DOMElement('property'); $parent->appendChild($child); $child->setAttribute('static', var_export($property->isStatic(), true)); $child->setAttribute('visibility', $property->getVisibility()); $child->setAttribute('namespace', $fullyQualifiedNamespaceName); $child->setAttribute('line', (string) $property->getLine()); $child->appendChild(new \DOMElement('name', '$' . $property->getName())); $child->appendChild(new \DOMElement('full_name', (string) $property->getFullyQualifiedStructuralElementName())); $child->appendChild(new \DOMElement('default'))->appendChild(new \DOMText((string) $property->getDefault())); $this->docBlockConverter->convert($child, $property); return $child; }
php
public function convert(\DOMElement $parent, PropertyDescriptor $property) { $fullyQualifiedNamespaceName = $property->getNamespace() instanceof NamespaceDescriptor ? $property->getNamespace()->getFullyQualifiedStructuralElementName() : $parent->getAttribute('namespace'); $child = new \DOMElement('property'); $parent->appendChild($child); $child->setAttribute('static', var_export($property->isStatic(), true)); $child->setAttribute('visibility', $property->getVisibility()); $child->setAttribute('namespace', $fullyQualifiedNamespaceName); $child->setAttribute('line', (string) $property->getLine()); $child->appendChild(new \DOMElement('name', '$' . $property->getName())); $child->appendChild(new \DOMElement('full_name', (string) $property->getFullyQualifiedStructuralElementName())); $child->appendChild(new \DOMElement('default'))->appendChild(new \DOMText((string) $property->getDefault())); $this->docBlockConverter->convert($child, $property); return $child; }
[ "public", "function", "convert", "(", "\\", "DOMElement", "$", "parent", ",", "PropertyDescriptor", "$", "property", ")", "{", "$", "fullyQualifiedNamespaceName", "=", "$", "property", "->", "getNamespace", "(", ")", "instanceof", "NamespaceDescriptor", "?", "$", "property", "->", "getNamespace", "(", ")", "->", "getFullyQualifiedStructuralElementName", "(", ")", ":", "$", "parent", "->", "getAttribute", "(", "'namespace'", ")", ";", "$", "child", "=", "new", "\\", "DOMElement", "(", "'property'", ")", ";", "$", "parent", "->", "appendChild", "(", "$", "child", ")", ";", "$", "child", "->", "setAttribute", "(", "'static'", ",", "var_export", "(", "$", "property", "->", "isStatic", "(", ")", ",", "true", ")", ")", ";", "$", "child", "->", "setAttribute", "(", "'visibility'", ",", "$", "property", "->", "getVisibility", "(", ")", ")", ";", "$", "child", "->", "setAttribute", "(", "'namespace'", ",", "$", "fullyQualifiedNamespaceName", ")", ";", "$", "child", "->", "setAttribute", "(", "'line'", ",", "(", "string", ")", "$", "property", "->", "getLine", "(", ")", ")", ";", "$", "child", "->", "appendChild", "(", "new", "\\", "DOMElement", "(", "'name'", ",", "'$'", ".", "$", "property", "->", "getName", "(", ")", ")", ")", ";", "$", "child", "->", "appendChild", "(", "new", "\\", "DOMElement", "(", "'full_name'", ",", "(", "string", ")", "$", "property", "->", "getFullyQualifiedStructuralElementName", "(", ")", ")", ")", ";", "$", "child", "->", "appendChild", "(", "new", "\\", "DOMElement", "(", "'default'", ")", ")", "->", "appendChild", "(", "new", "\\", "DOMText", "(", "(", "string", ")", "$", "property", "->", "getDefault", "(", ")", ")", ")", ";", "$", "this", "->", "docBlockConverter", "->", "convert", "(", "$", "child", ",", "$", "property", ")", ";", "return", "$", "child", ";", "}" ]
Export the given reflected property definition to the provided parent element. @param \DOMElement $parent Element to augment. @param PropertyDescriptor $property Element to export. @return \DOMElement
[ "Export", "the", "given", "reflected", "property", "definition", "to", "the", "provided", "parent", "element", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Core/Transformer/Writer/Xml/PropertyConverter.php#L47-L68
phpDocumentor/phpDocumentor2
src/phpDocumentor/Plugin/Core/ServiceProvider.php
ServiceProvider.register
public function register(Container $app): void { $this->registerWriters($app); $this->registerDependenciesOnXsltExtension($app); $app->register(new \phpDocumentor\Plugin\Graphs\ServiceProvider()); $app->register(new \phpDocumentor\Plugin\Twig\ServiceProvider()); }
php
public function register(Container $app): void { $this->registerWriters($app); $this->registerDependenciesOnXsltExtension($app); $app->register(new \phpDocumentor\Plugin\Graphs\ServiceProvider()); $app->register(new \phpDocumentor\Plugin\Twig\ServiceProvider()); }
[ "public", "function", "register", "(", "Container", "$", "app", ")", ":", "void", "{", "$", "this", "->", "registerWriters", "(", "$", "app", ")", ";", "$", "this", "->", "registerDependenciesOnXsltExtension", "(", "$", "app", ")", ";", "$", "app", "->", "register", "(", "new", "\\", "phpDocumentor", "\\", "Plugin", "\\", "Graphs", "\\", "ServiceProvider", "(", ")", ")", ";", "$", "app", "->", "register", "(", "new", "\\", "phpDocumentor", "\\", "Plugin", "\\", "Twig", "\\", "ServiceProvider", "(", ")", ")", ";", "}" ]
Registers services on the given app. @param Container $app An Application instance.
[ "Registers", "services", "on", "the", "given", "app", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Core/ServiceProvider.php#L39-L46
phpDocumentor/phpDocumentor2
src/phpDocumentor/Plugin/Core/ServiceProvider.php
ServiceProvider.registerWriters
private function registerWriters(Application $app) { $writerCollection = $this->getWriterCollection($app); $writerCollection['FileIo'] = new Writer\FileIo(); $writerCollection['sourcecode'] = new Writer\Sourcecode(); $writerCollection['statistics'] = new Writer\Statistics(); $writerCollection['xsl'] = new Writer\Xsl($app['monolog']); $checkstyleWriter = new Writer\Checkstyle(); $writerCollection['checkstyle'] = $checkstyleWriter; $xmlWriter = new Writer\Xml($app['transformer.routing.standard']); $writerCollection['xml'] = $xmlWriter; }
php
private function registerWriters(Application $app) { $writerCollection = $this->getWriterCollection($app); $writerCollection['FileIo'] = new Writer\FileIo(); $writerCollection['sourcecode'] = new Writer\Sourcecode(); $writerCollection['statistics'] = new Writer\Statistics(); $writerCollection['xsl'] = new Writer\Xsl($app['monolog']); $checkstyleWriter = new Writer\Checkstyle(); $writerCollection['checkstyle'] = $checkstyleWriter; $xmlWriter = new Writer\Xml($app['transformer.routing.standard']); $writerCollection['xml'] = $xmlWriter; }
[ "private", "function", "registerWriters", "(", "Application", "$", "app", ")", "{", "$", "writerCollection", "=", "$", "this", "->", "getWriterCollection", "(", "$", "app", ")", ";", "$", "writerCollection", "[", "'FileIo'", "]", "=", "new", "Writer", "\\", "FileIo", "(", ")", ";", "$", "writerCollection", "[", "'sourcecode'", "]", "=", "new", "Writer", "\\", "Sourcecode", "(", ")", ";", "$", "writerCollection", "[", "'statistics'", "]", "=", "new", "Writer", "\\", "Statistics", "(", ")", ";", "$", "writerCollection", "[", "'xsl'", "]", "=", "new", "Writer", "\\", "Xsl", "(", "$", "app", "[", "'monolog'", "]", ")", ";", "$", "checkstyleWriter", "=", "new", "Writer", "\\", "Checkstyle", "(", ")", ";", "$", "writerCollection", "[", "'checkstyle'", "]", "=", "$", "checkstyleWriter", ";", "$", "xmlWriter", "=", "new", "Writer", "\\", "Xml", "(", "$", "app", "[", "'transformer.routing.standard'", "]", ")", ";", "$", "writerCollection", "[", "'xml'", "]", "=", "$", "xmlWriter", ";", "}" ]
Creates all writers for this plugin and adds them to the WriterCollection object. This action will enable transformations in templates to make use of these writers.
[ "Creates", "all", "writers", "for", "this", "plugin", "and", "adds", "them", "to", "the", "WriterCollection", "object", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Core/ServiceProvider.php#L53-L67
phpDocumentor/phpDocumentor2
src/phpDocumentor/Plugin/Core/ServiceProvider.php
ServiceProvider.registerDependenciesOnXsltExtension
private function registerDependenciesOnXsltExtension(Application $app) { $queue = new Queue(); $queue->insert($app['transformer.routing.standard'], 1); Xslt\Extension::$routers = $queue; Xslt\Extension::$descriptorBuilder = $app['descriptor.builder']; }
php
private function registerDependenciesOnXsltExtension(Application $app) { $queue = new Queue(); $queue->insert($app['transformer.routing.standard'], 1); Xslt\Extension::$routers = $queue; Xslt\Extension::$descriptorBuilder = $app['descriptor.builder']; }
[ "private", "function", "registerDependenciesOnXsltExtension", "(", "Application", "$", "app", ")", "{", "$", "queue", "=", "new", "Queue", "(", ")", ";", "$", "queue", "->", "insert", "(", "$", "app", "[", "'transformer.routing.standard'", "]", ",", "1", ")", ";", "Xslt", "\\", "Extension", "::", "$", "routers", "=", "$", "queue", ";", "Xslt", "\\", "Extension", "::", "$", "descriptorBuilder", "=", "$", "app", "[", "'descriptor.builder'", "]", ";", "}" ]
Registers the Routing Queue and Descriptor Builder objects on the XSLT Extension class. In every template we use PHP helpers in order to be able to have routing that is universal between templates and convert Markdown text into HTML (for example). The only way for XSL to do this is by having global functions or static methods in a class because you cannot inject an object into an XSL processor. With this method we make sure that all dependencies used by the static methods are injected as static properties.
[ "Registers", "the", "Routing", "Queue", "and", "Descriptor", "Builder", "objects", "on", "the", "XSLT", "Extension", "class", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Core/ServiceProvider.php#L78-L84
phpDocumentor/phpDocumentor2
src/phpDocumentor/Transformer/Router/ExternalRouter.php
ExternalRouter.configure
public function configure() { $docs = []; //$this->configuration->getTransformer()->getExternalClassDocumentation(); foreach ($docs as $external) { $prefix = (string) $external->getPrefix(); $uri = (string) $external->getUri(); $this[] = new Rule( function ($node) use ($prefix) { return is_string($node) && (strpos(ltrim($node, '\\'), $prefix) === 0); }, function ($node) use ($uri) { return str_replace('{CLASS}', ltrim($node, '\\'), $uri); } ); } }
php
public function configure() { $docs = []; foreach ($docs as $external) { $prefix = (string) $external->getPrefix(); $uri = (string) $external->getUri(); $this[] = new Rule( function ($node) use ($prefix) { return is_string($node) && (strpos(ltrim($node, '\\'), $prefix) === 0); }, function ($node) use ($uri) { return str_replace('{CLASS}', ltrim($node, '\\'), $uri); } ); } }
[ "public", "function", "configure", "(", ")", "{", "$", "docs", "=", "[", "]", ";", "//$this->configuration->getTransformer()->getExternalClassDocumentation();", "foreach", "(", "$", "docs", "as", "$", "external", ")", "{", "$", "prefix", "=", "(", "string", ")", "$", "external", "->", "getPrefix", "(", ")", ";", "$", "uri", "=", "(", "string", ")", "$", "external", "->", "getUri", "(", ")", ";", "$", "this", "[", "]", "=", "new", "Rule", "(", "function", "(", "$", "node", ")", "use", "(", "$", "prefix", ")", "{", "return", "is_string", "(", "$", "node", ")", "&&", "(", "strpos", "(", "ltrim", "(", "$", "node", ",", "'\\\\'", ")", ",", "$", "prefix", ")", "===", "0", ")", ";", "}", ",", "function", "(", "$", "node", ")", "use", "(", "$", "uri", ")", "{", "return", "str_replace", "(", "'{CLASS}'", ",", "ltrim", "(", "$", "node", ",", "'\\\\'", ")", ",", "$", "uri", ")", ";", "}", ")", ";", "}", "}" ]
Configuration function to add routing rules to a router.
[ "Configuration", "function", "to", "add", "routing", "rules", "to", "a", "router", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Transformer/Router/ExternalRouter.php#L38-L54
phpDocumentor/phpDocumentor2
src/phpDocumentor/Plugin/Core/Transformer/Writer/Xsl.php
Xsl.setProcessorParameters
public function setProcessorParameters(TransformationObject $transformation, $proc) { foreach ($this->xsl_variables as $key => $variable) { // XSL does not allow both single and double quotes in a string if ((strpos($variable, '"') !== false) && ((strpos($variable, "'") !== false)) ) { $this->logger->warning( 'XSLT does not allow both double and single quotes in ' . 'a variable; transforming single quotes to a character ' . 'encoded version in variable: ' . $key ); $variable = str_replace("'", '&#39;', $variable); } $proc->setParameter('', $key, $variable); } // add / overwrite the parameters with those defined in the // transformation entry $parameters = $transformation->getParameters(); if (isset($parameters['variables'])) { /** @var \DOMElement $variable */ foreach ($parameters['variables'] as $key => $value) { $proc->setParameter('', $key, $value); } } }
php
public function setProcessorParameters(TransformationObject $transformation, $proc) { foreach ($this->xsl_variables as $key => $variable) { if ((strpos($variable, '"') !== false) && ((strpos($variable, "'") !== false)) ) { $this->logger->warning( 'XSLT does not allow both double and single quotes in ' . 'a variable; transforming single quotes to a character ' . 'encoded version in variable: ' . $key ); $variable = str_replace("'", '& } $proc->setParameter('', $key, $variable); } $parameters = $transformation->getParameters(); if (isset($parameters['variables'])) { foreach ($parameters['variables'] as $key => $value) { $proc->setParameter('', $key, $value); } } }
[ "public", "function", "setProcessorParameters", "(", "TransformationObject", "$", "transformation", ",", "$", "proc", ")", "{", "foreach", "(", "$", "this", "->", "xsl_variables", "as", "$", "key", "=>", "$", "variable", ")", "{", "// XSL does not allow both single and double quotes in a string", "if", "(", "(", "strpos", "(", "$", "variable", ",", "'\"'", ")", "!==", "false", ")", "&&", "(", "(", "strpos", "(", "$", "variable", ",", "\"'\"", ")", "!==", "false", ")", ")", ")", "{", "$", "this", "->", "logger", "->", "warning", "(", "'XSLT does not allow both double and single quotes in '", ".", "'a variable; transforming single quotes to a character '", ".", "'encoded version in variable: '", ".", "$", "key", ")", ";", "$", "variable", "=", "str_replace", "(", "\"'\"", ",", "'&#39;'", ",", "$", "variable", ")", ";", "}", "$", "proc", "->", "setParameter", "(", "''", ",", "$", "key", ",", "$", "variable", ")", ";", "}", "// add / overwrite the parameters with those defined in the", "// transformation entry", "$", "parameters", "=", "$", "transformation", "->", "getParameters", "(", ")", ";", "if", "(", "isset", "(", "$", "parameters", "[", "'variables'", "]", ")", ")", "{", "/** @var \\DOMElement $variable */", "foreach", "(", "$", "parameters", "[", "'variables'", "]", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "proc", "->", "setParameter", "(", "''", ",", "$", "key", ",", "$", "value", ")", ";", "}", "}", "}" ]
Sets the parameters of the XSLT processor. @param XSLTProcessor $proc XSLTProcessor.
[ "Sets", "the", "parameters", "of", "the", "XSLT", "processor", "." ]
train
https://github.com/phpDocumentor/phpDocumentor2/blob/7a835fd03ff40244ff557c3e0ce32239e478def0/src/phpDocumentor/Plugin/Core/Transformer/Writer/Xsl.php#L184-L211