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
52
3.87M
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
ekuiter/feature-php
FeaturePhp/Helper/XmlParser.php
XmlParser.parseString
public function parseString($str) { if (!extension_loaded("SimpleXML")) throw new XmlParserException("SimpleXML extension not loaded, can not parse XML"); libxml_use_internal_errors(true); $xml = simplexml_load_string($str); if ($xml === false) { $msg = "The following XML errors occurred while parsing:"; foreach (libxml_get_errors() as $error) $msg .= "\n" . $error->message; throw new XmlParserException($msg); } $this->xml = $xml; $this->xmlString = $str; return $this; }
php
public function parseString($str) { if (!extension_loaded("SimpleXML")) throw new XmlParserException("SimpleXML extension not loaded, can not parse XML"); libxml_use_internal_errors(true); $xml = simplexml_load_string($str); if ($xml === false) { $msg = "The following XML errors occurred while parsing:"; foreach (libxml_get_errors() as $error) $msg .= "\n" . $error->message; throw new XmlParserException($msg); } $this->xml = $xml; $this->xmlString = $str; return $this; }
[ "public", "function", "parseString", "(", "$", "str", ")", "{", "if", "(", "!", "extension_loaded", "(", "\"SimpleXML\"", ")", ")", "throw", "new", "XmlParserException", "(", "\"SimpleXML extension not loaded, can not parse XML\"", ")", ";", "libxml_use_internal_errors", "(", "true", ")", ";", "$", "xml", "=", "simplexml_load_string", "(", "$", "str", ")", ";", "if", "(", "$", "xml", "===", "false", ")", "{", "$", "msg", "=", "\"The following XML errors occurred while parsing:\"", ";", "foreach", "(", "libxml_get_errors", "(", ")", "as", "$", "error", ")", "$", "msg", ".=", "\"\\n\"", ".", "$", "error", "->", "message", ";", "throw", "new", "XmlParserException", "(", "$", "msg", ")", ";", "}", "$", "this", "->", "xml", "=", "$", "xml", ";", "$", "this", "->", "xmlString", "=", "$", "str", ";", "return", "$", "this", ";", "}" ]
Parses an XML string. @param string $str @return XmlParser
[ "Parses", "an", "XML", "string", "." ]
train
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Helper/XmlParser.php#L50-L67
ekuiter/feature-php
FeaturePhp/Helper/XmlParser.php
XmlParser.validate
public function validate($schemaFile) { if (!$this->xmlString) throw new XmlParserException("attempting to validate before parsing"); if (!extension_loaded("DOM")) { trigger_error("DOM extension not loaded, will not validate XML", E_USER_NOTICE); return $this; } libxml_use_internal_errors(true); $document = new \DOMDocument(); $document->loadXML($this->xmlString); if (!$document->schemaValidate($schemaFile)) { $msg = "The following XML errors occurred while validating:"; foreach (libxml_get_errors() as $error) $msg .= "\n" . $error->message; throw new XmlParserException($msg); } return $this; }
php
public function validate($schemaFile) { if (!$this->xmlString) throw new XmlParserException("attempting to validate before parsing"); if (!extension_loaded("DOM")) { trigger_error("DOM extension not loaded, will not validate XML", E_USER_NOTICE); return $this; } libxml_use_internal_errors(true); $document = new \DOMDocument(); $document->loadXML($this->xmlString); if (!$document->schemaValidate($schemaFile)) { $msg = "The following XML errors occurred while validating:"; foreach (libxml_get_errors() as $error) $msg .= "\n" . $error->message; throw new XmlParserException($msg); } return $this; }
[ "public", "function", "validate", "(", "$", "schemaFile", ")", "{", "if", "(", "!", "$", "this", "->", "xmlString", ")", "throw", "new", "XmlParserException", "(", "\"attempting to validate before parsing\"", ")", ";", "if", "(", "!", "extension_loaded", "(", "\"DOM\"", ")", ")", "{", "trigger_error", "(", "\"DOM extension not loaded, will not validate XML\"", ",", "E_USER_NOTICE", ")", ";", "return", "$", "this", ";", "}", "libxml_use_internal_errors", "(", "true", ")", ";", "$", "document", "=", "new", "\\", "DOMDocument", "(", ")", ";", "$", "document", "->", "loadXML", "(", "$", "this", "->", "xmlString", ")", ";", "if", "(", "!", "$", "document", "->", "schemaValidate", "(", "$", "schemaFile", ")", ")", "{", "$", "msg", "=", "\"The following XML errors occurred while validating:\"", ";", "foreach", "(", "libxml_get_errors", "(", ")", "as", "$", "error", ")", "$", "msg", ".=", "\"\\n\"", ".", "$", "error", "->", "message", ";", "throw", "new", "XmlParserException", "(", "$", "msg", ")", ";", "}", "return", "$", "this", ";", "}" ]
Validates XML using a schema. @param string $schemaFile @return XmlParser
[ "Validates", "XML", "using", "a", "schema", "." ]
train
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Helper/XmlParser.php#L86-L107
ekuiter/feature-php
FeaturePhp/Helper/XmlParser.php
XmlParser.get
public static function get($node, $tagName, $count = 1) { $node = $node->{$tagName}; if ($node->count() !== $count) throw new XmlParserException("xml does not have exactly $count $tagName's"); return $node[0]; }
php
public static function get($node, $tagName, $count = 1) { $node = $node->{$tagName}; if ($node->count() !== $count) throw new XmlParserException("xml does not have exactly $count $tagName's"); return $node[0]; }
[ "public", "static", "function", "get", "(", "$", "node", ",", "$", "tagName", ",", "$", "count", "=", "1", ")", "{", "$", "node", "=", "$", "node", "->", "{", "$", "tagName", "}", ";", "if", "(", "$", "node", "->", "count", "(", ")", "!==", "$", "count", ")", "throw", "new", "XmlParserException", "(", "\"xml does not have exactly $count $tagName's\"", ")", ";", "return", "$", "node", "[", "0", "]", ";", "}" ]
Returns a child node for a tag name from an XML node. @param \SimpleXMLElement $node @param string $tagName @param int $count how many child nodes for the tag name are allowed @return \SimpleXMLElement
[ "Returns", "a", "child", "node", "for", "a", "tag", "name", "from", "an", "XML", "node", "." ]
train
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Helper/XmlParser.php#L116-L121
zhouyl/mellivora
Mellivora/Database/Connectors/ConnectionFactory.php
ConnectionFactory.createConnector
public function createConnector(array $config) { if (!isset($config['driver'])) { throw new InvalidArgumentException('A driver must be specified.'); } if ($this->container->has($key = "db.connector.{$config['driver']}")) { return $this->container->get($key); } switch ($config['driver']) { case 'mysql': return new MySqlConnector; case 'pgsql': return new PostgresConnector; case 'sqlite': return new SQLiteConnector; case 'sqlsrv': return new SqlServerConnector; } throw new InvalidArgumentException("Unsupported driver [{$config['driver']}]"); }
php
public function createConnector(array $config) { if (!isset($config['driver'])) { throw new InvalidArgumentException('A driver must be specified.'); } if ($this->container->has($key = "db.connector.{$config['driver']}")) { return $this->container->get($key); } switch ($config['driver']) { case 'mysql': return new MySqlConnector; case 'pgsql': return new PostgresConnector; case 'sqlite': return new SQLiteConnector; case 'sqlsrv': return new SqlServerConnector; } throw new InvalidArgumentException("Unsupported driver [{$config['driver']}]"); }
[ "public", "function", "createConnector", "(", "array", "$", "config", ")", "{", "if", "(", "!", "isset", "(", "$", "config", "[", "'driver'", "]", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'A driver must be specified.'", ")", ";", "}", "if", "(", "$", "this", "->", "container", "->", "has", "(", "$", "key", "=", "\"db.connector.{$config['driver']}\"", ")", ")", "{", "return", "$", "this", "->", "container", "->", "get", "(", "$", "key", ")", ";", "}", "switch", "(", "$", "config", "[", "'driver'", "]", ")", "{", "case", "'mysql'", ":", "return", "new", "MySqlConnector", ";", "case", "'pgsql'", ":", "return", "new", "PostgresConnector", ";", "case", "'sqlite'", ":", "return", "new", "SQLiteConnector", ";", "case", "'sqlsrv'", ":", "return", "new", "SqlServerConnector", ";", "}", "throw", "new", "InvalidArgumentException", "(", "\"Unsupported driver [{$config['driver']}]\"", ")", ";", "}" ]
Create a connector instance based on the configuration. @param array $config @throws \InvalidArgumentException @return \Mellivora\Database\Connectors\ConnectorInterface
[ "Create", "a", "connector", "instance", "based", "on", "the", "configuration", "." ]
train
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Database/Connectors/ConnectionFactory.php#L246-L268
zhouyl/mellivora
Mellivora/Database/Connectors/ConnectionFactory.php
ConnectionFactory.createConnection
protected function createConnection($driver, $connection, $database, $prefix = '', array $config = []) { if ($resolver = Connection::getResolver($driver)) { return $resolver($connection, $database, $prefix, $config); } switch ($driver) { case 'mysql': return new MySqlConnection($connection, $database, $prefix, $config); case 'pgsql': return new PostgresConnection($connection, $database, $prefix, $config); case 'sqlite': return new SQLiteConnection($connection, $database, $prefix, $config); case 'sqlsrv': return new SqlServerConnection($connection, $database, $prefix, $config); } throw new InvalidArgumentException("Unsupported driver [$driver]"); }
php
protected function createConnection($driver, $connection, $database, $prefix = '', array $config = []) { if ($resolver = Connection::getResolver($driver)) { return $resolver($connection, $database, $prefix, $config); } switch ($driver) { case 'mysql': return new MySqlConnection($connection, $database, $prefix, $config); case 'pgsql': return new PostgresConnection($connection, $database, $prefix, $config); case 'sqlite': return new SQLiteConnection($connection, $database, $prefix, $config); case 'sqlsrv': return new SqlServerConnection($connection, $database, $prefix, $config); } throw new InvalidArgumentException("Unsupported driver [$driver]"); }
[ "protected", "function", "createConnection", "(", "$", "driver", ",", "$", "connection", ",", "$", "database", ",", "$", "prefix", "=", "''", ",", "array", "$", "config", "=", "[", "]", ")", "{", "if", "(", "$", "resolver", "=", "Connection", "::", "getResolver", "(", "$", "driver", ")", ")", "{", "return", "$", "resolver", "(", "$", "connection", ",", "$", "database", ",", "$", "prefix", ",", "$", "config", ")", ";", "}", "switch", "(", "$", "driver", ")", "{", "case", "'mysql'", ":", "return", "new", "MySqlConnection", "(", "$", "connection", ",", "$", "database", ",", "$", "prefix", ",", "$", "config", ")", ";", "case", "'pgsql'", ":", "return", "new", "PostgresConnection", "(", "$", "connection", ",", "$", "database", ",", "$", "prefix", ",", "$", "config", ")", ";", "case", "'sqlite'", ":", "return", "new", "SQLiteConnection", "(", "$", "connection", ",", "$", "database", ",", "$", "prefix", ",", "$", "config", ")", ";", "case", "'sqlsrv'", ":", "return", "new", "SqlServerConnection", "(", "$", "connection", ",", "$", "database", ",", "$", "prefix", ",", "$", "config", ")", ";", "}", "throw", "new", "InvalidArgumentException", "(", "\"Unsupported driver [$driver]\"", ")", ";", "}" ]
Create a new connection instance. @param string $driver @param \Closure|\PDO $connection @param string $database @param string $prefix @param array $config @throws \InvalidArgumentException @return \Mellivora\Database\Connection
[ "Create", "a", "new", "connection", "instance", "." ]
train
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Database/Connectors/ConnectionFactory.php#L283-L301
leoshtika/database
src/Mysql.php
Mysql.connect
public static function connect($mysqlConfig) { $dbConfig = array( 'dsn' => 'mysql:dbname=' . $mysqlConfig['dbname'] . ';host=' . $mysqlConfig['host'], 'user' => $mysqlConfig['user'], 'pass' => $mysqlConfig['pass'], 'options' => array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"), ); return parent::connect($dbConfig); }
php
public static function connect($mysqlConfig) { $dbConfig = array( 'dsn' => 'mysql:dbname=' . $mysqlConfig['dbname'] . ';host=' . $mysqlConfig['host'], 'user' => $mysqlConfig['user'], 'pass' => $mysqlConfig['pass'], 'options' => array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"), ); return parent::connect($dbConfig); }
[ "public", "static", "function", "connect", "(", "$", "mysqlConfig", ")", "{", "$", "dbConfig", "=", "array", "(", "'dsn'", "=>", "'mysql:dbname='", ".", "$", "mysqlConfig", "[", "'dbname'", "]", ".", "';host='", ".", "$", "mysqlConfig", "[", "'host'", "]", ",", "'user'", "=>", "$", "mysqlConfig", "[", "'user'", "]", ",", "'pass'", "=>", "$", "mysqlConfig", "[", "'pass'", "]", ",", "'options'", "=>", "array", "(", "PDO", "::", "MYSQL_ATTR_INIT_COMMAND", "=>", "\"SET NAMES utf8\"", ")", ",", ")", ";", "return", "parent", "::", "connect", "(", "$", "dbConfig", ")", ";", "}" ]
Returns a PDO instance @param array $mysqlConfig @return PDO
[ "Returns", "a", "PDO", "instance" ]
train
https://github.com/leoshtika/database/blob/a8a82cb6b16eb97caf8b583506c0e08ab944f761/src/Mysql.php#L27-L37
philiplb/Valdi
src/Valdi/Validator/DateTime.php
DateTime.isValid
public function isValid($value, array $parameters) { $format = 'Y-m-d H:i:s'; if (count($parameters) > 0) { $format = $parameters[0]; } return in_array($value, ['', null], true) || \DateTime::createFromFormat($format, $value) !== false; }
php
public function isValid($value, array $parameters) { $format = 'Y-m-d H:i:s'; if (count($parameters) > 0) { $format = $parameters[0]; } return in_array($value, ['', null], true) || \DateTime::createFromFormat($format, $value) !== false; }
[ "public", "function", "isValid", "(", "$", "value", ",", "array", "$", "parameters", ")", "{", "$", "format", "=", "'Y-m-d H:i:s'", ";", "if", "(", "count", "(", "$", "parameters", ")", ">", "0", ")", "{", "$", "format", "=", "$", "parameters", "[", "0", "]", ";", "}", "return", "in_array", "(", "$", "value", ",", "[", "''", ",", "null", "]", ",", "true", ")", "||", "\\", "DateTime", "::", "createFromFormat", "(", "$", "format", ",", "$", "value", ")", "!==", "false", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/philiplb/Valdi/blob/9927ec34a2cb00cec705e952d3c2374e2dc3c972/src/Valdi/Validator/DateTime.php#L24-L31
php-lug/lug
src/Component/Behat/Context/PagerContext.php
PagerContext.followPage
public function followPage($page) { \PHPUnit_Framework_Assert::assertNotNull( $link = $this->findPager()->findLink($page), sprintf('The page "%s" could not be found.', $page) ); $link->click(); }
php
public function followPage($page) { \PHPUnit_Framework_Assert::assertNotNull( $link = $this->findPager()->findLink($page), sprintf('The page "%s" could not be found.', $page) ); $link->click(); }
[ "public", "function", "followPage", "(", "$", "page", ")", "{", "\\", "PHPUnit_Framework_Assert", "::", "assertNotNull", "(", "$", "link", "=", "$", "this", "->", "findPager", "(", ")", "->", "findLink", "(", "$", "page", ")", ",", "sprintf", "(", "'The page \"%s\" could not be found.'", ",", "$", "page", ")", ")", ";", "$", "link", "->", "click", "(", ")", ";", "}" ]
@param string|int $page @Given I follow the page ":page"
[ "@param", "string|int", "$page" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Component/Behat/Context/PagerContext.php#L30-L38
php-lug/lug
src/Component/Behat/Context/PagerContext.php
PagerContext.assertPager
public function assertPager($count) { \PHPUnit_Framework_Assert::assertCount( $count + ($offset = 2), $pages = $this->findPager()->findAll('xpath', '/li'), sprintf('The number of pages "%d" does not match "%d".', count($pages) - $offset, $count) ); }
php
public function assertPager($count) { \PHPUnit_Framework_Assert::assertCount( $count + ($offset = 2), $pages = $this->findPager()->findAll('xpath', '/li'), sprintf('The number of pages "%d" does not match "%d".', count($pages) - $offset, $count) ); }
[ "public", "function", "assertPager", "(", "$", "count", ")", "{", "\\", "PHPUnit_Framework_Assert", "::", "assertCount", "(", "$", "count", "+", "(", "$", "offset", "=", "2", ")", ",", "$", "pages", "=", "$", "this", "->", "findPager", "(", ")", "->", "findAll", "(", "'xpath'", ",", "'/li'", ")", ",", "sprintf", "(", "'The number of pages \"%d\" does not match \"%d\".'", ",", "count", "(", "$", "pages", ")", "-", "$", "offset", ",", "$", "count", ")", ")", ";", "}" ]
@param string|int $count @Given I should see a pager with ":count" pages
[ "@param", "string|int", "$count" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Component/Behat/Context/PagerContext.php#L45-L52
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/persistent/writer.php
ezcDbSchemaPersistentWriter.writeField
private function writeField( $file, $fieldName, $field, $isPrimary ) { fwrite( $file, "\n" ); if ( $isPrimary ) { fwrite( $file, "\$def->idProperty = new ezcPersistentObjectIdProperty();\n" ); fwrite( $file, "\$def->idProperty->columnName = '$fieldName';\n" ); fwrite( $file, "\$def->idProperty->propertyName = '$fieldName';\n" ); if ( $field->autoIncrement ) { fwrite( $file, "\$def->idProperty->generator = new ezcPersistentGeneratorDefinition( 'ezcPersistentSequenceGenerator' );\n" ); } else { fwrite( $file, "\$def->idProperty->generator = new ezcPersistentGeneratorDefinition( 'ezcPersistentManualGenerator' );\n" ); fwrite( $file, "\$def->idProperty->propertyType = ezcPersistentObjectProperty::PHP_TYPE_STRING;\n" ); } } else { fwrite( $file, "\$def->properties['$fieldName'] = new ezcPersistentObjectProperty();\n" ); fwrite( $file, "\$def->properties['$fieldName']->columnName = '$fieldName';\n" ); fwrite( $file, "\$def->properties['$fieldName']->propertyName = '$fieldName';\n" ); fwrite( $file, "\$def->properties['$fieldName']->propertyType = {$this->translateType($field->type)};\n" ); } fwrite( $file, "\n" ); }
php
private function writeField( $file, $fieldName, $field, $isPrimary ) { fwrite( $file, "\n" ); if ( $isPrimary ) { fwrite( $file, "\$def->idProperty = new ezcPersistentObjectIdProperty();\n" ); fwrite( $file, "\$def->idProperty->columnName = '$fieldName';\n" ); fwrite( $file, "\$def->idProperty->propertyName = '$fieldName';\n" ); if ( $field->autoIncrement ) { fwrite( $file, "\$def->idProperty->generator = new ezcPersistentGeneratorDefinition( 'ezcPersistentSequenceGenerator' );\n" ); } else { fwrite( $file, "\$def->idProperty->generator = new ezcPersistentGeneratorDefinition( 'ezcPersistentManualGenerator' );\n" ); fwrite( $file, "\$def->idProperty->propertyType = ezcPersistentObjectProperty::PHP_TYPE_STRING;\n" ); } } else { fwrite( $file, "\$def->properties['$fieldName'] = new ezcPersistentObjectProperty();\n" ); fwrite( $file, "\$def->properties['$fieldName']->columnName = '$fieldName';\n" ); fwrite( $file, "\$def->properties['$fieldName']->propertyName = '$fieldName';\n" ); fwrite( $file, "\$def->properties['$fieldName']->propertyType = {$this->translateType($field->type)};\n" ); } fwrite( $file, "\n" ); }
[ "private", "function", "writeField", "(", "$", "file", ",", "$", "fieldName", ",", "$", "field", ",", "$", "isPrimary", ")", "{", "fwrite", "(", "$", "file", ",", "\"\\n\"", ")", ";", "if", "(", "$", "isPrimary", ")", "{", "fwrite", "(", "$", "file", ",", "\"\\$def->idProperty = new ezcPersistentObjectIdProperty();\\n\"", ")", ";", "fwrite", "(", "$", "file", ",", "\"\\$def->idProperty->columnName = '$fieldName';\\n\"", ")", ";", "fwrite", "(", "$", "file", ",", "\"\\$def->idProperty->propertyName = '$fieldName';\\n\"", ")", ";", "if", "(", "$", "field", "->", "autoIncrement", ")", "{", "fwrite", "(", "$", "file", ",", "\"\\$def->idProperty->generator = new ezcPersistentGeneratorDefinition( 'ezcPersistentSequenceGenerator' );\\n\"", ")", ";", "}", "else", "{", "fwrite", "(", "$", "file", ",", "\"\\$def->idProperty->generator = new ezcPersistentGeneratorDefinition( 'ezcPersistentManualGenerator' );\\n\"", ")", ";", "fwrite", "(", "$", "file", ",", "\"\\$def->idProperty->propertyType = ezcPersistentObjectProperty::PHP_TYPE_STRING;\\n\"", ")", ";", "}", "}", "else", "{", "fwrite", "(", "$", "file", ",", "\"\\$def->properties['$fieldName'] = new ezcPersistentObjectProperty();\\n\"", ")", ";", "fwrite", "(", "$", "file", ",", "\"\\$def->properties['$fieldName']->columnName = '$fieldName';\\n\"", ")", ";", "fwrite", "(", "$", "file", ",", "\"\\$def->properties['$fieldName']->propertyName = '$fieldName';\\n\"", ")", ";", "fwrite", "(", "$", "file", ",", "\"\\$def->properties['$fieldName']->propertyType = {$this->translateType($field->type)};\\n\"", ")", ";", "}", "fwrite", "(", "$", "file", ",", "\"\\n\"", ")", ";", "}" ]
Write a field of the schema to the PersistentObject definition. This method writes a database field to the PersistentObject definition file. @param resource(file) $file The file to write to. @param string $fieldName The name of the field. @param ezcDbSchemaField $field The field object. @param bool $isPrimary Whether the field is the primary key.
[ "Write", "a", "field", "of", "the", "schema", "to", "the", "PersistentObject", "definition", ".", "This", "method", "writes", "a", "database", "field", "to", "the", "PersistentObject", "definition", "file", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/persistent/writer.php#L102-L128
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/persistent/writer.php
ezcDbSchemaPersistentWriter.writeTable
private function writeTable( $dir, $tableName, ezcDbSchemaTable $table ) { $file = $this->openFile( $dir, $tableName ); fwrite( $file, "\$def = new ezcPersistentObjectDefinition();\n" ); fwrite( $file, "\$def->table = '$tableName';\n" ); fwrite( $file, "\$def->class = '{$this->prefix}$tableName';\n" ); $primaries = $this->determinePrimaries( $table->indexes ); // fields foreach ( $table->fields as $fieldName => $field ) { $this->writeField( $file, $fieldName, $field, isset( $primaries[$fieldName] ) ); } $this->closeFile( $file ); }
php
private function writeTable( $dir, $tableName, ezcDbSchemaTable $table ) { $file = $this->openFile( $dir, $tableName ); fwrite( $file, "\$def = new ezcPersistentObjectDefinition();\n" ); fwrite( $file, "\$def->table = '$tableName';\n" ); fwrite( $file, "\$def->class = '{$this->prefix}$tableName';\n" ); $primaries = $this->determinePrimaries( $table->indexes ); // fields foreach ( $table->fields as $fieldName => $field ) { $this->writeField( $file, $fieldName, $field, isset( $primaries[$fieldName] ) ); } $this->closeFile( $file ); }
[ "private", "function", "writeTable", "(", "$", "dir", ",", "$", "tableName", ",", "ezcDbSchemaTable", "$", "table", ")", "{", "$", "file", "=", "$", "this", "->", "openFile", "(", "$", "dir", ",", "$", "tableName", ")", ";", "fwrite", "(", "$", "file", ",", "\"\\$def = new ezcPersistentObjectDefinition();\\n\"", ")", ";", "fwrite", "(", "$", "file", ",", "\"\\$def->table = '$tableName';\\n\"", ")", ";", "fwrite", "(", "$", "file", ",", "\"\\$def->class = '{$this->prefix}$tableName';\\n\"", ")", ";", "$", "primaries", "=", "$", "this", "->", "determinePrimaries", "(", "$", "table", "->", "indexes", ")", ";", "// fields ", "foreach", "(", "$", "table", "->", "fields", "as", "$", "fieldName", "=>", "$", "field", ")", "{", "$", "this", "->", "writeField", "(", "$", "file", ",", "$", "fieldName", ",", "$", "field", ",", "isset", "(", "$", "primaries", "[", "$", "fieldName", "]", ")", ")", ";", "}", "$", "this", "->", "closeFile", "(", "$", "file", ")", ";", "}" ]
Writes the PersistentObject defintion for a table. This method writes the PersistentObject definition for a single database table. It creates a new file in the given directory, named in the format <table_name>.php, writes the start of the definition to it and calls the {@link ezcDbschemaPersistentWriter::writeField()} method for each of the database fields. The defition files always contain an object instance $def, which is returned in the end. @param string $dir The directory to write the defititions to. @param string $tableName Name of the database table. @param ezcDbSchemaTable $table The table definition.
[ "Writes", "the", "PersistentObject", "defintion", "for", "a", "table", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/persistent/writer.php#L181-L197
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/persistent/writer.php
ezcDbSchemaPersistentWriter.closeFile
private function closeFile( $file ) { fwrite( $file, "return \$def;\n" ); fwrite( $file, "\n" ); fwrite( $file, "?>\n" ); fclose( $file ); }
php
private function closeFile( $file ) { fwrite( $file, "return \$def;\n" ); fwrite( $file, "\n" ); fwrite( $file, "?>\n" ); fclose( $file ); }
[ "private", "function", "closeFile", "(", "$", "file", ")", "{", "fwrite", "(", "$", "file", ",", "\"return \\$def;\\n\"", ")", ";", "fwrite", "(", "$", "file", ",", "\"\\n\"", ")", ";", "fwrite", "(", "$", "file", ",", "\"?>\\n\"", ")", ";", "fclose", "(", "$", "file", ")", ";", "}" ]
Close a file where a PersistentObject definition has been written to. This method closes a file after writing a PersistentObject definition to it and writes the PHP closing tag to it. @param resource(file) $file The file resource to close. @return void
[ "Close", "a", "file", "where", "a", "PersistentObject", "definition", "has", "been", "written", "to", ".", "This", "method", "closes", "a", "file", "after", "writing", "a", "PersistentObject", "definition", "to", "it", "and", "writes", "the", "PHP", "closing", "tag", "to", "it", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/persistent/writer.php#L240-L246
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/persistent/writer.php
ezcDbSchemaPersistentWriter.determinePrimaries
private function determinePrimaries( $indexes ) { $primaries = array(); foreach ( $indexes as $index ) { if ( $index->primary ) { foreach ( $index->indexFields as $field => $definiton ) { $primaries[$field] = true; } } } return $primaries; }
php
private function determinePrimaries( $indexes ) { $primaries = array(); foreach ( $indexes as $index ) { if ( $index->primary ) { foreach ( $index->indexFields as $field => $definiton ) { $primaries[$field] = true; } } } return $primaries; }
[ "private", "function", "determinePrimaries", "(", "$", "indexes", ")", "{", "$", "primaries", "=", "array", "(", ")", ";", "foreach", "(", "$", "indexes", "as", "$", "index", ")", "{", "if", "(", "$", "index", "->", "primary", ")", "{", "foreach", "(", "$", "index", "->", "indexFields", "as", "$", "field", "=>", "$", "definiton", ")", "{", "$", "primaries", "[", "$", "field", "]", "=", "true", ";", "}", "}", "}", "return", "$", "primaries", ";", "}" ]
Extract primary keys from an index definition. This method extracts the names of all primary keys from the index defintions of a table. @param array(string=>ezcDbSchemaIndex) $indexes Indices. @return array(string=>bool) The primary keys.
[ "Extract", "primary", "keys", "from", "an", "index", "definition", ".", "This", "method", "extracts", "the", "names", "of", "all", "primary", "keys", "from", "the", "index", "defintions", "of", "a", "table", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/persistent/writer.php#L256-L270
DesignPond/newsletter
src/Http/Controllers/Backend/SendController.php
SendController.campagne
public function campagne(Request $request) { // Get campagne $campagne = $this->campagne->find($request->input('id')); $date = $request->input('date',null); //set or update html $html = $this->worker->html($campagne->id); $this->mailjet->setList($campagne->newsletter->list_id); // list id // Sync html content to api service and send to newsletter list! $response = $this->mailjet->setHtml($html,$campagne->api_campagne_id); if(!$response) { throw new \designpond\newsletter\Exceptions\CampagneUpdateException('Problème avec la préparation du contenu'); } /* * Send at specified date or delay for 15 minutes before sending just in case */ $toSend = $date ? \Carbon\Carbon::parse($date) : \Carbon\Carbon::now()->addMinutes(15); $result = $this->mailjet->sendCampagne($campagne->api_campagne_id, $toSend->toIso8601String()); if(!$result['success']) { throw new \designpond\newsletter\Exceptions\CampagneSendException('Problème avec l\'envoi'.$result['info']['ErrorMessage'].'; Code: '.$result['info']['StatusCode']); } // Update campagne status $this->campagne->update(['id' => $campagne->id, 'status' => 'envoyé', 'updated_at' => date('Y-m-d G:i:s'), 'send_at' => $toSend]); alert()->success('Campagne envoyé!'); return redirect('build/newsletter'); }
php
public function campagne(Request $request) { // Get campagne $campagne = $this->campagne->find($request->input('id')); $date = $request->input('date',null); //set or update html $html = $this->worker->html($campagne->id); $this->mailjet->setList($campagne->newsletter->list_id); // list id // Sync html content to api service and send to newsletter list! $response = $this->mailjet->setHtml($html,$campagne->api_campagne_id); if(!$response) { throw new \designpond\newsletter\Exceptions\CampagneUpdateException('Problème avec la préparation du contenu'); } /* * Send at specified date or delay for 15 minutes before sending just in case */ $toSend = $date ? \Carbon\Carbon::parse($date) : \Carbon\Carbon::now()->addMinutes(15); $result = $this->mailjet->sendCampagne($campagne->api_campagne_id, $toSend->toIso8601String()); if(!$result['success']) { throw new \designpond\newsletter\Exceptions\CampagneSendException('Problème avec l\'envoi'.$result['info']['ErrorMessage'].'; Code: '.$result['info']['StatusCode']); } // Update campagne status $this->campagne->update(['id' => $campagne->id, 'status' => 'envoyé', 'updated_at' => date('Y-m-d G:i:s'), 'send_at' => $toSend]); alert()->success('Campagne envoyé!'); return redirect('build/newsletter'); }
[ "public", "function", "campagne", "(", "Request", "$", "request", ")", "{", "// Get campagne", "$", "campagne", "=", "$", "this", "->", "campagne", "->", "find", "(", "$", "request", "->", "input", "(", "'id'", ")", ")", ";", "$", "date", "=", "$", "request", "->", "input", "(", "'date'", ",", "null", ")", ";", "//set or update html", "$", "html", "=", "$", "this", "->", "worker", "->", "html", "(", "$", "campagne", "->", "id", ")", ";", "$", "this", "->", "mailjet", "->", "setList", "(", "$", "campagne", "->", "newsletter", "->", "list_id", ")", ";", "// list id", "// Sync html content to api service and send to newsletter list!", "$", "response", "=", "$", "this", "->", "mailjet", "->", "setHtml", "(", "$", "html", ",", "$", "campagne", "->", "api_campagne_id", ")", ";", "if", "(", "!", "$", "response", ")", "{", "throw", "new", "\\", "designpond", "\\", "newsletter", "\\", "Exceptions", "\\", "CampagneUpdateException", "(", "'Problème avec la préparation du contenu');", "", "", "}", "/*\n * Send at specified date or delay for 15 minutes before sending just in case\n */", "$", "toSend", "=", "$", "date", "?", "\\", "Carbon", "\\", "Carbon", "::", "parse", "(", "$", "date", ")", ":", "\\", "Carbon", "\\", "Carbon", "::", "now", "(", ")", "->", "addMinutes", "(", "15", ")", ";", "$", "result", "=", "$", "this", "->", "mailjet", "->", "sendCampagne", "(", "$", "campagne", "->", "api_campagne_id", ",", "$", "toSend", "->", "toIso8601String", "(", ")", ")", ";", "if", "(", "!", "$", "result", "[", "'success'", "]", ")", "{", "throw", "new", "\\", "designpond", "\\", "newsletter", "\\", "Exceptions", "\\", "CampagneSendException", "(", "'Problème avec l\\'envoi'.", "$", "r", "esult[", "'", "info']", "[", "'", "ErrorMessage']", ".", "'", "; Code: '.", "$", "r", "esult[", "'", "info']", "[", "'", "StatusCode']", ")", ";", "", "}", "// Update campagne status", "$", "this", "->", "campagne", "->", "update", "(", "[", "'id'", "=>", "$", "campagne", "->", "id", ",", "'status'", "=>", "'envoyé',", " ", "updated_at' ", "> ", "ate(", "'", "Y-m-d G:i:s')", ",", " ", "send_at' ", "> ", "t", "oSend]", ")", ";", "", "alert", "(", ")", "->", "success", "(", "'Campagne envoyé!')", ";", "", "return", "redirect", "(", "'build/newsletter'", ")", ";", "}" ]
Send campagne @return \Illuminate\Http\Response
[ "Send", "campagne" ]
train
https://github.com/DesignPond/newsletter/blob/0bf0e7a8a42fa4b90a5e937771bb80058e0a91c3/src/Http/Controllers/Backend/SendController.php#L35-L72
DesignPond/newsletter
src/Http/Controllers/Backend/SendController.php
SendController.forward
public function forward(SendTestRequest $request) { $campagne = $this->campagne->find($request->input('id')); $sujet = ($campagne->status == 'brouillon' ? 'TEST | '.$campagne->sujet : $campagne->sujet ); // GET html $html = $this->worker->html($campagne->id); $email = $request->input('email'); \Mail::send([], [], function ($message) use ($html,$email,$sujet) { $message->to($email)->subject($sujet)->setBody($html, 'text/html'); }); // If we want to send via ajax just add a send_type "ajax $ajax = $request->input('send_type', 'normal'); if($ajax == 'ajax') { echo 'ok'; exit; } alert()->success('Email de test envoyé!'); return redirect('build/campagne/'.$campagne->id); }
php
public function forward(SendTestRequest $request) { $campagne = $this->campagne->find($request->input('id')); $sujet = ($campagne->status == 'brouillon' ? 'TEST | '.$campagne->sujet : $campagne->sujet ); // GET html $html = $this->worker->html($campagne->id); $email = $request->input('email'); \Mail::send([], [], function ($message) use ($html,$email,$sujet) { $message->to($email)->subject($sujet)->setBody($html, 'text/html'); }); // If we want to send via ajax just add a send_type "ajax $ajax = $request->input('send_type', 'normal'); if($ajax == 'ajax') { echo 'ok'; exit; } alert()->success('Email de test envoyé!'); return redirect('build/campagne/'.$campagne->id); }
[ "public", "function", "forward", "(", "SendTestRequest", "$", "request", ")", "{", "$", "campagne", "=", "$", "this", "->", "campagne", "->", "find", "(", "$", "request", "->", "input", "(", "'id'", ")", ")", ";", "$", "sujet", "=", "(", "$", "campagne", "->", "status", "==", "'brouillon'", "?", "'TEST | '", ".", "$", "campagne", "->", "sujet", ":", "$", "campagne", "->", "sujet", ")", ";", "// GET html", "$", "html", "=", "$", "this", "->", "worker", "->", "html", "(", "$", "campagne", "->", "id", ")", ";", "$", "email", "=", "$", "request", "->", "input", "(", "'email'", ")", ";", "\\", "Mail", "::", "send", "(", "[", "]", ",", "[", "]", ",", "function", "(", "$", "message", ")", "use", "(", "$", "html", ",", "$", "email", ",", "$", "sujet", ")", "{", "$", "message", "->", "to", "(", "$", "email", ")", "->", "subject", "(", "$", "sujet", ")", "->", "setBody", "(", "$", "html", ",", "'text/html'", ")", ";", "}", ")", ";", "// If we want to send via ajax just add a send_type \"ajax", "$", "ajax", "=", "$", "request", "->", "input", "(", "'send_type'", ",", "'normal'", ")", ";", "if", "(", "$", "ajax", "==", "'ajax'", ")", "{", "echo", "'ok'", ";", "exit", ";", "}", "alert", "(", ")", "->", "success", "(", "'Email de test envoyé!')", ";", "", "return", "redirect", "(", "'build/campagne/'", ".", "$", "campagne", "->", "id", ")", ";", "}" ]
Send test campagne @return \Illuminate\Http\Response
[ "Send", "test", "campagne" ]
train
https://github.com/DesignPond/newsletter/blob/0bf0e7a8a42fa4b90a5e937771bb80058e0a91c3/src/Http/Controllers/Backend/SendController.php#L120-L143
zhouyl/mellivora
Mellivora/Database/Console/Migrations/InstallCommand.php
InstallCommand.fire
public function fire() { $this->container['migration.repository']->setSource($this->input->getOption('database')); $this->container['migration.repository']->createRepository(); $this->info('Migration table created successfully.'); }
php
public function fire() { $this->container['migration.repository']->setSource($this->input->getOption('database')); $this->container['migration.repository']->createRepository(); $this->info('Migration table created successfully.'); }
[ "public", "function", "fire", "(", ")", "{", "$", "this", "->", "container", "[", "'migration.repository'", "]", "->", "setSource", "(", "$", "this", "->", "input", "->", "getOption", "(", "'database'", ")", ")", ";", "$", "this", "->", "container", "[", "'migration.repository'", "]", "->", "createRepository", "(", ")", ";", "$", "this", "->", "info", "(", "'Migration table created successfully.'", ")", ";", "}" ]
Execute the console command. @return void
[ "Execute", "the", "console", "command", "." ]
train
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Database/Console/Migrations/InstallCommand.php#L29-L36
tttptd/laravel-responder
src/Console/MakeTransformer.php
MakeTransformer.generateTransformer
protected function generateTransformer() { $name = (string) $this->argument('name'); $path = $this->laravel->basePath() . '/app/Transformers/' . $name . '.php'; if ($this->files->exists($path)) { return $this->error($name . ' already exists!'); } $this->makeDirectory($path); $stubPath = $this->option('pivot') ? 'resources/stubs/transformer.pivot.stub' : 'resources/stubs/transformer.stub'; $stub = $this->files->get(__DIR__ . '/../../' . $stubPath); $this->files->put($path, $this->makeTransformer($name, $stub)); $this->info('Transformer created successfully.'); }
php
protected function generateTransformer() { $name = (string) $this->argument('name'); $path = $this->laravel->basePath() . '/app/Transformers/' . $name . '.php'; if ($this->files->exists($path)) { return $this->error($name . ' already exists!'); } $this->makeDirectory($path); $stubPath = $this->option('pivot') ? 'resources/stubs/transformer.pivot.stub' : 'resources/stubs/transformer.stub'; $stub = $this->files->get(__DIR__ . '/../../' . $stubPath); $this->files->put($path, $this->makeTransformer($name, $stub)); $this->info('Transformer created successfully.'); }
[ "protected", "function", "generateTransformer", "(", ")", "{", "$", "name", "=", "(", "string", ")", "$", "this", "->", "argument", "(", "'name'", ")", ";", "$", "path", "=", "$", "this", "->", "laravel", "->", "basePath", "(", ")", ".", "'/app/Transformers/'", ".", "$", "name", ".", "'.php'", ";", "if", "(", "$", "this", "->", "files", "->", "exists", "(", "$", "path", ")", ")", "{", "return", "$", "this", "->", "error", "(", "$", "name", ".", "' already exists!'", ")", ";", "}", "$", "this", "->", "makeDirectory", "(", "$", "path", ")", ";", "$", "stubPath", "=", "$", "this", "->", "option", "(", "'pivot'", ")", "?", "'resources/stubs/transformer.pivot.stub'", ":", "'resources/stubs/transformer.stub'", ";", "$", "stub", "=", "$", "this", "->", "files", "->", "get", "(", "__DIR__", ".", "'/../../'", ".", "$", "stubPath", ")", ";", "$", "this", "->", "files", "->", "put", "(", "$", "path", ",", "$", "this", "->", "makeTransformer", "(", "$", "name", ",", "$", "stub", ")", ")", ";", "$", "this", "->", "info", "(", "'Transformer created successfully.'", ")", ";", "}" ]
Generate the transformer class. @return void
[ "Generate", "the", "transformer", "class", "." ]
train
https://github.com/tttptd/laravel-responder/blob/0e4a32701f0de755c1f1af458045829e1bd6caf6/src/Console/MakeTransformer.php#L68-L85
tttptd/laravel-responder
src/Console/MakeTransformer.php
MakeTransformer.makeTransformer
protected function makeTransformer(string $name, string $stub):string { $stub = $this->replaceNamespace($stub); $stub = $this->replaceClass($stub, $name); $stub = $this->replaceModel($stub, $name); return $stub; }
php
protected function makeTransformer(string $name, string $stub):string { $stub = $this->replaceNamespace($stub); $stub = $this->replaceClass($stub, $name); $stub = $this->replaceModel($stub, $name); return $stub; }
[ "protected", "function", "makeTransformer", "(", "string", "$", "name", ",", "string", "$", "stub", ")", ":", "string", "{", "$", "stub", "=", "$", "this", "->", "replaceNamespace", "(", "$", "stub", ")", ";", "$", "stub", "=", "$", "this", "->", "replaceClass", "(", "$", "stub", ",", "$", "name", ")", ";", "$", "stub", "=", "$", "this", "->", "replaceModel", "(", "$", "stub", ",", "$", "name", ")", ";", "return", "$", "stub", ";", "}" ]
Build the transformer class using the given name and stub. @param string $name @param string $stub @return string
[ "Build", "the", "transformer", "class", "using", "the", "given", "name", "and", "stub", "." ]
train
https://github.com/tttptd/laravel-responder/blob/0e4a32701f0de755c1f1af458045829e1bd6caf6/src/Console/MakeTransformer.php#L107-L114
tttptd/laravel-responder
src/Console/MakeTransformer.php
MakeTransformer.replaceNamespace
protected function replaceNamespace(string $stub):string { if (method_exists($this->laravel, 'getNameSpace')) { $namespace = $this->laravel->getNamespace() . 'Transformers'; } else { $namespace = 'App\Transformers'; } $stub = str_replace('DummyNamespace', $namespace, $stub); return $stub; }
php
protected function replaceNamespace(string $stub):string { if (method_exists($this->laravel, 'getNameSpace')) { $namespace = $this->laravel->getNamespace() . 'Transformers'; } else { $namespace = 'App\Transformers'; } $stub = str_replace('DummyNamespace', $namespace, $stub); return $stub; }
[ "protected", "function", "replaceNamespace", "(", "string", "$", "stub", ")", ":", "string", "{", "if", "(", "method_exists", "(", "$", "this", "->", "laravel", ",", "'getNameSpace'", ")", ")", "{", "$", "namespace", "=", "$", "this", "->", "laravel", "->", "getNamespace", "(", ")", ".", "'Transformers'", ";", "}", "else", "{", "$", "namespace", "=", "'App\\Transformers'", ";", "}", "$", "stub", "=", "str_replace", "(", "'DummyNamespace'", ",", "$", "namespace", ",", "$", "stub", ")", ";", "return", "$", "stub", ";", "}" ]
Replace the namespace for the given stub. @param string $stub @return string
[ "Replace", "the", "namespace", "for", "the", "given", "stub", "." ]
train
https://github.com/tttptd/laravel-responder/blob/0e4a32701f0de755c1f1af458045829e1bd6caf6/src/Console/MakeTransformer.php#L122-L133
tttptd/laravel-responder
src/Console/MakeTransformer.php
MakeTransformer.replaceClass
protected function replaceClass(string $stub, string $name):string { $stub = str_replace('DummyClass', $name, $stub); return $stub; }
php
protected function replaceClass(string $stub, string $name):string { $stub = str_replace('DummyClass', $name, $stub); return $stub; }
[ "protected", "function", "replaceClass", "(", "string", "$", "stub", ",", "string", "$", "name", ")", ":", "string", "{", "$", "stub", "=", "str_replace", "(", "'DummyClass'", ",", "$", "name", ",", "$", "stub", ")", ";", "return", "$", "stub", ";", "}" ]
Replace the class name for the given stub. @param string $stub @param string $name @return string
[ "Replace", "the", "class", "name", "for", "the", "given", "stub", "." ]
train
https://github.com/tttptd/laravel-responder/blob/0e4a32701f0de755c1f1af458045829e1bd6caf6/src/Console/MakeTransformer.php#L142-L147
tttptd/laravel-responder
src/Console/MakeTransformer.php
MakeTransformer.replaceModel
protected function replaceModel(string $stub, string $name):string { $model = $this->getModelNamespace($name); $class = $this->getClassFromNamespace($model); $stub = str_replace('DummyModelNamespace', $model, $stub); $stub = str_replace('DummyModelClass', $class, $stub); $stub = str_replace('DummyModelVariable', camel_case($class), $stub); return $stub; }
php
protected function replaceModel(string $stub, string $name):string { $model = $this->getModelNamespace($name); $class = $this->getClassFromNamespace($model); $stub = str_replace('DummyModelNamespace', $model, $stub); $stub = str_replace('DummyModelClass', $class, $stub); $stub = str_replace('DummyModelVariable', camel_case($class), $stub); return $stub; }
[ "protected", "function", "replaceModel", "(", "string", "$", "stub", ",", "string", "$", "name", ")", ":", "string", "{", "$", "model", "=", "$", "this", "->", "getModelNamespace", "(", "$", "name", ")", ";", "$", "class", "=", "$", "this", "->", "getClassFromNamespace", "(", "$", "model", ")", ";", "$", "stub", "=", "str_replace", "(", "'DummyModelNamespace'", ",", "$", "model", ",", "$", "stub", ")", ";", "$", "stub", "=", "str_replace", "(", "'DummyModelClass'", ",", "$", "class", ",", "$", "stub", ")", ";", "$", "stub", "=", "str_replace", "(", "'DummyModelVariable'", ",", "camel_case", "(", "$", "class", ")", ",", "$", "stub", ")", ";", "return", "$", "stub", ";", "}" ]
Replace the model for the given stub. @param string $stub @param string $name @return string
[ "Replace", "the", "model", "for", "the", "given", "stub", "." ]
train
https://github.com/tttptd/laravel-responder/blob/0e4a32701f0de755c1f1af458045829e1bd6caf6/src/Console/MakeTransformer.php#L156-L166
tttptd/laravel-responder
src/Console/MakeTransformer.php
MakeTransformer.getModelNamespace
protected function getModelNamespace(string $name):string { if ($this->option('model')) { return $this->option('model'); } return 'App\\' . str_replace('Transformer', '', $name); }
php
protected function getModelNamespace(string $name):string { if ($this->option('model')) { return $this->option('model'); } return 'App\\' . str_replace('Transformer', '', $name); }
[ "protected", "function", "getModelNamespace", "(", "string", "$", "name", ")", ":", "string", "{", "if", "(", "$", "this", "->", "option", "(", "'model'", ")", ")", "{", "return", "$", "this", "->", "option", "(", "'model'", ")", ";", "}", "return", "'App\\\\'", ".", "str_replace", "(", "'Transformer'", ",", "''", ",", "$", "name", ")", ";", "}" ]
Get the full class path for the model. @param string $name @return string
[ "Get", "the", "full", "class", "path", "for", "the", "model", "." ]
train
https://github.com/tttptd/laravel-responder/blob/0e4a32701f0de755c1f1af458045829e1bd6caf6/src/Console/MakeTransformer.php#L174-L181
primipilus/fileinfo
src/FileTool.php
FileTool.size
public static function size(string $path) : ?int { $size = filesize($path); return $size === false ? null : $size; }
php
public static function size(string $path) : ?int { $size = filesize($path); return $size === false ? null : $size; }
[ "public", "static", "function", "size", "(", "string", "$", "path", ")", ":", "?", "int", "{", "$", "size", "=", "filesize", "(", "$", "path", ")", ";", "return", "$", "size", "===", "false", "?", "null", ":", "$", "size", ";", "}" ]
@param string $path @return int|null
[ "@param", "string", "$path" ]
train
https://github.com/primipilus/fileinfo/blob/734fd25b3dfd3b0706f9ef07499663578c0fa56e/src/FileTool.php#L35-L39
Eresus/EresusCMS
src/core/HTTP/Response.php
Eresus_HTTP_Response.sendHeaders
public function sendHeaders() { /* Отправляем основной заголовок */ $statusText = $this->statusText ?: self::getStatusText($this->getStatusCode()); $header = 'HTTP/' . $this->getProtocolVersion() . ' ' . $this->getStatusCode() . ' ' . $statusText; header($header, true, $this->getStatusCode()); /* Отправляем дополнительные заголовки */ foreach ($this->headers as $header) { header($header); } return $this; }
php
public function sendHeaders() { /* Отправляем основной заголовок */ $statusText = $this->statusText ?: self::getStatusText($this->getStatusCode()); $header = 'HTTP/' . $this->getProtocolVersion() . ' ' . $this->getStatusCode() . ' ' . $statusText; header($header, true, $this->getStatusCode()); /* Отправляем дополнительные заголовки */ foreach ($this->headers as $header) { header($header); } return $this; }
[ "public", "function", "sendHeaders", "(", ")", "{", "/* Отправляем основной заголовок */", "$", "statusText", "=", "$", "this", "->", "statusText", "?", ":", "self", "::", "getStatusText", "(", "$", "this", "->", "getStatusCode", "(", ")", ")", ";", "$", "header", "=", "'HTTP/'", ".", "$", "this", "->", "getProtocolVersion", "(", ")", ".", "' '", ".", "$", "this", "->", "getStatusCode", "(", ")", ".", "' '", ".", "$", "statusText", ";", "header", "(", "$", "header", ",", "true", ",", "$", "this", "->", "getStatusCode", "(", ")", ")", ";", "/* Отправляем дополнительные заголовки */", "foreach", "(", "$", "this", "->", "headers", "as", "$", "header", ")", "{", "header", "(", "$", "header", ")", ";", "}", "return", "$", "this", ";", "}" ]
Отправляет заголовки ответа @return $this @since 3.01
[ "Отправляет", "заголовки", "ответа" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/HTTP/Response.php#L165-L181
Eresus/EresusCMS
src/core/HTTP/Response.php
Eresus_HTTP_Response.setProtocolVersion
public function setProtocolVersion($version) { if (!preg_match('/^\d(\.\d+)+$/', $version)) { throw new InvalidArgumentException('Invalid protocol version: ' . $version); } $this->protocolVersion = $version; return $this; }
php
public function setProtocolVersion($version) { if (!preg_match('/^\d(\.\d+)+$/', $version)) { throw new InvalidArgumentException('Invalid protocol version: ' . $version); } $this->protocolVersion = $version; return $this; }
[ "public", "function", "setProtocolVersion", "(", "$", "version", ")", "{", "if", "(", "!", "preg_match", "(", "'/^\\d(\\.\\d+)+$/'", ",", "$", "version", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Invalid protocol version: '", ".", "$", "version", ")", ";", "}", "$", "this", "->", "protocolVersion", "=", "$", "version", ";", "return", "$", "this", ";", "}" ]
Задаёт версию протокола @param string $version версия (1.0, 1.1, 2.0…) @throws InvalidArgumentException @return $this @since 3.01
[ "Задаёт", "версию", "протокола" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/HTTP/Response.php#L219-L227
Eresus/EresusCMS
src/core/HTTP/Response.php
Eresus_HTTP_Response.setStatusCode
public function setStatusCode($code, $text = null) { $code = intval($code); if ($code < 100 || $code > 999) { throw new InvalidArgumentException('Status code must be from 100 to 999'); } $this->status = $code; $this->statusText = $text; return $this; }
php
public function setStatusCode($code, $text = null) { $code = intval($code); if ($code < 100 || $code > 999) { throw new InvalidArgumentException('Status code must be from 100 to 999'); } $this->status = $code; $this->statusText = $text; return $this; }
[ "public", "function", "setStatusCode", "(", "$", "code", ",", "$", "text", "=", "null", ")", "{", "$", "code", "=", "intval", "(", "$", "code", ")", ";", "if", "(", "$", "code", "<", "100", "||", "$", "code", ">", "999", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Status code must be from 100 to 999'", ")", ";", "}", "$", "this", "->", "status", "=", "$", "code", ";", "$", "this", "->", "statusText", "=", "$", "text", ";", "return", "$", "this", ";", "}" ]
Задаёт код состояния @param int $code код состояния @param mixed $text опциональное текстовое описание кода @throws InvalidArgumentException @return $this @since 3.01
[ "Задаёт", "код", "состояния" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/HTTP/Response.php#L251-L261
NuclearCMS/Hierarchy
src/Support/LocaleManager.php
LocaleManager.setAppLocale
public function setAppLocale($locale = null, $session = true) { $locale = $locale ?: $this->session->get('_locale', null); if ($locale) { $this->app->setLocale($locale); if ($session) { $this->session->put('_locale', $locale); } $this->setTimeLocale($locale); } }
php
public function setAppLocale($locale = null, $session = true) { $locale = $locale ?: $this->session->get('_locale', null); if ($locale) { $this->app->setLocale($locale); if ($session) { $this->session->put('_locale', $locale); } $this->setTimeLocale($locale); } }
[ "public", "function", "setAppLocale", "(", "$", "locale", "=", "null", ",", "$", "session", "=", "true", ")", "{", "$", "locale", "=", "$", "locale", "?", ":", "$", "this", "->", "session", "->", "get", "(", "'_locale'", ",", "null", ")", ";", "if", "(", "$", "locale", ")", "{", "$", "this", "->", "app", "->", "setLocale", "(", "$", "locale", ")", ";", "if", "(", "$", "session", ")", "{", "$", "this", "->", "session", "->", "put", "(", "'_locale'", ",", "$", "locale", ")", ";", "}", "$", "this", "->", "setTimeLocale", "(", "$", "locale", ")", ";", "}", "}" ]
Sets the app locale @param string $locale @param bool $session @return void
[ "Sets", "the", "app", "locale" ]
train
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Support/LocaleManager.php#L43-L58
NuclearCMS/Hierarchy
src/Support/LocaleManager.php
LocaleManager.setTimeLocale
public function setTimeLocale($locale = null) { $locale = $locale ?: $this->session->get('_locale', $this->app->getLocale()); setlocale(LC_TIME, $this->config->get('translatable.full_locales.' . $locale, null)); Carbon::setLocale($locale); }
php
public function setTimeLocale($locale = null) { $locale = $locale ?: $this->session->get('_locale', $this->app->getLocale()); setlocale(LC_TIME, $this->config->get('translatable.full_locales.' . $locale, null)); Carbon::setLocale($locale); }
[ "public", "function", "setTimeLocale", "(", "$", "locale", "=", "null", ")", "{", "$", "locale", "=", "$", "locale", "?", ":", "$", "this", "->", "session", "->", "get", "(", "'_locale'", ",", "$", "this", "->", "app", "->", "getLocale", "(", ")", ")", ";", "setlocale", "(", "LC_TIME", ",", "$", "this", "->", "config", "->", "get", "(", "'translatable.full_locales.'", ".", "$", "locale", ",", "null", ")", ")", ";", "Carbon", "::", "setLocale", "(", "$", "locale", ")", ";", "}" ]
Sets the time locale @param string $locale @return void
[ "Sets", "the", "time", "locale" ]
train
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Support/LocaleManager.php#L66-L73
surebert/surebert-framework
src/sb/Files/ForceDownload.php
ForceDownload.send
public static function send($file, $display_file_name = '', $seekat=0) { $display_file_name = $display_file_name ? $display_file_name : basename($file); $display_file_name = str_replace(" ", "_", $display_file_name); header("HTTP/1.1 200 OK"); header("Status: 200 OK"); header("Pragma: private"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Transfer-Encoding: Binary"); header('Content-Type: application/force-download'); header('Content-disposition: attachment; filename="'.$display_file_name.'"'); while (ob_get_level() > 0) { ob_end_flush(); } \sb\Files::readChunked($file, $seekat); }
php
public static function send($file, $display_file_name = '', $seekat=0) { $display_file_name = $display_file_name ? $display_file_name : basename($file); $display_file_name = str_replace(" ", "_", $display_file_name); header("HTTP/1.1 200 OK"); header("Status: 200 OK"); header("Pragma: private"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Transfer-Encoding: Binary"); header('Content-Type: application/force-download'); header('Content-disposition: attachment; filename="'.$display_file_name.'"'); while (ob_get_level() > 0) { ob_end_flush(); } \sb\Files::readChunked($file, $seekat); }
[ "public", "static", "function", "send", "(", "$", "file", ",", "$", "display_file_name", "=", "''", ",", "$", "seekat", "=", "0", ")", "{", "$", "display_file_name", "=", "$", "display_file_name", "?", "$", "display_file_name", ":", "basename", "(", "$", "file", ")", ";", "$", "display_file_name", "=", "str_replace", "(", "\" \"", ",", "\"_\"", ",", "$", "display_file_name", ")", ";", "header", "(", "\"HTTP/1.1 200 OK\"", ")", ";", "header", "(", "\"Status: 200 OK\"", ")", ";", "header", "(", "\"Pragma: private\"", ")", ";", "header", "(", "\"Expires: 0\"", ")", ";", "header", "(", "\"Cache-Control: must-revalidate, post-check=0, pre-check=0\"", ")", ";", "header", "(", "\"Content-Transfer-Encoding: Binary\"", ")", ";", "header", "(", "'Content-Type: application/force-download'", ")", ";", "header", "(", "'Content-disposition: attachment; filename=\"'", ".", "$", "display_file_name", ".", "'\"'", ")", ";", "while", "(", "ob_get_level", "(", ")", ">", "0", ")", "{", "ob_end_flush", "(", ")", ";", "}", "\\", "sb", "\\", "Files", "::", "readChunked", "(", "$", "file", ",", "$", "seekat", ")", ";", "}" ]
Send headers and begins force-download @param string $file The path to the file to force download @param string $display_file_name The filename to give to the @param int $seekat Where to start in file stream force download if different than the basename of the file arg
[ "Send", "headers", "and", "begins", "force", "-", "download" ]
train
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Files/ForceDownload.php#L23-L40
surebert/surebert-framework
src/sb/Files/ForceDownload.php
ForceDownload.fileToZip
public static function fileToZip($path) { if (is_file($path) || is_dir($path)) { $zip = new \ZipArchive; $zip_file = ROOT . '/private/cache/zip/' . md5(microtime(true)); if (!is_dir(dirname($zip_file))) { mkdir(dirname($zip_file), 0775, true); } if ($zip->open($zip_file, \ZipArchive::CREATE) === true) { if (is_dir($path)) { $iterator = new \DirectoryIterator($path); foreach ($iterator as $file) { if ($file->isFile()) { $bn = $file->getBasename(); $zip->addFile($file->getPath() . '/' . $bn, $bn); } } } else { $zip->addFile($path, basename($path)); } if ($zip->close()) { self::send($zip_file, str_replace("/", "_", basename($path)) . '.zip'); unlink($zip_file); } } else { throw(new \Exception('failed to create zip file')); } } else { throw(new \Exception('No data found!')); } }
php
public static function fileToZip($path) { if (is_file($path) || is_dir($path)) { $zip = new \ZipArchive; $zip_file = ROOT . '/private/cache/zip/' . md5(microtime(true)); if (!is_dir(dirname($zip_file))) { mkdir(dirname($zip_file), 0775, true); } if ($zip->open($zip_file, \ZipArchive::CREATE) === true) { if (is_dir($path)) { $iterator = new \DirectoryIterator($path); foreach ($iterator as $file) { if ($file->isFile()) { $bn = $file->getBasename(); $zip->addFile($file->getPath() . '/' . $bn, $bn); } } } else { $zip->addFile($path, basename($path)); } if ($zip->close()) { self::send($zip_file, str_replace("/", "_", basename($path)) . '.zip'); unlink($zip_file); } } else { throw(new \Exception('failed to create zip file')); } } else { throw(new \Exception('No data found!')); } }
[ "public", "static", "function", "fileToZip", "(", "$", "path", ")", "{", "if", "(", "is_file", "(", "$", "path", ")", "||", "is_dir", "(", "$", "path", ")", ")", "{", "$", "zip", "=", "new", "\\", "ZipArchive", ";", "$", "zip_file", "=", "ROOT", ".", "'/private/cache/zip/'", ".", "md5", "(", "microtime", "(", "true", ")", ")", ";", "if", "(", "!", "is_dir", "(", "dirname", "(", "$", "zip_file", ")", ")", ")", "{", "mkdir", "(", "dirname", "(", "$", "zip_file", ")", ",", "0775", ",", "true", ")", ";", "}", "if", "(", "$", "zip", "->", "open", "(", "$", "zip_file", ",", "\\", "ZipArchive", "::", "CREATE", ")", "===", "true", ")", "{", "if", "(", "is_dir", "(", "$", "path", ")", ")", "{", "$", "iterator", "=", "new", "\\", "DirectoryIterator", "(", "$", "path", ")", ";", "foreach", "(", "$", "iterator", "as", "$", "file", ")", "{", "if", "(", "$", "file", "->", "isFile", "(", ")", ")", "{", "$", "bn", "=", "$", "file", "->", "getBasename", "(", ")", ";", "$", "zip", "->", "addFile", "(", "$", "file", "->", "getPath", "(", ")", ".", "'/'", ".", "$", "bn", ",", "$", "bn", ")", ";", "}", "}", "}", "else", "{", "$", "zip", "->", "addFile", "(", "$", "path", ",", "basename", "(", "$", "path", ")", ")", ";", "}", "if", "(", "$", "zip", "->", "close", "(", ")", ")", "{", "self", "::", "send", "(", "$", "zip_file", ",", "str_replace", "(", "\"/\"", ",", "\"_\"", ",", "basename", "(", "$", "path", ")", ")", ".", "'.zip'", ")", ";", "unlink", "(", "$", "zip_file", ")", ";", "}", "}", "else", "{", "throw", "(", "new", "\\", "Exception", "(", "'failed to create zip file'", ")", ")", ";", "}", "}", "else", "{", "throw", "(", "new", "\\", "Exception", "(", "'No data found!'", ")", ")", ";", "}", "}" ]
Converts a file or directory into a zip file for consumption by the browser @param string $path The path to the file or directory @return string
[ "Converts", "a", "file", "or", "directory", "into", "a", "zip", "file", "for", "consumption", "by", "the", "browser" ]
train
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Files/ForceDownload.php#L47-L80
david-mk/mail-map
src/MailMap/Connection.php
Connection.search
public function search($search = '', $criteria = SORTDATE, $opt = SE_UID, $dir = 1) { if ('' === ($search = trim($search))) { $search = null; } return imap_sort($this->stream, $criteria, $dir, $opt, $search); }
php
public function search($search = '', $criteria = SORTDATE, $opt = SE_UID, $dir = 1) { if ('' === ($search = trim($search))) { $search = null; } return imap_sort($this->stream, $criteria, $dir, $opt, $search); }
[ "public", "function", "search", "(", "$", "search", "=", "''", ",", "$", "criteria", "=", "SORTDATE", ",", "$", "opt", "=", "SE_UID", ",", "$", "dir", "=", "1", ")", "{", "if", "(", "''", "===", "(", "$", "search", "=", "trim", "(", "$", "search", ")", ")", ")", "{", "$", "search", "=", "null", ";", "}", "return", "imap_sort", "(", "$", "this", "->", "stream", ",", "$", "criteria", ",", "$", "dir", ",", "$", "opt", ",", "$", "search", ")", ";", "}" ]
Search mailbox for emails @param string $search Search string as specified in http://php.net/manual/en/function.imap-search.php @param int $criteria Sort flag from http://php.net/manual/en/function.imap-sort.php @param int $opt Options flags from http://php.net/manual/en/function.imap-sort.php @param int $dir Reverse option from http://php.net/manual/en/function.imap-sort.php @return array List of matched uids
[ "Search", "mailbox", "for", "emails" ]
train
https://github.com/david-mk/mail-map/blob/4eea346ece9fa35c0d309b5a909f657ad83e1e6a/src/MailMap/Connection.php#L45-L52
glynnforrest/blockade
src/Blockade/Exception/BlockadeException.php
BlockadeException.from
public static function from(DriverInterface $driver, $message = '', $code = 0, \Exception $previous = null) { //make sure that empty arguments don't get passed to exceptions as //they have default messages and codes. $self = $message ? ($code ? new static($message, $code, $previous) : new static($message)) : new static(); $self->setDriver($driver); return $self; }
php
public static function from(DriverInterface $driver, $message = '', $code = 0, \Exception $previous = null) { //make sure that empty arguments don't get passed to exceptions as //they have default messages and codes. $self = $message ? ($code ? new static($message, $code, $previous) : new static($message)) : new static(); $self->setDriver($driver); return $self; }
[ "public", "static", "function", "from", "(", "DriverInterface", "$", "driver", ",", "$", "message", "=", "''", ",", "$", "code", "=", "0", ",", "\\", "Exception", "$", "previous", "=", "null", ")", "{", "//make sure that empty arguments don't get passed to exceptions as", "//they have default messages and codes.", "$", "self", "=", "$", "message", "?", "(", "$", "code", "?", "new", "static", "(", "$", "message", ",", "$", "code", ",", "$", "previous", ")", ":", "new", "static", "(", "$", "message", ")", ")", ":", "new", "static", "(", ")", ";", "$", "self", "->", "setDriver", "(", "$", "driver", ")", ";", "return", "$", "self", ";", "}" ]
Factory method to set the driver that created this exception. @param DriverInterface $driver The driver
[ "Factory", "method", "to", "set", "the", "driver", "that", "created", "this", "exception", "." ]
train
https://github.com/glynnforrest/blockade/blob/5dfc8b2fa7b9f7029a1bdaa7c50e32ee8665ab3b/src/Blockade/Exception/BlockadeException.php#L21-L30
songshenzong/log
src/DebugBar.php
DebugBar.initStackSession
protected function initStackSession() { $http = $this->getHttpDriver(); if (!$http->isSessionStarted()) { throw new DebugBarException('Session must be started before using stack data in the songshenzong'); } if (!$http->hasSessionValue($this->stackSessionNamespace)) { $http->setSessionValue($this->stackSessionNamespace, []); } return $http; }
php
protected function initStackSession() { $http = $this->getHttpDriver(); if (!$http->isSessionStarted()) { throw new DebugBarException('Session must be started before using stack data in the songshenzong'); } if (!$http->hasSessionValue($this->stackSessionNamespace)) { $http->setSessionValue($this->stackSessionNamespace, []); } return $http; }
[ "protected", "function", "initStackSession", "(", ")", "{", "$", "http", "=", "$", "this", "->", "getHttpDriver", "(", ")", ";", "if", "(", "!", "$", "http", "->", "isSessionStarted", "(", ")", ")", "{", "throw", "new", "DebugBarException", "(", "'Session must be started before using stack data in the songshenzong'", ")", ";", "}", "if", "(", "!", "$", "http", "->", "hasSessionValue", "(", "$", "this", "->", "stackSessionNamespace", ")", ")", "{", "$", "http", "->", "setSessionValue", "(", "$", "this", "->", "stackSessionNamespace", ",", "[", "]", ")", ";", "}", "return", "$", "http", ";", "}" ]
Initializes the session for stacked data @return HttpDriverInterface @throws DebugBarException
[ "Initializes", "the", "session", "for", "stacked", "data" ]
train
https://github.com/songshenzong/log/blob/b1e01f7994da47737866eabf82367490eab17c46/src/DebugBar.php#L252-L264
heidelpay/PhpDoc
src/phpDocumentor/Plugin/LegacyNamespaceConverter/ServiceProvider.php
ServiceProvider.addNamespaceFilter
private function addNamespaceFilter(ProjectDescriptorBuilder $builder, Filter $filterManager) { $filter = new LegacyNamespaceFilter($builder); // parse parameters foreach ($this->plugin->getParameters() as $param) { if ($param->getKey() == 'NamespacePrefix') { $filter->setNamespacePrefix($param->getValue()); } } $filterManager->attach('phpDocumentor\Descriptor\ConstantDescriptor', $filter); $filterManager->attach('phpDocumentor\Descriptor\FunctionDescriptor', $filter); $filterManager->attach('phpDocumentor\Descriptor\InterfaceDescriptor', $filter); $filterManager->attach('phpDocumentor\Descriptor\TraitDescriptor', $filter); $filterManager->attach('phpDocumentor\Descriptor\PropertyDescriptor', $filter); $filterManager->attach('phpDocumentor\Descriptor\FileDescriptor', $filter); $filterManager->attach('phpDocumentor\Descriptor\ClassDescriptor', $filter); }
php
private function addNamespaceFilter(ProjectDescriptorBuilder $builder, Filter $filterManager) { $filter = new LegacyNamespaceFilter($builder); // parse parameters foreach ($this->plugin->getParameters() as $param) { if ($param->getKey() == 'NamespacePrefix') { $filter->setNamespacePrefix($param->getValue()); } } $filterManager->attach('phpDocumentor\Descriptor\ConstantDescriptor', $filter); $filterManager->attach('phpDocumentor\Descriptor\FunctionDescriptor', $filter); $filterManager->attach('phpDocumentor\Descriptor\InterfaceDescriptor', $filter); $filterManager->attach('phpDocumentor\Descriptor\TraitDescriptor', $filter); $filterManager->attach('phpDocumentor\Descriptor\PropertyDescriptor', $filter); $filterManager->attach('phpDocumentor\Descriptor\FileDescriptor', $filter); $filterManager->attach('phpDocumentor\Descriptor\ClassDescriptor', $filter); }
[ "private", "function", "addNamespaceFilter", "(", "ProjectDescriptorBuilder", "$", "builder", ",", "Filter", "$", "filterManager", ")", "{", "$", "filter", "=", "new", "LegacyNamespaceFilter", "(", "$", "builder", ")", ";", "// parse parameters", "foreach", "(", "$", "this", "->", "plugin", "->", "getParameters", "(", ")", "as", "$", "param", ")", "{", "if", "(", "$", "param", "->", "getKey", "(", ")", "==", "'NamespacePrefix'", ")", "{", "$", "filter", "->", "setNamespacePrefix", "(", "$", "param", "->", "getValue", "(", ")", ")", ";", "}", "}", "$", "filterManager", "->", "attach", "(", "'phpDocumentor\\Descriptor\\ConstantDescriptor'", ",", "$", "filter", ")", ";", "$", "filterManager", "->", "attach", "(", "'phpDocumentor\\Descriptor\\FunctionDescriptor'", ",", "$", "filter", ")", ";", "$", "filterManager", "->", "attach", "(", "'phpDocumentor\\Descriptor\\InterfaceDescriptor'", ",", "$", "filter", ")", ";", "$", "filterManager", "->", "attach", "(", "'phpDocumentor\\Descriptor\\TraitDescriptor'", ",", "$", "filter", ")", ";", "$", "filterManager", "->", "attach", "(", "'phpDocumentor\\Descriptor\\PropertyDescriptor'", ",", "$", "filter", ")", ";", "$", "filterManager", "->", "attach", "(", "'phpDocumentor\\Descriptor\\FileDescriptor'", ",", "$", "filter", ")", ";", "$", "filterManager", "->", "attach", "(", "'phpDocumentor\\Descriptor\\ClassDescriptor'", ",", "$", "filter", ")", ";", "}" ]
Attaches the filter responsible for the conversion to all structural elements. @param ProjectDescriptorBuilder $builder @param Filter $filterManager @return void
[ "Attaches", "the", "filter", "responsible", "for", "the", "conversion", "to", "all", "structural", "elements", "." ]
train
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Plugin/LegacyNamespaceConverter/ServiceProvider.php#L67-L85
alevilar/ristorantino-vendor
Risto/Model/Behavior/DiaBuscableBehavior.php
DiaBuscableBehavior.setUp
public function setUp ( Model $Model, $options = array() ) { if ( !empty($options['fieldsParaSumatoria']) ) { $this->fieldsParaSumatoria = $options['fieldsParaSumatoria']; } if ( !empty($options['fechaField']) ) { $this->fechaField = $options['fechaField']; } }
php
public function setUp ( Model $Model, $options = array() ) { if ( !empty($options['fieldsParaSumatoria']) ) { $this->fieldsParaSumatoria = $options['fieldsParaSumatoria']; } if ( !empty($options['fechaField']) ) { $this->fechaField = $options['fechaField']; } }
[ "public", "function", "setUp", "(", "Model", "$", "Model", ",", "$", "options", "=", "array", "(", ")", ")", "{", "if", "(", "!", "empty", "(", "$", "options", "[", "'fieldsParaSumatoria'", "]", ")", ")", "{", "$", "this", "->", "fieldsParaSumatoria", "=", "$", "options", "[", "'fieldsParaSumatoria'", "]", ";", "}", "if", "(", "!", "empty", "(", "$", "options", "[", "'fechaField'", "]", ")", ")", "{", "$", "this", "->", "fechaField", "=", "$", "options", "[", "'fechaField'", "]", ";", "}", "}" ]
Setup the behavior
[ "Setup", "the", "behavior" ]
train
https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Risto/Model/Behavior/DiaBuscableBehavior.php#L26-L35
Eresus/EresusCMS
src/core/HTTP/Redirect.php
Eresus_HTTP_Redirect.setStatusCode
public function setStatusCode($code, $text = null) { if ($this->getProtocolVersion() == '1.0' && !in_array($this->getStatusCode(), array(300, 301, 302, 304))) { $code = 302; } return parent::setStatusCode($code, $text); }
php
public function setStatusCode($code, $text = null) { if ($this->getProtocolVersion() == '1.0' && !in_array($this->getStatusCode(), array(300, 301, 302, 304))) { $code = 302; } return parent::setStatusCode($code, $text); }
[ "public", "function", "setStatusCode", "(", "$", "code", ",", "$", "text", "=", "null", ")", "{", "if", "(", "$", "this", "->", "getProtocolVersion", "(", ")", "==", "'1.0'", "&&", "!", "in_array", "(", "$", "this", "->", "getStatusCode", "(", ")", ",", "array", "(", "300", ",", "301", ",", "302", ",", "304", ")", ")", ")", "{", "$", "code", "=", "302", ";", "}", "return", "parent", "::", "setStatusCode", "(", "$", "code", ",", "$", "text", ")", ";", "}" ]
Задаёт код состояния @param int $code код состояния @param mixed $text опциональное текстовое описание кода @throws InvalidArgumentException @return $this @since 3.01
[ "Задаёт", "код", "состояния" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/HTTP/Redirect.php#L70-L78
Eresus/EresusCMS
src/core/HTTP/Redirect.php
Eresus_HTTP_Redirect.sendContent
public function sendContent() { $url = htmlspecialchars(strval($this->getContent())); $message = $this->statusText ?: self::getStatusText($this->getStatusCode()); echo <<<PAGE <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <html> <head> <meta http-equiv="Refresh" content="0; url='{$url}'"> <meta http-equiv="Content-type" content="text/html;charset=UTF-8"> <title>{$message}</title> </head> <body> <script> function doRedirect() { location.replace("{$url}"); } setTimeout("doRedirect()", 1000); </script> <p>Your browser does not support automatic redirection. Please follow <a href="{$url}">this link</a>.</p> </body> </html> PAGE; return $this; }
php
public function sendContent() { $url = htmlspecialchars(strval($this->getContent())); $message = $this->statusText ?: self::getStatusText($this->getStatusCode()); echo <<<PAGE <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <html> <head> <meta http-equiv="Refresh" content="0; url='{$url}'"> <meta http-equiv="Content-type" content="text/html;charset=UTF-8"> <title>{$message}</title> </head> <body> <script> function doRedirect() { location.replace("{$url}"); } setTimeout("doRedirect()", 1000); </script> <p>Your browser does not support automatic redirection. Please follow <a href="{$url}">this link</a>.</p> </body> </html> PAGE; return $this; }
[ "public", "function", "sendContent", "(", ")", "{", "$", "url", "=", "htmlspecialchars", "(", "strval", "(", "$", "this", "->", "getContent", "(", ")", ")", ")", ";", "$", "message", "=", "$", "this", "->", "statusText", "?", ":", "self", "::", "getStatusText", "(", "$", "this", "->", "getStatusCode", "(", ")", ")", ";", "echo", " <<<PAGE\n<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2 Final//EN\">\n<html>\n\t<head>\n\t\t<meta http-equiv=\"Refresh\" content=\"0; url='{$url}'\">\n\t\t<meta http-equiv=\"Content-type\" content=\"text/html;charset=UTF-8\">\n\t\t<title>{$message}</title>\n\t</head>\n\t<body>\n\t\t<script>\n\t\t\tfunction doRedirect()\n\t\t\t{\n\t\t\t\tlocation.replace(\"{$url}\");\n\t\t\t}\n\t\t\tsetTimeout(\"doRedirect()\", 1000);\n\t\t</script>\n\t\t<p>Your browser does not support automatic redirection. Please follow <a href=\"{$url}\">this link</a>.</p>\n\t</body>\n</html>\nPAGE", ";", "return", "$", "this", ";", "}" ]
Отправляет тело ответа @return $this @since 3.01
[ "Отправляет", "тело", "ответа" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/HTTP/Redirect.php#L101-L126
hametuha/wpametu
src/WPametu/Http/PostRedirectGet.php
PostRedirectGet.writeSession
private function writeSession($message, $from = '', $is_error = false){ if( session_id() ){ $key = $is_error ? $this->error_key : $this->message_key; // Initialize if( !isset($_SESSION[$key]) || !is_array($_SESSION[$key]) ){ $_SESSION[$key] = []; } // Add message $_SESSION[$key][] = ( empty($from) ? '' : sprintf('<strong>[%s]</strong> ', $from) ).$message; } }
php
private function writeSession($message, $from = '', $is_error = false){ if( session_id() ){ $key = $is_error ? $this->error_key : $this->message_key; // Initialize if( !isset($_SESSION[$key]) || !is_array($_SESSION[$key]) ){ $_SESSION[$key] = []; } // Add message $_SESSION[$key][] = ( empty($from) ? '' : sprintf('<strong>[%s]</strong> ', $from) ).$message; } }
[ "private", "function", "writeSession", "(", "$", "message", ",", "$", "from", "=", "''", ",", "$", "is_error", "=", "false", ")", "{", "if", "(", "session_id", "(", ")", ")", "{", "$", "key", "=", "$", "is_error", "?", "$", "this", "->", "error_key", ":", "$", "this", "->", "message_key", ";", "// Initialize", "if", "(", "!", "isset", "(", "$", "_SESSION", "[", "$", "key", "]", ")", "||", "!", "is_array", "(", "$", "_SESSION", "[", "$", "key", "]", ")", ")", "{", "$", "_SESSION", "[", "$", "key", "]", "=", "[", "]", ";", "}", "// Add message", "$", "_SESSION", "[", "$", "key", "]", "[", "]", "=", "(", "empty", "(", "$", "from", ")", "?", "''", ":", "sprintf", "(", "'<strong>[%s]</strong> '", ",", "$", "from", ")", ")", ".", "$", "message", ";", "}", "}" ]
Write message to session @param $message @param string $from @param bool $is_error
[ "Write", "message", "to", "session" ]
train
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/Http/PostRedirectGet.php#L105-L115
hametuha/wpametu
src/WPametu/Http/PostRedirectGet.php
PostRedirectGet.flushMessage
public function flushMessage(){ if( session_id() ){ foreach( [ $this->error_key => 'error', $this->message_key => 'updated' ] as $key => $class_name ){ if( isset($_SESSION[$key]) && !empty($_SESSION[$key]) ){ $markup = sprintf('<div class="%s"><p>%s</p></div>', $class_name, implode('<br />', $_SESSION[$key])); if( is_admin() ){ echo $markup; }else{ /** * Post redirect get message's filter * * @param string $markup html string * @param array $messages Messages' array * @param string $class_name updated or error. * @return string */ echo apply_filters('wpametu_prg_message_class', $markup, $_SESSION[$key], $class_name); } // Make session empty. $_SESSION[$key] = []; } } } }
php
public function flushMessage(){ if( session_id() ){ foreach( [ $this->error_key => 'error', $this->message_key => 'updated' ] as $key => $class_name ){ if( isset($_SESSION[$key]) && !empty($_SESSION[$key]) ){ $markup = sprintf('<div class="%s"><p>%s</p></div>', $class_name, implode('<br />', $_SESSION[$key])); if( is_admin() ){ echo $markup; }else{ /** * Post redirect get message's filter * * @param string $markup html string * @param array $messages Messages' array * @param string $class_name updated or error. * @return string */ echo apply_filters('wpametu_prg_message_class', $markup, $_SESSION[$key], $class_name); } // Make session empty. $_SESSION[$key] = []; } } } }
[ "public", "function", "flushMessage", "(", ")", "{", "if", "(", "session_id", "(", ")", ")", "{", "foreach", "(", "[", "$", "this", "->", "error_key", "=>", "'error'", ",", "$", "this", "->", "message_key", "=>", "'updated'", "]", "as", "$", "key", "=>", "$", "class_name", ")", "{", "if", "(", "isset", "(", "$", "_SESSION", "[", "$", "key", "]", ")", "&&", "!", "empty", "(", "$", "_SESSION", "[", "$", "key", "]", ")", ")", "{", "$", "markup", "=", "sprintf", "(", "'<div class=\"%s\"><p>%s</p></div>'", ",", "$", "class_name", ",", "implode", "(", "'<br />'", ",", "$", "_SESSION", "[", "$", "key", "]", ")", ")", ";", "if", "(", "is_admin", "(", ")", ")", "{", "echo", "$", "markup", ";", "}", "else", "{", "/**\n * Post redirect get message's filter\n *\n * @param string $markup html string\n * @param array $messages Messages' array\n * @param string $class_name updated or error.\n * @return string\n */", "echo", "apply_filters", "(", "'wpametu_prg_message_class'", ",", "$", "markup", ",", "$", "_SESSION", "[", "$", "key", "]", ",", "$", "class_name", ")", ";", "}", "// Make session empty.", "$", "_SESSION", "[", "$", "key", "]", "=", "[", "]", ";", "}", "}", "}", "}" ]
Show message on screen
[ "Show", "message", "on", "screen" ]
train
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/Http/PostRedirectGet.php#L120-L143
WScore/Validation
src/Utils/HelperMultiple.php
HelperMultiple.prepare
public static function prepare($name, $source, $option) { // get options. if (is_string($option)) { $option = (array) Helper::arrGet(self::$multiples, $option, array()); } $lists = self::find_multiple($name, $source, $option); $found = self::merge_multiple($option, $lists); return $found; }
php
public static function prepare($name, $source, $option) { // get options. if (is_string($option)) { $option = (array) Helper::arrGet(self::$multiples, $option, array()); } $lists = self::find_multiple($name, $source, $option); $found = self::merge_multiple($option, $lists); return $found; }
[ "public", "static", "function", "prepare", "(", "$", "name", ",", "$", "source", ",", "$", "option", ")", "{", "// get options.", "if", "(", "is_string", "(", "$", "option", ")", ")", "{", "$", "option", "=", "(", "array", ")", "Helper", "::", "arrGet", "(", "self", "::", "$", "multiples", ",", "$", "option", ",", "array", "(", ")", ")", ";", "}", "$", "lists", "=", "self", "::", "find_multiple", "(", "$", "name", ",", "$", "source", ",", "$", "option", ")", ";", "$", "found", "=", "self", "::", "merge_multiple", "(", "$", "option", ",", "$", "lists", ")", ";", "return", "$", "found", ";", "}" ]
prepares for validation by creating a value from multiple value. @param string $name @param array $source @param string|array $option @return mixed|null|string
[ "prepares", "for", "validation", "by", "creating", "a", "value", "from", "multiple", "value", "." ]
train
https://github.com/WScore/Validation/blob/25c0dca37d624bb0bb22f8e79ba54db2f69e0950/src/Utils/HelperMultiple.php#L33-L44
WScore/Validation
src/Utils/HelperMultiple.php
HelperMultiple.find_multiple
private static function find_multiple($name, $source, $option) { $sep = Helper::arrGet($option, 'separator', '_'); $suffix = explode(',', $option['suffix']); $lists = []; foreach ($suffix as $sfx) { $name_sfx = $name . $sep . $sfx; if (array_key_exists($name_sfx, $source) && trim($source[$name_sfx])) { $lists[] = trim($source[$name_sfx]); } } return $lists; }
php
private static function find_multiple($name, $source, $option) { $sep = Helper::arrGet($option, 'separator', '_'); $suffix = explode(',', $option['suffix']); $lists = []; foreach ($suffix as $sfx) { $name_sfx = $name . $sep . $sfx; if (array_key_exists($name_sfx, $source) && trim($source[$name_sfx])) { $lists[] = trim($source[$name_sfx]); } } return $lists; }
[ "private", "static", "function", "find_multiple", "(", "$", "name", ",", "$", "source", ",", "$", "option", ")", "{", "$", "sep", "=", "Helper", "::", "arrGet", "(", "$", "option", ",", "'separator'", ",", "'_'", ")", ";", "$", "suffix", "=", "explode", "(", "','", ",", "$", "option", "[", "'suffix'", "]", ")", ";", "$", "lists", "=", "[", "]", ";", "foreach", "(", "$", "suffix", "as", "$", "sfx", ")", "{", "$", "name_sfx", "=", "$", "name", ".", "$", "sep", ".", "$", "sfx", ";", "if", "(", "array_key_exists", "(", "$", "name_sfx", ",", "$", "source", ")", "&&", "trim", "(", "$", "source", "[", "$", "name_sfx", "]", ")", ")", "{", "$", "lists", "[", "]", "=", "trim", "(", "$", "source", "[", "$", "name_sfx", "]", ")", ";", "}", "}", "return", "$", "lists", ";", "}" ]
find multiples values from suffix list. @param string $name @param array $source @param array $option @return array
[ "find", "multiples", "values", "from", "suffix", "list", "." ]
train
https://github.com/WScore/Validation/blob/25c0dca37d624bb0bb22f8e79ba54db2f69e0950/src/Utils/HelperMultiple.php#L54-L67
WScore/Validation
src/Utils/HelperMultiple.php
HelperMultiple.merge_multiple
private static function merge_multiple($option, $lists) { if (empty($lists)) { return null; } // found format using sprintf. if (isset($option['format'])) { $param = array_merge(array($option['format']), $lists); $found = call_user_func_array('sprintf', $param); } else { $con = Helper::arrGet($option, 'connector', '-'); $found = implode($con, $lists); } return $found; }
php
private static function merge_multiple($option, $lists) { if (empty($lists)) { return null; } // found format using sprintf. if (isset($option['format'])) { $param = array_merge(array($option['format']), $lists); $found = call_user_func_array('sprintf', $param); } else { $con = Helper::arrGet($option, 'connector', '-'); $found = implode($con, $lists); } return $found; }
[ "private", "static", "function", "merge_multiple", "(", "$", "option", ",", "$", "lists", ")", "{", "if", "(", "empty", "(", "$", "lists", ")", ")", "{", "return", "null", ";", "}", "// found format using sprintf.", "if", "(", "isset", "(", "$", "option", "[", "'format'", "]", ")", ")", "{", "$", "param", "=", "array_merge", "(", "array", "(", "$", "option", "[", "'format'", "]", ")", ",", "$", "lists", ")", ";", "$", "found", "=", "call_user_func_array", "(", "'sprintf'", ",", "$", "param", ")", ";", "}", "else", "{", "$", "con", "=", "Helper", "::", "arrGet", "(", "$", "option", ",", "'connector'", ",", "'-'", ")", ";", "$", "found", "=", "implode", "(", "$", "con", ",", "$", "lists", ")", ";", "}", "return", "$", "found", ";", "}" ]
merge the found list into one value. @param array $option @param array $lists @return mixed|null|string
[ "merge", "the", "found", "list", "into", "one", "value", "." ]
train
https://github.com/WScore/Validation/blob/25c0dca37d624bb0bb22f8e79ba54db2f69e0950/src/Utils/HelperMultiple.php#L76-L91
WellCommerce/StandardEditionBundle
DataFixtures/ORM/LoadProductData.php
LoadProductData.load
public function load(ObjectManager $manager) { if (!$this->isEnabled()) { return; } $limit = $this->container->getParameter('fixtures_product_limit'); $faker = $this->getFakerGenerator(); $names = []; for ($i = 0; $i < $limit; $i++) { $sentence = $faker->unique()->sentence(3); $name = substr($sentence, 0, strlen($sentence) - 1); $names[$name] = $name; } $products = new ArrayCollection(); foreach ($names as $name) { $products->add($this->createRandomProduct($name, $manager)); } $manager->flush(); $products->map(function (Product $product) { $product->getCategories()->map(function (Category $category) { $category->setProductsCount($category->getProducts()->count()); $category->setChildrenCount($category->getChildren()->count()); }); }); $this->createLayoutBoxes($manager, [ 'product_info' => [ 'type' => 'ProductInfo', 'name' => 'Product', ], ]); $manager->flush(); }
php
public function load(ObjectManager $manager) { if (!$this->isEnabled()) { return; } $limit = $this->container->getParameter('fixtures_product_limit'); $faker = $this->getFakerGenerator(); $names = []; for ($i = 0; $i < $limit; $i++) { $sentence = $faker->unique()->sentence(3); $name = substr($sentence, 0, strlen($sentence) - 1); $names[$name] = $name; } $products = new ArrayCollection(); foreach ($names as $name) { $products->add($this->createRandomProduct($name, $manager)); } $manager->flush(); $products->map(function (Product $product) { $product->getCategories()->map(function (Category $category) { $category->setProductsCount($category->getProducts()->count()); $category->setChildrenCount($category->getChildren()->count()); }); }); $this->createLayoutBoxes($manager, [ 'product_info' => [ 'type' => 'ProductInfo', 'name' => 'Product', ], ]); $manager->flush(); }
[ "public", "function", "load", "(", "ObjectManager", "$", "manager", ")", "{", "if", "(", "!", "$", "this", "->", "isEnabled", "(", ")", ")", "{", "return", ";", "}", "$", "limit", "=", "$", "this", "->", "container", "->", "getParameter", "(", "'fixtures_product_limit'", ")", ";", "$", "faker", "=", "$", "this", "->", "getFakerGenerator", "(", ")", ";", "$", "names", "=", "[", "]", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "limit", ";", "$", "i", "++", ")", "{", "$", "sentence", "=", "$", "faker", "->", "unique", "(", ")", "->", "sentence", "(", "3", ")", ";", "$", "name", "=", "substr", "(", "$", "sentence", ",", "0", ",", "strlen", "(", "$", "sentence", ")", "-", "1", ")", ";", "$", "names", "[", "$", "name", "]", "=", "$", "name", ";", "}", "$", "products", "=", "new", "ArrayCollection", "(", ")", ";", "foreach", "(", "$", "names", "as", "$", "name", ")", "{", "$", "products", "->", "add", "(", "$", "this", "->", "createRandomProduct", "(", "$", "name", ",", "$", "manager", ")", ")", ";", "}", "$", "manager", "->", "flush", "(", ")", ";", "$", "products", "->", "map", "(", "function", "(", "Product", "$", "product", ")", "{", "$", "product", "->", "getCategories", "(", ")", "->", "map", "(", "function", "(", "Category", "$", "category", ")", "{", "$", "category", "->", "setProductsCount", "(", "$", "category", "->", "getProducts", "(", ")", "->", "count", "(", ")", ")", ";", "$", "category", "->", "setChildrenCount", "(", "$", "category", "->", "getChildren", "(", ")", "->", "count", "(", ")", ")", ";", "}", ")", ";", "}", ")", ";", "$", "this", "->", "createLayoutBoxes", "(", "$", "manager", ",", "[", "'product_info'", "=>", "[", "'type'", "=>", "'ProductInfo'", ",", "'name'", "=>", "'Product'", ",", "]", ",", "]", ")", ";", "$", "manager", "->", "flush", "(", ")", ";", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/WellCommerce/StandardEditionBundle/blob/6367bd20bbb6bde37c710a6ba87ae72b5f05f61e/DataFixtures/ORM/LoadProductData.php#L44-L82
ekuiter/feature-php
FeaturePhp/Collaboration/Role.php
Role.correspondsTo
public function correspondsTo($role) { if ($this->fileSpecification->getRelativeSource() === $role->fileSpecification->getRelativeSource()) { if ($this->fileSpecification->getTarget() !== $role->fileSpecification->getTarget()) throw new RoleException("mismatching targets for \"{$this->fileSpecification->getSource()}\"" . " and \"{$role->fileSpecification->getSource()}\""); if ($this->getKind() !== $role->getKind()) throw new RoleException("mismatching kinds for \"{$this->fileSpecification->getSource()}\"" . " and \"{$role->fileSpecification->getSource()}\""); return true; } return false; }
php
public function correspondsTo($role) { if ($this->fileSpecification->getRelativeSource() === $role->fileSpecification->getRelativeSource()) { if ($this->fileSpecification->getTarget() !== $role->fileSpecification->getTarget()) throw new RoleException("mismatching targets for \"{$this->fileSpecification->getSource()}\"" . " and \"{$role->fileSpecification->getSource()}\""); if ($this->getKind() !== $role->getKind()) throw new RoleException("mismatching kinds for \"{$this->fileSpecification->getSource()}\"" . " and \"{$role->fileSpecification->getSource()}\""); return true; } return false; }
[ "public", "function", "correspondsTo", "(", "$", "role", ")", "{", "if", "(", "$", "this", "->", "fileSpecification", "->", "getRelativeSource", "(", ")", "===", "$", "role", "->", "fileSpecification", "->", "getRelativeSource", "(", ")", ")", "{", "if", "(", "$", "this", "->", "fileSpecification", "->", "getTarget", "(", ")", "!==", "$", "role", "->", "fileSpecification", "->", "getTarget", "(", ")", ")", "throw", "new", "RoleException", "(", "\"mismatching targets for \\\"{$this->fileSpecification->getSource()}\\\"\"", ".", "\" and \\\"{$role->fileSpecification->getSource()}\\\"\"", ")", ";", "if", "(", "$", "this", "->", "getKind", "(", ")", "!==", "$", "role", "->", "getKind", "(", ")", ")", "throw", "new", "RoleException", "(", "\"mismatching kinds for \\\"{$this->fileSpecification->getSource()}\\\"\"", ".", "\" and \\\"{$role->fileSpecification->getSource()}\\\"\"", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Returns whether two roles are refining the same class. It requires the roles' files to reside in the same containment hierarchies (i.e. their source paths match). This is an equivalence relation and can be used by {@see \FeaturePhp\Helper\Partition}. @param Role $role @return bool
[ "Returns", "whether", "two", "roles", "are", "refining", "the", "same", "class", ".", "It", "requires", "the", "roles", "files", "to", "reside", "in", "the", "same", "containment", "hierarchies", "(", "i", ".", "e", ".", "their", "source", "paths", "match", ")", ".", "This", "is", "an", "equivalence", "relation", "and", "can", "be", "used", "by", "{" ]
train
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Collaboration/Role.php#L76-L87
brightmarch/rest-easy
src/Brightmarch/RestEasy/Controller/Mixin/HttpJsonMiddlewareMixin.php
HttpJsonMiddlewareMixin.renderResource
public function renderResource($view, array $parameters=[], $statusCode=200) { $jsonHeader = 'application/json'; $response = parent::renderResource($view, $parameters, $statusCode); // Only do this if they are actually sending JSON. if (false !== stripos($response->headers->get('content-type'), $jsonHeader)) { $jsonDecoded = json_decode($response->getContent()); $jsonEncoded = json_encode($jsonDecoded, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); return $response->setContent($jsonEncoded); } else { return $response; } }
php
public function renderResource($view, array $parameters=[], $statusCode=200) { $jsonHeader = 'application/json'; $response = parent::renderResource($view, $parameters, $statusCode); // Only do this if they are actually sending JSON. if (false !== stripos($response->headers->get('content-type'), $jsonHeader)) { $jsonDecoded = json_decode($response->getContent()); $jsonEncoded = json_encode($jsonDecoded, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); return $response->setContent($jsonEncoded); } else { return $response; } }
[ "public", "function", "renderResource", "(", "$", "view", ",", "array", "$", "parameters", "=", "[", "]", ",", "$", "statusCode", "=", "200", ")", "{", "$", "jsonHeader", "=", "'application/json'", ";", "$", "response", "=", "parent", "::", "renderResource", "(", "$", "view", ",", "$", "parameters", ",", "$", "statusCode", ")", ";", "// Only do this if they are actually sending JSON.", "if", "(", "false", "!==", "stripos", "(", "$", "response", "->", "headers", "->", "get", "(", "'content-type'", ")", ",", "$", "jsonHeader", ")", ")", "{", "$", "jsonDecoded", "=", "json_decode", "(", "$", "response", "->", "getContent", "(", ")", ")", ";", "$", "jsonEncoded", "=", "json_encode", "(", "$", "jsonDecoded", ",", "JSON_PRETTY_PRINT", "|", "JSON_UNESCAPED_SLASHES", ")", ";", "return", "$", "response", "->", "setContent", "(", "$", "jsonEncoded", ")", ";", "}", "else", "{", "return", "$", "response", ";", "}", "}" ]
This middleware method takes content from a Symfony\Component\HttpFoundation\Response object and pretty prints the JSON if the response is of Content-Type application/json. @param string $view @param array $parameters @param integer $statusCode @return Symfony\Component\HttpFoundation\Response
[ "This", "middleware", "method", "takes", "content", "from", "a", "Symfony", "\\", "Component", "\\", "HttpFoundation", "\\", "Response", "object", "and", "pretty", "prints", "the", "JSON", "if", "the", "response", "is", "of", "Content", "-", "Type", "application", "/", "json", "." ]
train
https://github.com/brightmarch/rest-easy/blob/a6903cdff0a5de2e4466d3e3438c59b9903049f4/src/Brightmarch/RestEasy/Controller/Mixin/HttpJsonMiddlewareMixin.php#L19-L33
nabab/bbn
src/bbn/appui/menus.php
menus.to_path
public function to_path(string $id){ if ( bbn\str::is_uid($id) ){ return $this->options->to_path($id, '', $this->_get_public_root()); } return false; }
php
public function to_path(string $id){ if ( bbn\str::is_uid($id) ){ return $this->options->to_path($id, '', $this->_get_public_root()); } return false; }
[ "public", "function", "to_path", "(", "string", "$", "id", ")", "{", "if", "(", "bbn", "\\", "str", "::", "is_uid", "(", "$", "id", ")", ")", "{", "return", "$", "this", "->", "options", "->", "to_path", "(", "$", "id", ",", "''", ",", "$", "this", "->", "_get_public_root", "(", ")", ")", ";", "}", "return", "false", ";", "}" ]
Returns the path corresponding to an ID @param string $id @return int|boolean
[ "Returns", "the", "path", "corresponding", "to", "an", "ID" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/menus.php#L160-L165
nabab/bbn
src/bbn/appui/menus.php
menus.add_shortcut
public function add_shortcut(string $id): ?string { if ( ($bit = $this->pref->get_bit($id, false)) && ($id_option = $this->from_path('shortcuts')) && ($c = $this->pref->get_class_cfg()) ){ if ( $id_menu = $this->pref->get_by_option($id_option) ){ $id_menu = $id_menu[$c['arch']['user_options']['id']]; } else { $id_menu = $this->pref->add($id_option, [$c['arch']['user_options']['text'] => _('Shortcuts')]); } if ( !empty($id_menu) && ($arch = $c['arch']['user_options_bits']) ){ if ( ($bits = $this->pref->get_bits($id_menu, false, false)) && ( \bbn\x::find($bits, [$arch['id_option'] => $bit[$arch['id_option']]]) !== false) ){ return null; } return $this->pref->add_bit($id_menu, [ $arch['id_option'] => $bit[$arch['id_option']], $arch['text'] => $bit[$arch['text']], $arch['cfg'] => $bit[$arch['cfg']], $arch['num'] => $this->pref->next_bit_num($id_menu) ?: 1 ]); } } return null; }
php
public function add_shortcut(string $id): ?string { if ( ($bit = $this->pref->get_bit($id, false)) && ($id_option = $this->from_path('shortcuts')) && ($c = $this->pref->get_class_cfg()) ){ if ( $id_menu = $this->pref->get_by_option($id_option) ){ $id_menu = $id_menu[$c['arch']['user_options']['id']]; } else { $id_menu = $this->pref->add($id_option, [$c['arch']['user_options']['text'] => _('Shortcuts')]); } if ( !empty($id_menu) && ($arch = $c['arch']['user_options_bits']) ){ if ( ($bits = $this->pref->get_bits($id_menu, false, false)) && ( \bbn\x::find($bits, [$arch['id_option'] => $bit[$arch['id_option']]]) !== false) ){ return null; } return $this->pref->add_bit($id_menu, [ $arch['id_option'] => $bit[$arch['id_option']], $arch['text'] => $bit[$arch['text']], $arch['cfg'] => $bit[$arch['cfg']], $arch['num'] => $this->pref->next_bit_num($id_menu) ?: 1 ]); } } return null; }
[ "public", "function", "add_shortcut", "(", "string", "$", "id", ")", ":", "?", "string", "{", "if", "(", "(", "$", "bit", "=", "$", "this", "->", "pref", "->", "get_bit", "(", "$", "id", ",", "false", ")", ")", "&&", "(", "$", "id_option", "=", "$", "this", "->", "from_path", "(", "'shortcuts'", ")", ")", "&&", "(", "$", "c", "=", "$", "this", "->", "pref", "->", "get_class_cfg", "(", ")", ")", ")", "{", "if", "(", "$", "id_menu", "=", "$", "this", "->", "pref", "->", "get_by_option", "(", "$", "id_option", ")", ")", "{", "$", "id_menu", "=", "$", "id_menu", "[", "$", "c", "[", "'arch'", "]", "[", "'user_options'", "]", "[", "'id'", "]", "]", ";", "}", "else", "{", "$", "id_menu", "=", "$", "this", "->", "pref", "->", "add", "(", "$", "id_option", ",", "[", "$", "c", "[", "'arch'", "]", "[", "'user_options'", "]", "[", "'text'", "]", "=>", "_", "(", "'Shortcuts'", ")", "]", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "id_menu", ")", "&&", "(", "$", "arch", "=", "$", "c", "[", "'arch'", "]", "[", "'user_options_bits'", "]", ")", ")", "{", "if", "(", "(", "$", "bits", "=", "$", "this", "->", "pref", "->", "get_bits", "(", "$", "id_menu", ",", "false", ",", "false", ")", ")", "&&", "(", "\\", "bbn", "\\", "x", "::", "find", "(", "$", "bits", ",", "[", "$", "arch", "[", "'id_option'", "]", "=>", "$", "bit", "[", "$", "arch", "[", "'id_option'", "]", "]", "]", ")", "!==", "false", ")", ")", "{", "return", "null", ";", "}", "return", "$", "this", "->", "pref", "->", "add_bit", "(", "$", "id_menu", ",", "[", "$", "arch", "[", "'id_option'", "]", "=>", "$", "bit", "[", "$", "arch", "[", "'id_option'", "]", "]", ",", "$", "arch", "[", "'text'", "]", "=>", "$", "bit", "[", "$", "arch", "[", "'text'", "]", "]", ",", "$", "arch", "[", "'cfg'", "]", "=>", "$", "bit", "[", "$", "arch", "[", "'cfg'", "]", "]", ",", "$", "arch", "[", "'num'", "]", "=>", "$", "this", "->", "pref", "->", "next_bit_num", "(", "$", "id_menu", ")", "?", ":", "1", "]", ")", ";", "}", "}", "return", "null", ";", "}" ]
Adds an user'shortcut from a menu @param string $id The menu item's ID to link @return string|null
[ "Adds", "an", "user", "shortcut", "from", "a", "menu" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/menus.php#L191-L223
nabab/bbn
src/bbn/appui/menus.php
menus.remove_shortcut
public function remove_shortcut($id): ?int { if ( \bbn\str::is_uid($id) ){ return $this->pref->delete_bit($id); } return null; }
php
public function remove_shortcut($id): ?int { if ( \bbn\str::is_uid($id) ){ return $this->pref->delete_bit($id); } return null; }
[ "public", "function", "remove_shortcut", "(", "$", "id", ")", ":", "?", "int", "{", "if", "(", "\\", "bbn", "\\", "str", "::", "is_uid", "(", "$", "id", ")", ")", "{", "return", "$", "this", "->", "pref", "->", "delete_bit", "(", "$", "id", ")", ";", "}", "return", "null", ";", "}" ]
Removes an user'shortcut @param string $id The shortcut's ID @return null|int
[ "Removes", "an", "user", "shortcut" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/menus.php#L231-L237
nabab/bbn
src/bbn/appui/menus.php
menus.shortcuts
public function shortcuts(): ?array { if ( ($id_option = $this->from_path('shortcuts')) && ($menu = $this->pref->get_by_option($id_option)) ){ $links = $this->pref->get_bits($menu['id']); $res = []; foreach ( $links as $link ){ if ( ($url = $this->to_path($link['id_option'])) ){ $res[] = [ 'id' => $link['id'], 'id_option' => $link['id_option'], 'url' => $url, 'text' => $link['text'], 'icon' => $link['icon'], 'num' => $link['num'] ]; } } return $res; } return null; }
php
public function shortcuts(): ?array { if ( ($id_option = $this->from_path('shortcuts')) && ($menu = $this->pref->get_by_option($id_option)) ){ $links = $this->pref->get_bits($menu['id']); $res = []; foreach ( $links as $link ){ if ( ($url = $this->to_path($link['id_option'])) ){ $res[] = [ 'id' => $link['id'], 'id_option' => $link['id_option'], 'url' => $url, 'text' => $link['text'], 'icon' => $link['icon'], 'num' => $link['num'] ]; } } return $res; } return null; }
[ "public", "function", "shortcuts", "(", ")", ":", "?", "array", "{", "if", "(", "(", "$", "id_option", "=", "$", "this", "->", "from_path", "(", "'shortcuts'", ")", ")", "&&", "(", "$", "menu", "=", "$", "this", "->", "pref", "->", "get_by_option", "(", "$", "id_option", ")", ")", ")", "{", "$", "links", "=", "$", "this", "->", "pref", "->", "get_bits", "(", "$", "menu", "[", "'id'", "]", ")", ";", "$", "res", "=", "[", "]", ";", "foreach", "(", "$", "links", "as", "$", "link", ")", "{", "if", "(", "(", "$", "url", "=", "$", "this", "->", "to_path", "(", "$", "link", "[", "'id_option'", "]", ")", ")", ")", "{", "$", "res", "[", "]", "=", "[", "'id'", "=>", "$", "link", "[", "'id'", "]", ",", "'id_option'", "=>", "$", "link", "[", "'id_option'", "]", ",", "'url'", "=>", "$", "url", ",", "'text'", "=>", "$", "link", "[", "'text'", "]", ",", "'icon'", "=>", "$", "link", "[", "'icon'", "]", ",", "'num'", "=>", "$", "link", "[", "'num'", "]", "]", ";", "}", "}", "return", "$", "res", ";", "}", "return", "null", ";", "}" ]
Gets the user' shortcuts list @return null|array
[ "Gets", "the", "user", "shortcuts", "list" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/menus.php#L244-L267
nabab/bbn
src/bbn/appui/menus.php
menus.remove
public function remove(string $id){ if ( \bbn\str::is_uid($id) ){ if ( $id_menu = $this->get_id_menu($id) ){ if ( $this->pref->delete_bit($id) ){ $this->delete_cache($id_menu); return true; } } else if ( $this->pref->delete($id) ){ $this->options->delete_cache($this->from_path('menus')); return true; } } return false; }
php
public function remove(string $id){ if ( \bbn\str::is_uid($id) ){ if ( $id_menu = $this->get_id_menu($id) ){ if ( $this->pref->delete_bit($id) ){ $this->delete_cache($id_menu); return true; } } else if ( $this->pref->delete($id) ){ $this->options->delete_cache($this->from_path('menus')); return true; } } return false; }
[ "public", "function", "remove", "(", "string", "$", "id", ")", "{", "if", "(", "\\", "bbn", "\\", "str", "::", "is_uid", "(", "$", "id", ")", ")", "{", "if", "(", "$", "id_menu", "=", "$", "this", "->", "get_id_menu", "(", "$", "id", ")", ")", "{", "if", "(", "$", "this", "->", "pref", "->", "delete_bit", "(", "$", "id", ")", ")", "{", "$", "this", "->", "delete_cache", "(", "$", "id_menu", ")", ";", "return", "true", ";", "}", "}", "else", "if", "(", "$", "this", "->", "pref", "->", "delete", "(", "$", "id", ")", ")", "{", "$", "this", "->", "options", "->", "delete_cache", "(", "$", "this", "->", "from_path", "(", "'menus'", ")", ")", ";", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Removes menu and deletes parent cache @param $id @return int|boolean
[ "Removes", "menu", "and", "deletes", "parent", "cache" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/menus.php#L285-L299
nabab/bbn
src/bbn/appui/menus.php
menus.add
public function add($id_menu, array $cfg = null): ?string { $ids = []; if ( \is_array($id_menu) ){ $cfg = $id_menu; $id_opt = $this->from_path('menus'); } if ( !empty($cfg) ){ if ( \bbn\str::is_uid($id_menu) ){ $id = $this->pref->add_bit($id_menu, $cfg); } else { $id = $this->pref->add($id_opt, $cfg); } } if ( !empty($id) ){ if ( \bbn\str::is_uid($id_menu) ){ $this->delete_cache($id_menu); } $this->options->delete_cache($id_opt); return $id; } return null; }
php
public function add($id_menu, array $cfg = null): ?string { $ids = []; if ( \is_array($id_menu) ){ $cfg = $id_menu; $id_opt = $this->from_path('menus'); } if ( !empty($cfg) ){ if ( \bbn\str::is_uid($id_menu) ){ $id = $this->pref->add_bit($id_menu, $cfg); } else { $id = $this->pref->add($id_opt, $cfg); } } if ( !empty($id) ){ if ( \bbn\str::is_uid($id_menu) ){ $this->delete_cache($id_menu); } $this->options->delete_cache($id_opt); return $id; } return null; }
[ "public", "function", "add", "(", "$", "id_menu", ",", "array", "$", "cfg", "=", "null", ")", ":", "?", "string", "{", "$", "ids", "=", "[", "]", ";", "if", "(", "\\", "is_array", "(", "$", "id_menu", ")", ")", "{", "$", "cfg", "=", "$", "id_menu", ";", "$", "id_opt", "=", "$", "this", "->", "from_path", "(", "'menus'", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "cfg", ")", ")", "{", "if", "(", "\\", "bbn", "\\", "str", "::", "is_uid", "(", "$", "id_menu", ")", ")", "{", "$", "id", "=", "$", "this", "->", "pref", "->", "add_bit", "(", "$", "id_menu", ",", "$", "cfg", ")", ";", "}", "else", "{", "$", "id", "=", "$", "this", "->", "pref", "->", "add", "(", "$", "id_opt", ",", "$", "cfg", ")", ";", "}", "}", "if", "(", "!", "empty", "(", "$", "id", ")", ")", "{", "if", "(", "\\", "bbn", "\\", "str", "::", "is_uid", "(", "$", "id_menu", ")", ")", "{", "$", "this", "->", "delete_cache", "(", "$", "id_menu", ")", ";", "}", "$", "this", "->", "options", "->", "delete_cache", "(", "$", "id_opt", ")", ";", "return", "$", "id", ";", "}", "return", "null", ";", "}" ]
Add menu and delete the chache. @param string|array $id_parent @param array $cfg @return null|string @internal param $id
[ "Add", "menu", "and", "delete", "the", "chache", "." ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/menus.php#L309-L332
nabab/bbn
src/bbn/appui/menus.php
menus.set
public function set(string $id, array $cfg): bool { if ( \bbn\str::is_uid($id) && ($id_menu = $this->get_id_menu($id)) && $this->pref->update_bit($id, $cfg) ){ $this->delete_cache($id_menu); return true; } return false; }
php
public function set(string $id, array $cfg): bool { if ( \bbn\str::is_uid($id) && ($id_menu = $this->get_id_menu($id)) && $this->pref->update_bit($id, $cfg) ){ $this->delete_cache($id_menu); return true; } return false; }
[ "public", "function", "set", "(", "string", "$", "id", ",", "array", "$", "cfg", ")", ":", "bool", "{", "if", "(", "\\", "bbn", "\\", "str", "::", "is_uid", "(", "$", "id", ")", "&&", "(", "$", "id_menu", "=", "$", "this", "->", "get_id_menu", "(", "$", "id", ")", ")", "&&", "$", "this", "->", "pref", "->", "update_bit", "(", "$", "id", ",", "$", "cfg", ")", ")", "{", "$", "this", "->", "delete_cache", "(", "$", "id_menu", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Updates a menu item and deletes the menu cache @param string $id @param array $cfg @return bool
[ "Updates", "a", "menu", "item", "and", "deletes", "the", "menu", "cache" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/menus.php#L341-L352
nabab/bbn
src/bbn/appui/menus.php
menus.set_text
public function set_text(string $id, string $text): bool { if ( \bbn\str::is_uid($id) && $this->pref->set_text($id, $text) ){ $this->delete_cache($id); return true; } return false; }
php
public function set_text(string $id, string $text): bool { if ( \bbn\str::is_uid($id) && $this->pref->set_text($id, $text) ){ $this->delete_cache($id); return true; } return false; }
[ "public", "function", "set_text", "(", "string", "$", "id", ",", "string", "$", "text", ")", ":", "bool", "{", "if", "(", "\\", "bbn", "\\", "str", "::", "is_uid", "(", "$", "id", ")", "&&", "$", "this", "->", "pref", "->", "set_text", "(", "$", "id", ",", "$", "text", ")", ")", "{", "$", "this", "->", "delete_cache", "(", "$", "id", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Sets the menu's text and deletes its chache @param string $id The menu's ID @param array $text The new text tp set @return bool
[ "Sets", "the", "menu", "s", "text", "and", "deletes", "its", "chache" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/menus.php#L361-L368
nabab/bbn
src/bbn/appui/menus.php
menus.delete_cache
public function delete_cache($id_menu){ $this->options->delete_cache($this->from_path('menus'), true); return $this->cache_delete($id_menu); }
php
public function delete_cache($id_menu){ $this->options->delete_cache($this->from_path('menus'), true); return $this->cache_delete($id_menu); }
[ "public", "function", "delete_cache", "(", "$", "id_menu", ")", "{", "$", "this", "->", "options", "->", "delete_cache", "(", "$", "this", "->", "from_path", "(", "'menus'", ")", ",", "true", ")", ";", "return", "$", "this", "->", "cache_delete", "(", "$", "id_menu", ")", ";", "}" ]
Clears the menu cache
[ "Clears", "the", "menu", "cache" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/menus.php#L373-L376
nabab/bbn
src/bbn/appui/menus.php
menus.get_default
public function get_default(): ?string { if ( ($id_opt = $this->from_path('default')) && ($all = $this->pref->get_all($id_opt)) ){ $id = false; foreach ( $all as $a ){ if ( !empty($a['id_user']) ){ $id = $a['id_alias']; break; } else if ( !empty($a['id_group']) ){ $id = $a['id_alias']; break; } else if ( !empty($a['public']) ){ $id = $a['id_alias']; break; } } return $id; } return null; }
php
public function get_default(): ?string { if ( ($id_opt = $this->from_path('default')) && ($all = $this->pref->get_all($id_opt)) ){ $id = false; foreach ( $all as $a ){ if ( !empty($a['id_user']) ){ $id = $a['id_alias']; break; } else if ( !empty($a['id_group']) ){ $id = $a['id_alias']; break; } else if ( !empty($a['public']) ){ $id = $a['id_alias']; break; } } return $id; } return null; }
[ "public", "function", "get_default", "(", ")", ":", "?", "string", "{", "if", "(", "(", "$", "id_opt", "=", "$", "this", "->", "from_path", "(", "'default'", ")", ")", "&&", "(", "$", "all", "=", "$", "this", "->", "pref", "->", "get_all", "(", "$", "id_opt", ")", ")", ")", "{", "$", "id", "=", "false", ";", "foreach", "(", "$", "all", "as", "$", "a", ")", "{", "if", "(", "!", "empty", "(", "$", "a", "[", "'id_user'", "]", ")", ")", "{", "$", "id", "=", "$", "a", "[", "'id_alias'", "]", ";", "break", ";", "}", "else", "if", "(", "!", "empty", "(", "$", "a", "[", "'id_group'", "]", ")", ")", "{", "$", "id", "=", "$", "a", "[", "'id_alias'", "]", ";", "break", ";", "}", "else", "if", "(", "!", "empty", "(", "$", "a", "[", "'public'", "]", ")", ")", "{", "$", "id", "=", "$", "a", "[", "'id_alias'", "]", ";", "break", ";", "}", "}", "return", "$", "id", ";", "}", "return", "null", ";", "}" ]
Gets the user's default menu @return string
[ "Gets", "the", "user", "s", "default", "menu" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/menus.php#L383-L407
nabab/bbn
src/bbn/appui/menus.php
menus.get_menus
public function get_menus($k_text = 'text', $k_value = 'value'): ?array { $c = $this->pref->get_class_cfg(); return array_map(function($e) use($c, $k_text, $k_value){ return [ $k_text => $e[$c['arch']['user_options']['text']], $k_value => $e[$c['arch']['user_options']['id']], $c['arch']['user_options']['public'] => $e[$c['arch']['user_options']['public']], $c['arch']['user_options']['id_user'] => $e[$c['arch']['user_options']['id_user']], $c['arch']['user_options']['id_group'] => $e[$c['arch']['user_options']['id_group']] ]; }, $this->pref->get_all(self::get_appui_option_id('menus'))); }
php
public function get_menus($k_text = 'text', $k_value = 'value'): ?array { $c = $this->pref->get_class_cfg(); return array_map(function($e) use($c, $k_text, $k_value){ return [ $k_text => $e[$c['arch']['user_options']['text']], $k_value => $e[$c['arch']['user_options']['id']], $c['arch']['user_options']['public'] => $e[$c['arch']['user_options']['public']], $c['arch']['user_options']['id_user'] => $e[$c['arch']['user_options']['id_user']], $c['arch']['user_options']['id_group'] => $e[$c['arch']['user_options']['id_group']] ]; }, $this->pref->get_all(self::get_appui_option_id('menus'))); }
[ "public", "function", "get_menus", "(", "$", "k_text", "=", "'text'", ",", "$", "k_value", "=", "'value'", ")", ":", "?", "array", "{", "$", "c", "=", "$", "this", "->", "pref", "->", "get_class_cfg", "(", ")", ";", "return", "array_map", "(", "function", "(", "$", "e", ")", "use", "(", "$", "c", ",", "$", "k_text", ",", "$", "k_value", ")", "{", "return", "[", "$", "k_text", "=>", "$", "e", "[", "$", "c", "[", "'arch'", "]", "[", "'user_options'", "]", "[", "'text'", "]", "]", ",", "$", "k_value", "=>", "$", "e", "[", "$", "c", "[", "'arch'", "]", "[", "'user_options'", "]", "[", "'id'", "]", "]", ",", "$", "c", "[", "'arch'", "]", "[", "'user_options'", "]", "[", "'public'", "]", "=>", "$", "e", "[", "$", "c", "[", "'arch'", "]", "[", "'user_options'", "]", "[", "'public'", "]", "]", ",", "$", "c", "[", "'arch'", "]", "[", "'user_options'", "]", "[", "'id_user'", "]", "=>", "$", "e", "[", "$", "c", "[", "'arch'", "]", "[", "'user_options'", "]", "[", "'id_user'", "]", "]", ",", "$", "c", "[", "'arch'", "]", "[", "'user_options'", "]", "[", "'id_group'", "]", "=>", "$", "e", "[", "$", "c", "[", "'arch'", "]", "[", "'user_options'", "]", "[", "'id_group'", "]", "]", "]", ";", "}", ",", "$", "this", "->", "pref", "->", "get_all", "(", "self", "::", "get_appui_option_id", "(", "'menus'", ")", ")", ")", ";", "}" ]
Gets the user's menus list (text-value form) @param string $k_text The key used for the text. Default: 'text' @param string $k_value The key used for the value. Default 'value' @return array
[ "Gets", "the", "user", "s", "menus", "list", "(", "text", "-", "value", "form", ")" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/menus.php#L416-L428
nabab/bbn
src/bbn/appui/menus.php
menus.clone
public function clone(string $id, string $name): ?string { if ( \bbn\str::is_uid($id) && ($id_menu = $this->add(['text' => $name])) ){ if ( ($bits = $this->pref->get_full_bits($id)) && !$this->_clone($id_menu, $bits) ){ return null; } return $id_menu; } return null; }
php
public function clone(string $id, string $name): ?string { if ( \bbn\str::is_uid($id) && ($id_menu = $this->add(['text' => $name])) ){ if ( ($bits = $this->pref->get_full_bits($id)) && !$this->_clone($id_menu, $bits) ){ return null; } return $id_menu; } return null; }
[ "public", "function", "clone", "(", "string", "$", "id", ",", "string", "$", "name", ")", ":", "?", "string", "{", "if", "(", "\\", "bbn", "\\", "str", "::", "is_uid", "(", "$", "id", ")", "&&", "(", "$", "id_menu", "=", "$", "this", "->", "add", "(", "[", "'text'", "=>", "$", "name", "]", ")", ")", ")", "{", "if", "(", "(", "$", "bits", "=", "$", "this", "->", "pref", "->", "get_full_bits", "(", "$", "id", ")", ")", "&&", "!", "$", "this", "->", "_clone", "(", "$", "id_menu", ",", "$", "bits", ")", ")", "{", "return", "null", ";", "}", "return", "$", "id_menu", ";", "}", "return", "null", ";", "}" ]
Clones a menu @param string $id The menu's ID to clone @param string $name The new menu's name @return null|string The new ID
[ "Clones", "a", "menu" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/menus.php#L439-L448
nabab/bbn
src/bbn/appui/menus.php
menus.copy
public function copy(string $id_menu, string $id_menu_to, array $cfg): ?string { if ( \bbn\str::is_uid($id_menu) && \bbn\str::is_uid($id_menu_to) && ($bits = $this->pref->get_full_bits($id_menu)) && ($id = $this->add($id_menu_to, $cfg)) && $this->_clone($id_menu_to, $bits, $id) ){ return $id; } return null; }
php
public function copy(string $id_menu, string $id_menu_to, array $cfg): ?string { if ( \bbn\str::is_uid($id_menu) && \bbn\str::is_uid($id_menu_to) && ($bits = $this->pref->get_full_bits($id_menu)) && ($id = $this->add($id_menu_to, $cfg)) && $this->_clone($id_menu_to, $bits, $id) ){ return $id; } return null; }
[ "public", "function", "copy", "(", "string", "$", "id_menu", ",", "string", "$", "id_menu_to", ",", "array", "$", "cfg", ")", ":", "?", "string", "{", "if", "(", "\\", "bbn", "\\", "str", "::", "is_uid", "(", "$", "id_menu", ")", "&&", "\\", "bbn", "\\", "str", "::", "is_uid", "(", "$", "id_menu_to", ")", "&&", "(", "$", "bits", "=", "$", "this", "->", "pref", "->", "get_full_bits", "(", "$", "id_menu", ")", ")", "&&", "(", "$", "id", "=", "$", "this", "->", "add", "(", "$", "id_menu_to", ",", "$", "cfg", ")", ")", "&&", "$", "this", "->", "_clone", "(", "$", "id_menu_to", ",", "$", "bits", ",", "$", "id", ")", ")", "{", "return", "$", "id", ";", "}", "return", "null", ";", "}" ]
Copies a menu into another one. @param string $id The menu's ID to copy @param string $id_menu_to The target menu's ID @param array $cfg @return null|string The new ID
[ "Copies", "a", "menu", "into", "another", "one", "." ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/menus.php#L460-L472
nabab/bbn
src/bbn/appui/menus.php
menus.copy_to
public function copy_to(string $id_bit, string $id_menu_to, array $cfg): ?string { if ( \bbn\str::is_uid($id_bit) && \bbn\str::is_uid($id_menu_to) && ($bit = $this->pref->get_bit($id_bit)) && ($id_menu = $this->get_id_menu($id_bit)) ){ $bit = array_merge($bit, $cfg, [ 'id_parent' => null, 'num' => $this->pref->get_max_bit_num($id_menu_to, null, true) ]); $bits = $this->pref->get_full_bits($id_menu, $id_bit, true); if ( $id = $this->add($id_menu_to, $bit) ){ if ( !empty($bits) && !$this->_clone($id_menu_to, $bits, $id) ){ return null; } return $id; } } return null; }
php
public function copy_to(string $id_bit, string $id_menu_to, array $cfg): ?string { if ( \bbn\str::is_uid($id_bit) && \bbn\str::is_uid($id_menu_to) && ($bit = $this->pref->get_bit($id_bit)) && ($id_menu = $this->get_id_menu($id_bit)) ){ $bit = array_merge($bit, $cfg, [ 'id_parent' => null, 'num' => $this->pref->get_max_bit_num($id_menu_to, null, true) ]); $bits = $this->pref->get_full_bits($id_menu, $id_bit, true); if ( $id = $this->add($id_menu_to, $bit) ){ if ( !empty($bits) && !$this->_clone($id_menu_to, $bits, $id) ){ return null; } return $id; } } return null; }
[ "public", "function", "copy_to", "(", "string", "$", "id_bit", ",", "string", "$", "id_menu_to", ",", "array", "$", "cfg", ")", ":", "?", "string", "{", "if", "(", "\\", "bbn", "\\", "str", "::", "is_uid", "(", "$", "id_bit", ")", "&&", "\\", "bbn", "\\", "str", "::", "is_uid", "(", "$", "id_menu_to", ")", "&&", "(", "$", "bit", "=", "$", "this", "->", "pref", "->", "get_bit", "(", "$", "id_bit", ")", ")", "&&", "(", "$", "id_menu", "=", "$", "this", "->", "get_id_menu", "(", "$", "id_bit", ")", ")", ")", "{", "$", "bit", "=", "array_merge", "(", "$", "bit", ",", "$", "cfg", ",", "[", "'id_parent'", "=>", "null", ",", "'num'", "=>", "$", "this", "->", "pref", "->", "get_max_bit_num", "(", "$", "id_menu_to", ",", "null", ",", "true", ")", "]", ")", ";", "$", "bits", "=", "$", "this", "->", "pref", "->", "get_full_bits", "(", "$", "id_menu", ",", "$", "id_bit", ",", "true", ")", ";", "if", "(", "$", "id", "=", "$", "this", "->", "add", "(", "$", "id_menu_to", ",", "$", "bit", ")", ")", "{", "if", "(", "!", "empty", "(", "$", "bits", ")", "&&", "!", "$", "this", "->", "_clone", "(", "$", "id_menu_to", ",", "$", "bits", ",", "$", "id", ")", ")", "{", "return", "null", ";", "}", "return", "$", "id", ";", "}", "}", "return", "null", ";", "}" ]
Clones a section/link to an other menu. @param string $id_bit The bit's ID to clone @param string $id_menu_to The menu's ID to clone @param string $cfgvaule of bit @return null|string The new ID
[ "Clones", "a", "section", "/", "link", "to", "an", "other", "menu", "." ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/menus.php#L483-L504
nabab/bbn
src/bbn/appui/menus.php
menus.order
public function order(string $id, int $pos): bool { if ( $res = $this->pref->order_bit($id, $pos) ){ $this->delete_cache($this->get_id_menu($id)); return true; } return false; }
php
public function order(string $id, int $pos): bool { if ( $res = $this->pref->order_bit($id, $pos) ){ $this->delete_cache($this->get_id_menu($id)); return true; } return false; }
[ "public", "function", "order", "(", "string", "$", "id", ",", "int", "$", "pos", ")", ":", "bool", "{", "if", "(", "$", "res", "=", "$", "this", "->", "pref", "->", "order_bit", "(", "$", "id", ",", "$", "pos", ")", ")", "{", "$", "this", "->", "delete_cache", "(", "$", "this", "->", "get_id_menu", "(", "$", "id", ")", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Orders a section/link. @param string $id The section/link's ID @param int $pos The new position. @return bool
[ "Orders", "a", "section", "/", "link", "." ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/menus.php#L513-L520
nabab/bbn
src/bbn/appui/menus.php
menus.move
public function move(string $id, string $id_parent = null): bool { if ( $this->pref->move_bit($id, $id_parent) ){ $this->delete_cache($this->get_id_menu($id)); return true; } return false; }
php
public function move(string $id, string $id_parent = null): bool { if ( $this->pref->move_bit($id, $id_parent) ){ $this->delete_cache($this->get_id_menu($id)); return true; } return false; }
[ "public", "function", "move", "(", "string", "$", "id", ",", "string", "$", "id_parent", "=", "null", ")", ":", "bool", "{", "if", "(", "$", "this", "->", "pref", "->", "move_bit", "(", "$", "id", ",", "$", "id_parent", ")", ")", "{", "$", "this", "->", "delete_cache", "(", "$", "this", "->", "get_id_menu", "(", "$", "id", ")", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Moves a section/link inside to another one. @param string $id The section/link's ID. @param string|null $id_parent The parent's ID. @return bool
[ "Moves", "a", "section", "/", "link", "inside", "to", "another", "one", "." ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/menus.php#L529-L536
pinepain/amqpy
src/AMQPy/Client/Properties.php
Properties.setHeaders
public function setHeaders($headers) { $_headers = []; if (is_array($headers)) { $_headers = $headers; } elseif ($headers instanceof Traversable) { $_headers = iterator_to_array($headers); } else { $type = is_object($headers) ? get_class($headers) . " object" : "scalar " . gettype($headers); throw new PropertiesException ("Headers should be array or iterable, {$type} given instead"); } $this->properties['headers'] = $_headers; }
php
public function setHeaders($headers) { $_headers = []; if (is_array($headers)) { $_headers = $headers; } elseif ($headers instanceof Traversable) { $_headers = iterator_to_array($headers); } else { $type = is_object($headers) ? get_class($headers) . " object" : "scalar " . gettype($headers); throw new PropertiesException ("Headers should be array or iterable, {$type} given instead"); } $this->properties['headers'] = $_headers; }
[ "public", "function", "setHeaders", "(", "$", "headers", ")", "{", "$", "_headers", "=", "[", "]", ";", "if", "(", "is_array", "(", "$", "headers", ")", ")", "{", "$", "_headers", "=", "$", "headers", ";", "}", "elseif", "(", "$", "headers", "instanceof", "Traversable", ")", "{", "$", "_headers", "=", "iterator_to_array", "(", "$", "headers", ")", ";", "}", "else", "{", "$", "type", "=", "is_object", "(", "$", "headers", ")", "?", "get_class", "(", "$", "headers", ")", ".", "\" object\"", ":", "\"scalar \"", ".", "gettype", "(", "$", "headers", ")", ";", "throw", "new", "PropertiesException", "(", "\"Headers should be array or iterable, {$type} given instead\"", ")", ";", "}", "$", "this", "->", "properties", "[", "'headers'", "]", "=", "$", "_headers", ";", "}" ]
@param mixed $headers @throws PropertiesException When try to set different from array or other iterable value as headers
[ "@param", "mixed", "$headers" ]
train
https://github.com/pinepain/amqpy/blob/fc61dacc37a97a100caf67232a72be32dd7cc896/src/AMQPy/Client/Properties.php#L152-L169
DataDo/data
src/main/php/DataDo/Data/Repository.php
Repository.insert
public function insert($entity) { $values = $this->getInsertValues($entity, $this->namingContention); $keyString = implode(array_keys($values), ', '); $questionMarkString = count($values) === 0 ? '' : ('?' . str_repeat(', ?', count($values) - 1)); $sql = "INSERT INTO $this->tableName ($keyString) VALUES ($questionMarkString)"; $sth = $this->pdo->prepare($sql); $sth->execute(array_values($values)); $id = $this->pdo->lastInsertId(); if ($this->idProperty !== null) { $this->idProperty->setValue($entity, $id); } return $id; }
php
public function insert($entity) { $values = $this->getInsertValues($entity, $this->namingContention); $keyString = implode(array_keys($values), ', '); $questionMarkString = count($values) === 0 ? '' : ('?' . str_repeat(', ?', count($values) - 1)); $sql = "INSERT INTO $this->tableName ($keyString) VALUES ($questionMarkString)"; $sth = $this->pdo->prepare($sql); $sth->execute(array_values($values)); $id = $this->pdo->lastInsertId(); if ($this->idProperty !== null) { $this->idProperty->setValue($entity, $id); } return $id; }
[ "public", "function", "insert", "(", "$", "entity", ")", "{", "$", "values", "=", "$", "this", "->", "getInsertValues", "(", "$", "entity", ",", "$", "this", "->", "namingContention", ")", ";", "$", "keyString", "=", "implode", "(", "array_keys", "(", "$", "values", ")", ",", "', '", ")", ";", "$", "questionMarkString", "=", "count", "(", "$", "values", ")", "===", "0", "?", "''", ":", "(", "'?'", ".", "str_repeat", "(", "', ?'", ",", "count", "(", "$", "values", ")", "-", "1", ")", ")", ";", "$", "sql", "=", "\"INSERT INTO $this->tableName ($keyString) VALUES ($questionMarkString)\"", ";", "$", "sth", "=", "$", "this", "->", "pdo", "->", "prepare", "(", "$", "sql", ")", ";", "$", "sth", "->", "execute", "(", "array_values", "(", "$", "values", ")", ")", ";", "$", "id", "=", "$", "this", "->", "pdo", "->", "lastInsertId", "(", ")", ";", "if", "(", "$", "this", "->", "idProperty", "!==", "null", ")", "{", "$", "this", "->", "idProperty", "->", "setValue", "(", "$", "entity", ",", "$", "id", ")", ";", "}", "return", "$", "id", ";", "}" ]
Insert an entity into the database. You can optionally provide a property name. If you do the inserted id will be assigned to that property. @param $entity @return integer the id of the row that was inserted
[ "Insert", "an", "entity", "into", "the", "database", ".", "You", "can", "optionally", "provide", "a", "property", "name", ".", "If", "you", "do", "the", "inserted", "id", "will", "be", "assigned", "to", "that", "property", "." ]
train
https://github.com/DataDo/data/blob/555b02a27755032fcd53e165b0674e81a68067c0/src/main/php/DataDo/Data/Repository.php#L71-L87
DataDo/data
src/main/php/DataDo/Data/Repository.php
Repository.update
public function update($entity) { if ($this->idProperty === null) { throw new ConfigurationException('No idProperty set'); } $id = $this->idProperty->getValue($entity); if ($id === null) { throw new ConfigurationException('Value of ' . $this->idProperty->getName() . ' is null'); } $values = $this->getInsertValues($entity, $this->namingContention); $keyString = implode(array_keys($values), ' = ?,') . ' = ?'; $idColumn = $this->namingContention->propertyToColumnName($this->idProperty); $onlyValues = array_values($values); $onlyValues[] = $id; $sql = "UPDATE $this->tableName SET $keyString WHERE $idColumn = ?"; $sth = $this->pdo->prepare($sql); $sth->execute($onlyValues); return $id; }
php
public function update($entity) { if ($this->idProperty === null) { throw new ConfigurationException('No idProperty set'); } $id = $this->idProperty->getValue($entity); if ($id === null) { throw new ConfigurationException('Value of ' . $this->idProperty->getName() . ' is null'); } $values = $this->getInsertValues($entity, $this->namingContention); $keyString = implode(array_keys($values), ' = ?,') . ' = ?'; $idColumn = $this->namingContention->propertyToColumnName($this->idProperty); $onlyValues = array_values($values); $onlyValues[] = $id; $sql = "UPDATE $this->tableName SET $keyString WHERE $idColumn = ?"; $sth = $this->pdo->prepare($sql); $sth->execute($onlyValues); return $id; }
[ "public", "function", "update", "(", "$", "entity", ")", "{", "if", "(", "$", "this", "->", "idProperty", "===", "null", ")", "{", "throw", "new", "ConfigurationException", "(", "'No idProperty set'", ")", ";", "}", "$", "id", "=", "$", "this", "->", "idProperty", "->", "getValue", "(", "$", "entity", ")", ";", "if", "(", "$", "id", "===", "null", ")", "{", "throw", "new", "ConfigurationException", "(", "'Value of '", ".", "$", "this", "->", "idProperty", "->", "getName", "(", ")", ".", "' is null'", ")", ";", "}", "$", "values", "=", "$", "this", "->", "getInsertValues", "(", "$", "entity", ",", "$", "this", "->", "namingContention", ")", ";", "$", "keyString", "=", "implode", "(", "array_keys", "(", "$", "values", ")", ",", "' = ?,'", ")", ".", "' = ?'", ";", "$", "idColumn", "=", "$", "this", "->", "namingContention", "->", "propertyToColumnName", "(", "$", "this", "->", "idProperty", ")", ";", "$", "onlyValues", "=", "array_values", "(", "$", "values", ")", ";", "$", "onlyValues", "[", "]", "=", "$", "id", ";", "$", "sql", "=", "\"UPDATE $this->tableName SET $keyString WHERE $idColumn = ?\"", ";", "$", "sth", "=", "$", "this", "->", "pdo", "->", "prepare", "(", "$", "sql", ")", ";", "$", "sth", "->", "execute", "(", "$", "onlyValues", ")", ";", "return", "$", "id", ";", "}" ]
Update an existing entity in the database. @param mixed $entity the entity @return int the id of the entity @throws ConfigurationException if no idProperty was set
[ "Update", "an", "existing", "entity", "in", "the", "database", "." ]
train
https://github.com/DataDo/data/blob/555b02a27755032fcd53e165b0674e81a68067c0/src/main/php/DataDo/Data/Repository.php#L95-L117
DataDo/data
src/main/php/DataDo/Data/Repository.php
Repository.save
public function save($entity) { if ($this->idProperty->getValue($entity) === null) { return $this->insert($entity); } else { return $this->update($entity); } }
php
public function save($entity) { if ($this->idProperty->getValue($entity) === null) { return $this->insert($entity); } else { return $this->update($entity); } }
[ "public", "function", "save", "(", "$", "entity", ")", "{", "if", "(", "$", "this", "->", "idProperty", "->", "getValue", "(", "$", "entity", ")", "===", "null", ")", "{", "return", "$", "this", "->", "insert", "(", "$", "entity", ")", ";", "}", "else", "{", "return", "$", "this", "->", "update", "(", "$", "entity", ")", ";", "}", "}" ]
Insert an entity into the database if it has no id yet. Otherwise update it by id. @param mixed $entity the entity @return int the id of the saved document @throws ConfigurationException if no idProperty was set
[ "Insert", "an", "entity", "into", "the", "database", "if", "it", "has", "no", "id", "yet", ".", "Otherwise", "update", "it", "by", "id", "." ]
train
https://github.com/DataDo/data/blob/555b02a27755032fcd53e165b0674e81a68067c0/src/main/php/DataDo/Data/Repository.php#L125-L133
DataDo/data
src/main/php/DataDo/Data/Repository.php
Repository.get
public function get($id) { $idName = ucfirst($this->idProperty->getName()); return $this->__call("getBy$idName", array($id)); }
php
public function get($id) { $idName = ucfirst($this->idProperty->getName()); return $this->__call("getBy$idName", array($id)); }
[ "public", "function", "get", "(", "$", "id", ")", "{", "$", "idName", "=", "ucfirst", "(", "$", "this", "->", "idProperty", "->", "getName", "(", ")", ")", ";", "return", "$", "this", "->", "__call", "(", "\"getBy$idName\"", ",", "array", "(", "$", "id", ")", ")", ";", "}" ]
Get an entity by it's idProperty value. @param mixed $id the id value @return mixed the entity @throws ErrorException
[ "Get", "an", "entity", "by", "it", "s", "idProperty", "value", "." ]
train
https://github.com/DataDo/data/blob/555b02a27755032fcd53e165b0674e81a68067c0/src/main/php/DataDo/Data/Repository.php#L141-L145
DataDo/data
src/main/php/DataDo/Data/Repository.php
Repository.delete
public function delete($id) { $idName = ucfirst($this->idProperty->getName()); return $this->__call("deleteBy$idName", array($id)); }
php
public function delete($id) { $idName = ucfirst($this->idProperty->getName()); return $this->__call("deleteBy$idName", array($id)); }
[ "public", "function", "delete", "(", "$", "id", ")", "{", "$", "idName", "=", "ucfirst", "(", "$", "this", "->", "idProperty", "->", "getName", "(", ")", ")", ";", "return", "$", "this", "->", "__call", "(", "\"deleteBy$idName\"", ",", "array", "(", "$", "id", ")", ")", ";", "}" ]
Delete an entity by it's idProperty value. @param mixed $id the id value @return mixed the entity @throws ErrorException
[ "Delete", "an", "entity", "by", "it", "s", "idProperty", "value", "." ]
train
https://github.com/DataDo/data/blob/555b02a27755032fcd53e165b0674e81a68067c0/src/main/php/DataDo/Data/Repository.php#L153-L157
DataDo/data
src/main/php/DataDo/Data/Repository.php
Repository.addMethod
private function addMethod($method) { $tokens = $this->methodParser->parse($method); $query = $this->queryBuilder->build($tokens, $this->tableName, $this->namingContention, $this->entityClass); if ($query->getResultMode() <= QueryBuilderResult::RESULT_SELECT_MULTIPLE) { $this->addSelectionMethod($query, $method); } else { $this->addIntResultMethod($query, $method); } }
php
private function addMethod($method) { $tokens = $this->methodParser->parse($method); $query = $this->queryBuilder->build($tokens, $this->tableName, $this->namingContention, $this->entityClass); if ($query->getResultMode() <= QueryBuilderResult::RESULT_SELECT_MULTIPLE) { $this->addSelectionMethod($query, $method); } else { $this->addIntResultMethod($query, $method); } }
[ "private", "function", "addMethod", "(", "$", "method", ")", "{", "$", "tokens", "=", "$", "this", "->", "methodParser", "->", "parse", "(", "$", "method", ")", ";", "$", "query", "=", "$", "this", "->", "queryBuilder", "->", "build", "(", "$", "tokens", ",", "$", "this", "->", "tableName", ",", "$", "this", "->", "namingContention", ",", "$", "this", "->", "entityClass", ")", ";", "if", "(", "$", "query", "->", "getResultMode", "(", ")", "<=", "QueryBuilderResult", "::", "RESULT_SELECT_MULTIPLE", ")", "{", "$", "this", "->", "addSelectionMethod", "(", "$", "query", ",", "$", "method", ")", ";", "}", "else", "{", "$", "this", "->", "addIntResultMethod", "(", "$", "query", ",", "$", "method", ")", ";", "}", "}" ]
Parse a dsl method and add it to this repository. @param $method string the method name @throws DslSyntaxException
[ "Parse", "a", "dsl", "method", "and", "add", "it", "to", "this", "repository", "." ]
train
https://github.com/DataDo/data/blob/555b02a27755032fcd53e165b0674e81a68067c0/src/main/php/DataDo/Data/Repository.php#L201-L211
DataDo/data
src/main/php/DataDo/Data/Repository.php
Repository.addSelectionMethod
private function addSelectionMethod(QueryBuilderResult $query, $methodName) { $findMethod = function () use ($query, $methodName) { $sth = $this->pdo->prepare($query->getSql()); /** @noinspection PhpMethodParametersCountMismatchInspection */ $sth->setFetchMode(\PDO::FETCH_CLASS, $this->entityClass->getName()); try { $sth->execute(func_get_args()); } catch (PDOException $e) { throw new DslSyntaxException('Failed to run query [' . $methodName . '] with parameters ' . print_r(func_get_args(), true)); } switch ($query->getResultMode()) { case QueryBuilderResult::RESULT_SELECT_SINGLE: return $sth->fetch(); case QueryBuilderResult::RESULT_SELECT_MULTIPLE: return $sth->fetchAll(); } throw new DslSyntaxException('Result Mode ' . $query->getResultMode() . ' is not implemented', DATADO_ILLEGAL_RESULT_MODE); }; $this->methods[$methodName] = \Closure::bind($findMethod, $this, get_class()); }
php
private function addSelectionMethod(QueryBuilderResult $query, $methodName) { $findMethod = function () use ($query, $methodName) { $sth = $this->pdo->prepare($query->getSql()); /** @noinspection PhpMethodParametersCountMismatchInspection */ $sth->setFetchMode(\PDO::FETCH_CLASS, $this->entityClass->getName()); try { $sth->execute(func_get_args()); } catch (PDOException $e) { throw new DslSyntaxException('Failed to run query [' . $methodName . '] with parameters ' . print_r(func_get_args(), true)); } switch ($query->getResultMode()) { case QueryBuilderResult::RESULT_SELECT_SINGLE: return $sth->fetch(); case QueryBuilderResult::RESULT_SELECT_MULTIPLE: return $sth->fetchAll(); } throw new DslSyntaxException('Result Mode ' . $query->getResultMode() . ' is not implemented', DATADO_ILLEGAL_RESULT_MODE); }; $this->methods[$methodName] = \Closure::bind($findMethod, $this, get_class()); }
[ "private", "function", "addSelectionMethod", "(", "QueryBuilderResult", "$", "query", ",", "$", "methodName", ")", "{", "$", "findMethod", "=", "function", "(", ")", "use", "(", "$", "query", ",", "$", "methodName", ")", "{", "$", "sth", "=", "$", "this", "->", "pdo", "->", "prepare", "(", "$", "query", "->", "getSql", "(", ")", ")", ";", "/** @noinspection PhpMethodParametersCountMismatchInspection */", "$", "sth", "->", "setFetchMode", "(", "\\", "PDO", "::", "FETCH_CLASS", ",", "$", "this", "->", "entityClass", "->", "getName", "(", ")", ")", ";", "try", "{", "$", "sth", "->", "execute", "(", "func_get_args", "(", ")", ")", ";", "}", "catch", "(", "PDOException", "$", "e", ")", "{", "throw", "new", "DslSyntaxException", "(", "'Failed to run query ['", ".", "$", "methodName", ".", "'] with parameters '", ".", "print_r", "(", "func_get_args", "(", ")", ",", "true", ")", ")", ";", "}", "switch", "(", "$", "query", "->", "getResultMode", "(", ")", ")", "{", "case", "QueryBuilderResult", "::", "RESULT_SELECT_SINGLE", ":", "return", "$", "sth", "->", "fetch", "(", ")", ";", "case", "QueryBuilderResult", "::", "RESULT_SELECT_MULTIPLE", ":", "return", "$", "sth", "->", "fetchAll", "(", ")", ";", "}", "throw", "new", "DslSyntaxException", "(", "'Result Mode '", ".", "$", "query", "->", "getResultMode", "(", ")", ".", "' is not implemented'", ",", "DATADO_ILLEGAL_RESULT_MODE", ")", ";", "}", ";", "$", "this", "->", "methods", "[", "$", "methodName", "]", "=", "\\", "Closure", "::", "bind", "(", "$", "findMethod", ",", "$", "this", ",", "get_class", "(", ")", ")", ";", "}" ]
Add a method that can either result in an entity or an array of entities. @param $query QueryBuilderResult a parsed query @param $methodName string the name of the dsl method @throws DslSyntaxException if an unsupported result mode was requested
[ "Add", "a", "method", "that", "can", "either", "result", "in", "an", "entity", "or", "an", "array", "of", "entities", "." ]
train
https://github.com/DataDo/data/blob/555b02a27755032fcd53e165b0674e81a68067c0/src/main/php/DataDo/Data/Repository.php#L219-L244
DataDo/data
src/main/php/DataDo/Data/Repository.php
Repository.addIntResultMethod
private function addIntResultMethod(QueryBuilderResult $query, $methodName) { $intResultMethod = function () use ($query) { $sth = $this->pdo->prepare($query->getSql()); $sth->execute(func_get_args()); return $sth->rowCount(); }; $this->methods[$methodName] = \Closure::bind($intResultMethod, $this, get_class()); }
php
private function addIntResultMethod(QueryBuilderResult $query, $methodName) { $intResultMethod = function () use ($query) { $sth = $this->pdo->prepare($query->getSql()); $sth->execute(func_get_args()); return $sth->rowCount(); }; $this->methods[$methodName] = \Closure::bind($intResultMethod, $this, get_class()); }
[ "private", "function", "addIntResultMethod", "(", "QueryBuilderResult", "$", "query", ",", "$", "methodName", ")", "{", "$", "intResultMethod", "=", "function", "(", ")", "use", "(", "$", "query", ")", "{", "$", "sth", "=", "$", "this", "->", "pdo", "->", "prepare", "(", "$", "query", "->", "getSql", "(", ")", ")", ";", "$", "sth", "->", "execute", "(", "func_get_args", "(", ")", ")", ";", "return", "$", "sth", "->", "rowCount", "(", ")", ";", "}", ";", "$", "this", "->", "methods", "[", "$", "methodName", "]", "=", "\\", "Closure", "::", "bind", "(", "$", "intResultMethod", ",", "$", "this", ",", "get_class", "(", ")", ")", ";", "}" ]
Add a new method that will result in an integer. @param $query QueryBuilderResult a parsed dsl query @param $methodName string the name of the method
[ "Add", "a", "new", "method", "that", "will", "result", "in", "an", "integer", "." ]
train
https://github.com/DataDo/data/blob/555b02a27755032fcd53e165b0674e81a68067c0/src/main/php/DataDo/Data/Repository.php#L251-L260
DataDo/data
src/main/php/DataDo/Data/Repository.php
Repository.checkDatabase
public function checkDatabase($showAllData = true) { switch ($this->pdo->getAttribute(PDO::ATTR_DRIVER_NAME)) { case 'mysql': $sth = $this->pdo->prepare('SELECT COLUMN_NAME FROM information_schema.COLUMNS WHERE TABLE_NAME = ?'); $sth->execute(array($this->tableName)); $columnNameColumn = 'COLUMN_NAME'; break; case 'sqlite': $sth = $this->pdo->prepare("PRAGMA table_info($this->tableName)"); $sth->execute(); $columnNameColumn = 'name'; break; default: echo '<p>SQL Driver: ' . $this->pdo->getAttribute(PDO::ATTR_DRIVER_NAME) . ' is not supported by the checking tool... sorry</p>' . PHP_EOL; return; } $tableProperties = $sth->fetchAll(); $classProperties = $this->entityClass->getProperties(); $properties = []; foreach ($tableProperties as $prop) { $newProp = new stdClass(); $newProp->actualColumnName = $prop[$columnNameColumn]; $properties[$newProp->actualColumnName] = $newProp; } foreach ($classProperties as $prop) { $expectedColumnName = $this->namingContention->propertyToColumnName($prop); if (array_key_exists($expectedColumnName, $properties)) { $newProp = $properties[$expectedColumnName]; } else { $newProp = new stdClass(); $properties[$expectedColumnName] = $newProp; } $newProp->propertyName = $prop->getName(); $newProp->expectedColumnName = $expectedColumnName; } $issetOr = function (&$value, $default = '') { return isset($value) ? $value : $default; }; $pdoAtt = function ($att) { try { return $this->pdo->getAttribute($att); } catch (PDOException $e) { return 'Not supported by driver'; } }; $getClass = function (stdClass $prop) use ($issetOr) { $classes = $issetOr($prop->expectedColumnName) === $issetOr($prop->actualColumnName) ? 'correct' : 'error'; if ($issetOr($prop->propertyName) === $this->idProperty->getName()) { $classes .= ' primary-key'; } return $classes; }; $entitiesError = false; $entities = []; if ($showAllData) { try { $entities = $this->findAll(); } catch (\Exception $e) { $entitiesError = $e; } } include 'Check/checkDatabaseTable.php'; }
php
public function checkDatabase($showAllData = true) { switch ($this->pdo->getAttribute(PDO::ATTR_DRIVER_NAME)) { case 'mysql': $sth = $this->pdo->prepare('SELECT COLUMN_NAME FROM information_schema.COLUMNS WHERE TABLE_NAME = ?'); $sth->execute(array($this->tableName)); $columnNameColumn = 'COLUMN_NAME'; break; case 'sqlite': $sth = $this->pdo->prepare("PRAGMA table_info($this->tableName)"); $sth->execute(); $columnNameColumn = 'name'; break; default: echo '<p>SQL Driver: ' . $this->pdo->getAttribute(PDO::ATTR_DRIVER_NAME) . ' is not supported by the checking tool... sorry</p>' . PHP_EOL; return; } $tableProperties = $sth->fetchAll(); $classProperties = $this->entityClass->getProperties(); $properties = []; foreach ($tableProperties as $prop) { $newProp = new stdClass(); $newProp->actualColumnName = $prop[$columnNameColumn]; $properties[$newProp->actualColumnName] = $newProp; } foreach ($classProperties as $prop) { $expectedColumnName = $this->namingContention->propertyToColumnName($prop); if (array_key_exists($expectedColumnName, $properties)) { $newProp = $properties[$expectedColumnName]; } else { $newProp = new stdClass(); $properties[$expectedColumnName] = $newProp; } $newProp->propertyName = $prop->getName(); $newProp->expectedColumnName = $expectedColumnName; } $issetOr = function (&$value, $default = '') { return isset($value) ? $value : $default; }; $pdoAtt = function ($att) { try { return $this->pdo->getAttribute($att); } catch (PDOException $e) { return 'Not supported by driver'; } }; $getClass = function (stdClass $prop) use ($issetOr) { $classes = $issetOr($prop->expectedColumnName) === $issetOr($prop->actualColumnName) ? 'correct' : 'error'; if ($issetOr($prop->propertyName) === $this->idProperty->getName()) { $classes .= ' primary-key'; } return $classes; }; $entitiesError = false; $entities = []; if ($showAllData) { try { $entities = $this->findAll(); } catch (\Exception $e) { $entitiesError = $e; } } include 'Check/checkDatabaseTable.php'; }
[ "public", "function", "checkDatabase", "(", "$", "showAllData", "=", "true", ")", "{", "switch", "(", "$", "this", "->", "pdo", "->", "getAttribute", "(", "PDO", "::", "ATTR_DRIVER_NAME", ")", ")", "{", "case", "'mysql'", ":", "$", "sth", "=", "$", "this", "->", "pdo", "->", "prepare", "(", "'SELECT COLUMN_NAME FROM information_schema.COLUMNS WHERE TABLE_NAME = ?'", ")", ";", "$", "sth", "->", "execute", "(", "array", "(", "$", "this", "->", "tableName", ")", ")", ";", "$", "columnNameColumn", "=", "'COLUMN_NAME'", ";", "break", ";", "case", "'sqlite'", ":", "$", "sth", "=", "$", "this", "->", "pdo", "->", "prepare", "(", "\"PRAGMA table_info($this->tableName)\"", ")", ";", "$", "sth", "->", "execute", "(", ")", ";", "$", "columnNameColumn", "=", "'name'", ";", "break", ";", "default", ":", "echo", "'<p>SQL Driver: '", ".", "$", "this", "->", "pdo", "->", "getAttribute", "(", "PDO", "::", "ATTR_DRIVER_NAME", ")", ".", "' is not supported by the checking tool... sorry</p>'", ".", "PHP_EOL", ";", "return", ";", "}", "$", "tableProperties", "=", "$", "sth", "->", "fetchAll", "(", ")", ";", "$", "classProperties", "=", "$", "this", "->", "entityClass", "->", "getProperties", "(", ")", ";", "$", "properties", "=", "[", "]", ";", "foreach", "(", "$", "tableProperties", "as", "$", "prop", ")", "{", "$", "newProp", "=", "new", "stdClass", "(", ")", ";", "$", "newProp", "->", "actualColumnName", "=", "$", "prop", "[", "$", "columnNameColumn", "]", ";", "$", "properties", "[", "$", "newProp", "->", "actualColumnName", "]", "=", "$", "newProp", ";", "}", "foreach", "(", "$", "classProperties", "as", "$", "prop", ")", "{", "$", "expectedColumnName", "=", "$", "this", "->", "namingContention", "->", "propertyToColumnName", "(", "$", "prop", ")", ";", "if", "(", "array_key_exists", "(", "$", "expectedColumnName", ",", "$", "properties", ")", ")", "{", "$", "newProp", "=", "$", "properties", "[", "$", "expectedColumnName", "]", ";", "}", "else", "{", "$", "newProp", "=", "new", "stdClass", "(", ")", ";", "$", "properties", "[", "$", "expectedColumnName", "]", "=", "$", "newProp", ";", "}", "$", "newProp", "->", "propertyName", "=", "$", "prop", "->", "getName", "(", ")", ";", "$", "newProp", "->", "expectedColumnName", "=", "$", "expectedColumnName", ";", "}", "$", "issetOr", "=", "function", "(", "&", "$", "value", ",", "$", "default", "=", "''", ")", "{", "return", "isset", "(", "$", "value", ")", "?", "$", "value", ":", "$", "default", ";", "}", ";", "$", "pdoAtt", "=", "function", "(", "$", "att", ")", "{", "try", "{", "return", "$", "this", "->", "pdo", "->", "getAttribute", "(", "$", "att", ")", ";", "}", "catch", "(", "PDOException", "$", "e", ")", "{", "return", "'Not supported by driver'", ";", "}", "}", ";", "$", "getClass", "=", "function", "(", "stdClass", "$", "prop", ")", "use", "(", "$", "issetOr", ")", "{", "$", "classes", "=", "$", "issetOr", "(", "$", "prop", "->", "expectedColumnName", ")", "===", "$", "issetOr", "(", "$", "prop", "->", "actualColumnName", ")", "?", "'correct'", ":", "'error'", ";", "if", "(", "$", "issetOr", "(", "$", "prop", "->", "propertyName", ")", "===", "$", "this", "->", "idProperty", "->", "getName", "(", ")", ")", "{", "$", "classes", ".=", "' primary-key'", ";", "}", "return", "$", "classes", ";", "}", ";", "$", "entitiesError", "=", "false", ";", "$", "entities", "=", "[", "]", ";", "if", "(", "$", "showAllData", ")", "{", "try", "{", "$", "entities", "=", "$", "this", "->", "findAll", "(", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "entitiesError", "=", "$", "e", ";", "}", "}", "include", "'Check/checkDatabaseTable.php'", ";", "}" ]
This method will run some analysis on the correctness of your configuration. It will be exported to the screen. @param boolean $showAllData set this to false if you want to hide the entities row
[ "This", "method", "will", "run", "some", "analysis", "on", "the", "correctness", "of", "your", "configuration", ".", "It", "will", "be", "exported", "to", "the", "screen", "." ]
train
https://github.com/DataDo/data/blob/555b02a27755032fcd53e165b0674e81a68067c0/src/main/php/DataDo/Data/Repository.php#L285-L359
neyaoz/laravel-view-control
src/ViewControl/Vendor/Illuminate/View/Engines/ControlEngine.php
ControlEngine.get
public function get($path, array $data = []) { $name = $this->getName($path); if (! $this->getFilesystem()->exists($this->getBladePath($path))) { throw new InvalidArgumentException("Blade [$name] not found."); } $view = $this->getBladeEngine()->get($this->getBladePath($path), $data); $data['document'] = new HtmlPageCrawler($view); $this->evaluatePath($path, $data); return $data['document']->saveHTML(); }
php
public function get($path, array $data = []) { $name = $this->getName($path); if (! $this->getFilesystem()->exists($this->getBladePath($path))) { throw new InvalidArgumentException("Blade [$name] not found."); } $view = $this->getBladeEngine()->get($this->getBladePath($path), $data); $data['document'] = new HtmlPageCrawler($view); $this->evaluatePath($path, $data); return $data['document']->saveHTML(); }
[ "public", "function", "get", "(", "$", "path", ",", "array", "$", "data", "=", "[", "]", ")", "{", "$", "name", "=", "$", "this", "->", "getName", "(", "$", "path", ")", ";", "if", "(", "!", "$", "this", "->", "getFilesystem", "(", ")", "->", "exists", "(", "$", "this", "->", "getBladePath", "(", "$", "path", ")", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "\"Blade [$name] not found.\"", ")", ";", "}", "$", "view", "=", "$", "this", "->", "getBladeEngine", "(", ")", "->", "get", "(", "$", "this", "->", "getBladePath", "(", "$", "path", ")", ",", "$", "data", ")", ";", "$", "data", "[", "'document'", "]", "=", "new", "HtmlPageCrawler", "(", "$", "view", ")", ";", "$", "this", "->", "evaluatePath", "(", "$", "path", ",", "$", "data", ")", ";", "return", "$", "data", "[", "'document'", "]", "->", "saveHTML", "(", ")", ";", "}" ]
Get the evaluated contents of the view. @param string $path @param array $data @return string
[ "Get", "the", "evaluated", "contents", "of", "the", "view", "." ]
train
https://github.com/neyaoz/laravel-view-control/blob/2f49777a5cd81223cd36da2ef4385ccd036a4b1e/src/ViewControl/Vendor/Illuminate/View/Engines/ControlEngine.php#L34-L48
php-lug/lug
src/Bundle/ResourceBundle/Form/DataTransformer/BooleanTransformer.php
BooleanTransformer.transform
public function transform($value) { if ($value === null) { return; } if (!is_bool($value)) { throw new TransformationFailedException(sprintf( 'The boolean type expects a boolean or null value, got "%s"', is_object($value) ? get_class($value) : gettype($value) )); } return $value; }
php
public function transform($value) { if ($value === null) { return; } if (!is_bool($value)) { throw new TransformationFailedException(sprintf( 'The boolean type expects a boolean or null value, got "%s"', is_object($value) ? get_class($value) : gettype($value) )); } return $value; }
[ "public", "function", "transform", "(", "$", "value", ")", "{", "if", "(", "$", "value", "===", "null", ")", "{", "return", ";", "}", "if", "(", "!", "is_bool", "(", "$", "value", ")", ")", "{", "throw", "new", "TransformationFailedException", "(", "sprintf", "(", "'The boolean type expects a boolean or null value, got \"%s\"'", ",", "is_object", "(", "$", "value", ")", "?", "get_class", "(", "$", "value", ")", ":", "gettype", "(", "$", "value", ")", ")", ")", ";", "}", "return", "$", "value", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/ResourceBundle/Form/DataTransformer/BooleanTransformer.php#L25-L39
php-lug/lug
src/Bundle/ResourceBundle/Form/DataTransformer/BooleanTransformer.php
BooleanTransformer.reverseTransform
public function reverseTransform($value) { if ($value === null || $value === '') { return false; } if (!is_scalar($value) || ($value = filter_var($value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE)) === null) { throw new TransformationFailedException('The boolean value is not valid.'); } return $value; }
php
public function reverseTransform($value) { if ($value === null || $value === '') { return false; } if (!is_scalar($value) || ($value = filter_var($value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE)) === null) { throw new TransformationFailedException('The boolean value is not valid.'); } return $value; }
[ "public", "function", "reverseTransform", "(", "$", "value", ")", "{", "if", "(", "$", "value", "===", "null", "||", "$", "value", "===", "''", ")", "{", "return", "false", ";", "}", "if", "(", "!", "is_scalar", "(", "$", "value", ")", "||", "(", "$", "value", "=", "filter_var", "(", "$", "value", ",", "FILTER_VALIDATE_BOOLEAN", ",", "FILTER_NULL_ON_FAILURE", ")", ")", "===", "null", ")", "{", "throw", "new", "TransformationFailedException", "(", "'The boolean value is not valid.'", ")", ";", "}", "return", "$", "value", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/ResourceBundle/Form/DataTransformer/BooleanTransformer.php#L44-L56
InactiveProjects/limoncello-illuminate
app/Database/Factories/Factory.php
Factory.getRandomUser
protected function getRandomUser() { if ($this->users === null) { $this->users = User::all(); } return $this->users->random(); }
php
protected function getRandomUser() { if ($this->users === null) { $this->users = User::all(); } return $this->users->random(); }
[ "protected", "function", "getRandomUser", "(", ")", "{", "if", "(", "$", "this", "->", "users", "===", "null", ")", "{", "$", "this", "->", "users", "=", "User", "::", "all", "(", ")", ";", "}", "return", "$", "this", "->", "users", "->", "random", "(", ")", ";", "}" ]
@return User @SuppressWarnings(PHPMD.StaticAccess)
[ "@return", "User" ]
train
https://github.com/InactiveProjects/limoncello-illuminate/blob/cae6fc26190efcf090495a5c3582c10fa2430897/app/Database/Factories/Factory.php#L27-L34
expectation-php/expect
src/matcher/ToMatch.php
ToMatch.match
public function match($actual) { $this->actual = $actual; $patternMatcher = new PatternMatcher($this->expected); return $patternMatcher->match($this->actual); }
php
public function match($actual) { $this->actual = $actual; $patternMatcher = new PatternMatcher($this->expected); return $patternMatcher->match($this->actual); }
[ "public", "function", "match", "(", "$", "actual", ")", "{", "$", "this", "->", "actual", "=", "$", "actual", ";", "$", "patternMatcher", "=", "new", "PatternMatcher", "(", "$", "this", "->", "expected", ")", ";", "return", "$", "patternMatcher", "->", "match", "(", "$", "this", "->", "actual", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/expectation-php/expect/blob/1a32c5af37f3dc8dabe4e8eedeeb21aea16ce139/src/matcher/ToMatch.php#L51-L57
f3ath/lazypdo
src/LazyPDO.php
LazyPDO.getPDO
protected function getPDO() { if (null === $this->pdo) { $this->pdo = new \PDO($this->dsn, $this->user, $this->password, $this->options); } return $this->pdo; }
php
protected function getPDO() { if (null === $this->pdo) { $this->pdo = new \PDO($this->dsn, $this->user, $this->password, $this->options); } return $this->pdo; }
[ "protected", "function", "getPDO", "(", ")", "{", "if", "(", "null", "===", "$", "this", "->", "pdo", ")", "{", "$", "this", "->", "pdo", "=", "new", "\\", "PDO", "(", "$", "this", "->", "dsn", ",", "$", "this", "->", "user", ",", "$", "this", "->", "password", ",", "$", "this", "->", "options", ")", ";", "}", "return", "$", "this", "->", "pdo", ";", "}" ]
Get PDO object. Cache the result @return \PDO
[ "Get", "PDO", "object", ".", "Cache", "the", "result" ]
train
https://github.com/f3ath/lazypdo/blob/0ebdb3bc87d327d68a322d5fca049f4c21865928/src/LazyPDO.php#L43-L49
f3ath/lazypdo
src/LazyPDO.php
LazyPDO.serialize
public function serialize() { if ($this->inTransaction()) { throw new \RuntimeException('Can not serialize in transaction'); } return serialize(array( $this->dsn, $this->user, $this->password, $this->options, )); }
php
public function serialize() { if ($this->inTransaction()) { throw new \RuntimeException('Can not serialize in transaction'); } return serialize(array( $this->dsn, $this->user, $this->password, $this->options, )); }
[ "public", "function", "serialize", "(", ")", "{", "if", "(", "$", "this", "->", "inTransaction", "(", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'Can not serialize in transaction'", ")", ";", "}", "return", "serialize", "(", "array", "(", "$", "this", "->", "dsn", ",", "$", "this", "->", "user", ",", "$", "this", "->", "password", ",", "$", "this", "->", "options", ",", ")", ")", ";", "}" ]
serialize @return string
[ "serialize" ]
train
https://github.com/f3ath/lazypdo/blob/0ebdb3bc87d327d68a322d5fca049f4c21865928/src/LazyPDO.php#L67-L78
f3ath/lazypdo
src/LazyPDO.php
LazyPDO.unserialize
public function unserialize($serialized) { list($this->dsn, $this->user, $this->password, $this->options) = unserialize($serialized); }
php
public function unserialize($serialized) { list($this->dsn, $this->user, $this->password, $this->options) = unserialize($serialized); }
[ "public", "function", "unserialize", "(", "$", "serialized", ")", "{", "list", "(", "$", "this", "->", "dsn", ",", "$", "this", "->", "user", ",", "$", "this", "->", "password", ",", "$", "this", "->", "options", ")", "=", "unserialize", "(", "$", "serialized", ")", ";", "}" ]
unserialize @param string $serialized @return void
[ "unserialize" ]
train
https://github.com/f3ath/lazypdo/blob/0ebdb3bc87d327d68a322d5fca049f4c21865928/src/LazyPDO.php#L86-L89
f3ath/lazypdo
src/LazyPDO.php
LazyPDO.setAttribute
public function setAttribute($attribute, $value) { if (parent::setAttribute($attribute, $value)) { $this->options[$attribute] = $value; return true; } return false; }
php
public function setAttribute($attribute, $value) { if (parent::setAttribute($attribute, $value)) { $this->options[$attribute] = $value; return true; } return false; }
[ "public", "function", "setAttribute", "(", "$", "attribute", ",", "$", "value", ")", "{", "if", "(", "parent", "::", "setAttribute", "(", "$", "attribute", ",", "$", "value", ")", ")", "{", "$", "this", "->", "options", "[", "$", "attribute", "]", "=", "$", "value", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
setAttribute @param int $attribute @param mixed $value @return boolean
[ "setAttribute" ]
train
https://github.com/f3ath/lazypdo/blob/0ebdb3bc87d327d68a322d5fca049f4c21865928/src/LazyPDO.php#L98-L105
VincentChalnot/SidusDataGridBundle
Renderer/DefaultColumnLabelRenderer.php
DefaultColumnLabelRenderer.renderColumnLabel
public function renderColumnLabel(Column $column): string { $label = $column->getLabel(); if (!$label) { $key = "datagrid.{$column->getDataGrid()->getCode()}.{$column->getCode()}"; if ($this->translator instanceof TranslatorBagInterface && $this->translator->getCatalogue() && $this->translator->getCatalogue()->has($key) ) { $label = $key; } else { $label = ucfirst( strtolower(trim(preg_replace(['/([A-Z])/', '/[_\s]+/'], ['_$1', ' '], $column->getCode()))) ); } } return $this->translator->trans($label); }
php
public function renderColumnLabel(Column $column): string { $label = $column->getLabel(); if (!$label) { $key = "datagrid.{$column->getDataGrid()->getCode()}.{$column->getCode()}"; if ($this->translator instanceof TranslatorBagInterface && $this->translator->getCatalogue() && $this->translator->getCatalogue()->has($key) ) { $label = $key; } else { $label = ucfirst( strtolower(trim(preg_replace(['/([A-Z])/', '/[_\s]+/'], ['_$1', ' '], $column->getCode()))) ); } } return $this->translator->trans($label); }
[ "public", "function", "renderColumnLabel", "(", "Column", "$", "column", ")", ":", "string", "{", "$", "label", "=", "$", "column", "->", "getLabel", "(", ")", ";", "if", "(", "!", "$", "label", ")", "{", "$", "key", "=", "\"datagrid.{$column->getDataGrid()->getCode()}.{$column->getCode()}\"", ";", "if", "(", "$", "this", "->", "translator", "instanceof", "TranslatorBagInterface", "&&", "$", "this", "->", "translator", "->", "getCatalogue", "(", ")", "&&", "$", "this", "->", "translator", "->", "getCatalogue", "(", ")", "->", "has", "(", "$", "key", ")", ")", "{", "$", "label", "=", "$", "key", ";", "}", "else", "{", "$", "label", "=", "ucfirst", "(", "strtolower", "(", "trim", "(", "preg_replace", "(", "[", "'/([A-Z])/'", ",", "'/[_\\s]+/'", "]", ",", "[", "'_$1'", ",", "' '", "]", ",", "$", "column", "->", "getCode", "(", ")", ")", ")", ")", ")", ";", "}", "}", "return", "$", "this", "->", "translator", "->", "trans", "(", "$", "label", ")", ";", "}" ]
@param Column $column @return string
[ "@param", "Column", "$column" ]
train
https://github.com/VincentChalnot/SidusDataGridBundle/blob/aa929113e2208ed335f514d2891affaf7fddf3f6/Renderer/DefaultColumnLabelRenderer.php#L40-L58
technote-space/wordpress-plugin-base
src/classes/controllers/admin/setting.php
Setting.post_action
protected function post_action() { foreach ( $this->app->setting->get_groups() as $group ) { foreach ( $this->app->setting->get_settings( $group ) as $setting ) { $this->app->option->set_post_value( $this->app->utility->array_get( $this->app->setting->get_setting( $setting, true ), 'name', '' ) ); } } $this->app->add_message( 'Settings updated.', 'setting' ); }
php
protected function post_action() { foreach ( $this->app->setting->get_groups() as $group ) { foreach ( $this->app->setting->get_settings( $group ) as $setting ) { $this->app->option->set_post_value( $this->app->utility->array_get( $this->app->setting->get_setting( $setting, true ), 'name', '' ) ); } } $this->app->add_message( 'Settings updated.', 'setting' ); }
[ "protected", "function", "post_action", "(", ")", "{", "foreach", "(", "$", "this", "->", "app", "->", "setting", "->", "get_groups", "(", ")", "as", "$", "group", ")", "{", "foreach", "(", "$", "this", "->", "app", "->", "setting", "->", "get_settings", "(", "$", "group", ")", "as", "$", "setting", ")", "{", "$", "this", "->", "app", "->", "option", "->", "set_post_value", "(", "$", "this", "->", "app", "->", "utility", "->", "array_get", "(", "$", "this", "->", "app", "->", "setting", "->", "get_setting", "(", "$", "setting", ",", "true", ")", ",", "'name'", ",", "''", ")", ")", ";", "}", "}", "$", "this", "->", "app", "->", "add_message", "(", "'Settings updated.'", ",", "'setting'", ")", ";", "}" ]
post action
[ "post", "action" ]
train
https://github.com/technote-space/wordpress-plugin-base/blob/02cfcba358432a2539af07a69d9db00ff7c14eac/src/classes/controllers/admin/setting.php#L46-L53
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/parser/headers_holder.php
ezcMailHeadersHolder.offsetGet
public function offsetGet( $key ) { $key = strtolower( $key ); if ( !array_key_exists( $key, $this->lookup ) ) { return null; } return $this->map[$this->lookup[$key]]; }
php
public function offsetGet( $key ) { $key = strtolower( $key ); if ( !array_key_exists( $key, $this->lookup ) ) { return null; } return $this->map[$this->lookup[$key]]; }
[ "public", "function", "offsetGet", "(", "$", "key", ")", "{", "$", "key", "=", "strtolower", "(", "$", "key", ")", ";", "if", "(", "!", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "lookup", ")", ")", "{", "return", "null", ";", "}", "return", "$", "this", "->", "map", "[", "$", "this", "->", "lookup", "[", "$", "key", "]", "]", ";", "}" ]
Returns the value recognized with $key. @param string $key @return mixed
[ "Returns", "the", "value", "recognized", "with", "$key", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/parser/headers_holder.php#L71-L79
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/parser/headers_holder.php
ezcMailHeadersHolder.offsetSet
public function offsetSet( $key, $value ) { $lowerKey = strtolower( $key ); if ( !array_key_exists( $lowerKey, $this->lookup ) ) { $this->map[$key] = $value; $this->lookup[$lowerKey] = $key; } else // use old case { $this->map[$this->lookup[$lowerKey]] = $value; } }
php
public function offsetSet( $key, $value ) { $lowerKey = strtolower( $key ); if ( !array_key_exists( $lowerKey, $this->lookup ) ) { $this->map[$key] = $value; $this->lookup[$lowerKey] = $key; } else // use old case { $this->map[$this->lookup[$lowerKey]] = $value; } }
[ "public", "function", "offsetSet", "(", "$", "key", ",", "$", "value", ")", "{", "$", "lowerKey", "=", "strtolower", "(", "$", "key", ")", ";", "if", "(", "!", "array_key_exists", "(", "$", "lowerKey", ",", "$", "this", "->", "lookup", ")", ")", "{", "$", "this", "->", "map", "[", "$", "key", "]", "=", "$", "value", ";", "$", "this", "->", "lookup", "[", "$", "lowerKey", "]", "=", "$", "key", ";", "}", "else", "// use old case", "{", "$", "this", "->", "map", "[", "$", "this", "->", "lookup", "[", "$", "lowerKey", "]", "]", "=", "$", "value", ";", "}", "}" ]
Sets the offset $key to the value $value. If it is a new entry the case in $key will be stored. If the $key exists already using a case insensitive lookup the new spelling will be discarded. @param string $key @param mixed $value
[ "Sets", "the", "offset", "$key", "to", "the", "value", "$value", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/parser/headers_holder.php#L90-L102
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/parser/headers_holder.php
ezcMailHeadersHolder.offsetUnset
public function offsetUnset( $key ) { $key = strtolower( $key ); if ( array_key_exists( $key, $this->lookup ) ) { unset( $this->map[$this->lookup[$key]] ); unset( $this->lookup[$key] ); } }
php
public function offsetUnset( $key ) { $key = strtolower( $key ); if ( array_key_exists( $key, $this->lookup ) ) { unset( $this->map[$this->lookup[$key]] ); unset( $this->lookup[$key] ); } }
[ "public", "function", "offsetUnset", "(", "$", "key", ")", "{", "$", "key", "=", "strtolower", "(", "$", "key", ")", ";", "if", "(", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "lookup", ")", ")", "{", "unset", "(", "$", "this", "->", "map", "[", "$", "this", "->", "lookup", "[", "$", "key", "]", "]", ")", ";", "unset", "(", "$", "this", "->", "lookup", "[", "$", "key", "]", ")", ";", "}", "}" ]
Unsets the key $key. @param string $key
[ "Unsets", "the", "key", "$key", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/parser/headers_holder.php#L109-L117
heidelpay/PhpDoc
src/phpDocumentor/Descriptor/ServiceProvider.php
ServiceProvider.register
public function register(Application $app) { $app['parser.example.finder'] = new Example\Finder(); $this->addCache($app); $this->addAssemblers($app); $this->addFilters($app); $this->addValidators($app); $this->addBuilder($app); // I would prefer to extend it but due to a circular reference will pimple fatal $this->attachFiltersToManager($app['descriptor.filter'], $app); $app['descriptor.analyzer'] = function () { return new ProjectAnalyzer(); }; }
php
public function register(Application $app) { $app['parser.example.finder'] = new Example\Finder(); $this->addCache($app); $this->addAssemblers($app); $this->addFilters($app); $this->addValidators($app); $this->addBuilder($app); // I would prefer to extend it but due to a circular reference will pimple fatal $this->attachFiltersToManager($app['descriptor.filter'], $app); $app['descriptor.analyzer'] = function () { return new ProjectAnalyzer(); }; }
[ "public", "function", "register", "(", "Application", "$", "app", ")", "{", "$", "app", "[", "'parser.example.finder'", "]", "=", "new", "Example", "\\", "Finder", "(", ")", ";", "$", "this", "->", "addCache", "(", "$", "app", ")", ";", "$", "this", "->", "addAssemblers", "(", "$", "app", ")", ";", "$", "this", "->", "addFilters", "(", "$", "app", ")", ";", "$", "this", "->", "addValidators", "(", "$", "app", ")", ";", "$", "this", "->", "addBuilder", "(", "$", "app", ")", ";", "// I would prefer to extend it but due to a circular reference will pimple fatal", "$", "this", "->", "attachFiltersToManager", "(", "$", "app", "[", "'descriptor.filter'", "]", ",", "$", "app", ")", ";", "$", "app", "[", "'descriptor.analyzer'", "]", "=", "function", "(", ")", "{", "return", "new", "ProjectAnalyzer", "(", ")", ";", "}", ";", "}" ]
Adds the services needed to build the descriptors. @param Application $app An Application instance @return void
[ "Adds", "the", "services", "needed", "to", "build", "the", "descriptors", "." ]
train
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Descriptor/ServiceProvider.php#L89-L105
heidelpay/PhpDoc
src/phpDocumentor/Descriptor/ServiceProvider.php
ServiceProvider.attachAssemblersToFactory
public function attachAssemblersToFactory(AssemblerFactory $factory, Application $app) { // @codingStandardsIgnoreStart because we limit the verbosity by making all closures single-line $fileMatcher = function ($criteria) { return $criteria instanceof FileReflector; }; $constantMatcher = function ($criteria) { return $criteria instanceof ConstantReflector || $criteria instanceof ClassConstant; }; $traitMatcher = function ($criteria) { return $criteria instanceof TraitReflector; }; $classMatcher = function ($criteria) { return $criteria instanceof ClassReflector; }; $interfaceMatcher = function ($criteria) { return $criteria instanceof InterfaceReflector; }; $propertyMatcher = function ($criteria) { return $criteria instanceof ClassReflector\PropertyReflector; }; $methodMatcher = function ($criteria) { return $criteria instanceof ClassReflector\MethodReflector; }; $argumentMatcher = function ($criteria) { return $criteria instanceof FunctionReflector\ArgumentReflector; }; $functionMatcher = function ($criteria) { return $criteria instanceof FunctionReflector; }; $authorMatcher = function ($criteria) { return $criteria instanceof AuthorTag; }; $deprecatedMatcher = function ($criteria) { return $criteria instanceof DeprecatedTag; }; $exampleMatcher = function ($criteria) { return $criteria instanceof ExampleTag; }; $linkMatcher = function ($criteria) { return $criteria instanceof LinkTag; }; $methodTagMatcher = function ($criteria) { return $criteria instanceof MethodTag; }; $propertyTagMatcher = function ($criteria) { return $criteria instanceof PropertyTag; }; $paramMatcher = function ($criteria) { return $criteria instanceof ParamTag; }; $throwsMatcher = function ($criteria) { return $criteria instanceof ThrowsTag; }; $returnMatcher = function ($criteria) { return $criteria instanceof ReturnTag; }; $usesMatcher = function ($criteria) { return $criteria instanceof UsesTag; }; $seeMatcher = function ($criteria) { return $criteria instanceof SeeTag; }; $sinceMatcher = function ($criteria) { return $criteria instanceof SinceTag; }; $varMatcher = function ($criteria) { return $criteria instanceof VarTag; }; $versionMatcher = function ($criteria) { return $criteria instanceof Tag\VersionTag; }; $typeCollectionMatcher = function ($criteria) { return $criteria instanceof TypeCollection; }; $tagFallbackMatcher = function ($criteria) { return $criteria instanceof Tag; }; // @codingStandardsIgnoreEnd $argumentAssembler = new ArgumentAssembler(); $factory->register($fileMatcher, new FileAssembler()); $factory->register($constantMatcher, new ConstantAssembler()); $factory->register($traitMatcher, new TraitAssembler()); $factory->register($classMatcher, new ClassAssembler()); $factory->register($interfaceMatcher, new InterfaceAssembler()); $factory->register($propertyMatcher, new PropertyAssembler()); $factory->register($argumentMatcher, $argumentAssembler); $factory->register($methodMatcher, new MethodAssembler($argumentAssembler)); $factory->register($functionMatcher, new FunctionAssembler($argumentAssembler)); $factory->register($authorMatcher, new AuthorAssembler()); $factory->register($deprecatedMatcher, new DeprecatedAssembler()); $factory->register($exampleMatcher, new ExampleAssembler($app['parser.example.finder'])); $factory->register($linkMatcher, new LinkAssembler()); $factory->register($methodTagMatcher, new MethodTagAssembler()); $factory->register($propertyTagMatcher, new PropertyTagAssembler()); $factory->register($varMatcher, new VarAssembler()); $factory->register($paramMatcher, new ParamAssembler()); $factory->register($throwsMatcher, new ThrowsAssembler()); $factory->register($returnMatcher, new ReturnAssembler()); $factory->register($usesMatcher, new UsesAssembler()); $factory->register($seeMatcher, new SeeAssembler()); $factory->register($sinceMatcher, new SinceAssembler()); $factory->register($versionMatcher, new VersionAssembler()); $factory->register($typeCollectionMatcher, new TypeCollectionAssembler()); $factory->registerFallback($tagFallbackMatcher, new GenericTagAssembler()); return $factory; }
php
public function attachAssemblersToFactory(AssemblerFactory $factory, Application $app) { // @codingStandardsIgnoreStart because we limit the verbosity by making all closures single-line $fileMatcher = function ($criteria) { return $criteria instanceof FileReflector; }; $constantMatcher = function ($criteria) { return $criteria instanceof ConstantReflector || $criteria instanceof ClassConstant; }; $traitMatcher = function ($criteria) { return $criteria instanceof TraitReflector; }; $classMatcher = function ($criteria) { return $criteria instanceof ClassReflector; }; $interfaceMatcher = function ($criteria) { return $criteria instanceof InterfaceReflector; }; $propertyMatcher = function ($criteria) { return $criteria instanceof ClassReflector\PropertyReflector; }; $methodMatcher = function ($criteria) { return $criteria instanceof ClassReflector\MethodReflector; }; $argumentMatcher = function ($criteria) { return $criteria instanceof FunctionReflector\ArgumentReflector; }; $functionMatcher = function ($criteria) { return $criteria instanceof FunctionReflector; }; $authorMatcher = function ($criteria) { return $criteria instanceof AuthorTag; }; $deprecatedMatcher = function ($criteria) { return $criteria instanceof DeprecatedTag; }; $exampleMatcher = function ($criteria) { return $criteria instanceof ExampleTag; }; $linkMatcher = function ($criteria) { return $criteria instanceof LinkTag; }; $methodTagMatcher = function ($criteria) { return $criteria instanceof MethodTag; }; $propertyTagMatcher = function ($criteria) { return $criteria instanceof PropertyTag; }; $paramMatcher = function ($criteria) { return $criteria instanceof ParamTag; }; $throwsMatcher = function ($criteria) { return $criteria instanceof ThrowsTag; }; $returnMatcher = function ($criteria) { return $criteria instanceof ReturnTag; }; $usesMatcher = function ($criteria) { return $criteria instanceof UsesTag; }; $seeMatcher = function ($criteria) { return $criteria instanceof SeeTag; }; $sinceMatcher = function ($criteria) { return $criteria instanceof SinceTag; }; $varMatcher = function ($criteria) { return $criteria instanceof VarTag; }; $versionMatcher = function ($criteria) { return $criteria instanceof Tag\VersionTag; }; $typeCollectionMatcher = function ($criteria) { return $criteria instanceof TypeCollection; }; $tagFallbackMatcher = function ($criteria) { return $criteria instanceof Tag; }; // @codingStandardsIgnoreEnd $argumentAssembler = new ArgumentAssembler(); $factory->register($fileMatcher, new FileAssembler()); $factory->register($constantMatcher, new ConstantAssembler()); $factory->register($traitMatcher, new TraitAssembler()); $factory->register($classMatcher, new ClassAssembler()); $factory->register($interfaceMatcher, new InterfaceAssembler()); $factory->register($propertyMatcher, new PropertyAssembler()); $factory->register($argumentMatcher, $argumentAssembler); $factory->register($methodMatcher, new MethodAssembler($argumentAssembler)); $factory->register($functionMatcher, new FunctionAssembler($argumentAssembler)); $factory->register($authorMatcher, new AuthorAssembler()); $factory->register($deprecatedMatcher, new DeprecatedAssembler()); $factory->register($exampleMatcher, new ExampleAssembler($app['parser.example.finder'])); $factory->register($linkMatcher, new LinkAssembler()); $factory->register($methodTagMatcher, new MethodTagAssembler()); $factory->register($propertyTagMatcher, new PropertyTagAssembler()); $factory->register($varMatcher, new VarAssembler()); $factory->register($paramMatcher, new ParamAssembler()); $factory->register($throwsMatcher, new ThrowsAssembler()); $factory->register($returnMatcher, new ReturnAssembler()); $factory->register($usesMatcher, new UsesAssembler()); $factory->register($seeMatcher, new SeeAssembler()); $factory->register($sinceMatcher, new SinceAssembler()); $factory->register($versionMatcher, new VersionAssembler()); $factory->register($typeCollectionMatcher, new TypeCollectionAssembler()); $factory->registerFallback($tagFallbackMatcher, new GenericTagAssembler()); return $factory; }
[ "public", "function", "attachAssemblersToFactory", "(", "AssemblerFactory", "$", "factory", ",", "Application", "$", "app", ")", "{", "// @codingStandardsIgnoreStart because we limit the verbosity by making all closures single-line", "$", "fileMatcher", "=", "function", "(", "$", "criteria", ")", "{", "return", "$", "criteria", "instanceof", "FileReflector", ";", "}", ";", "$", "constantMatcher", "=", "function", "(", "$", "criteria", ")", "{", "return", "$", "criteria", "instanceof", "ConstantReflector", "||", "$", "criteria", "instanceof", "ClassConstant", ";", "}", ";", "$", "traitMatcher", "=", "function", "(", "$", "criteria", ")", "{", "return", "$", "criteria", "instanceof", "TraitReflector", ";", "}", ";", "$", "classMatcher", "=", "function", "(", "$", "criteria", ")", "{", "return", "$", "criteria", "instanceof", "ClassReflector", ";", "}", ";", "$", "interfaceMatcher", "=", "function", "(", "$", "criteria", ")", "{", "return", "$", "criteria", "instanceof", "InterfaceReflector", ";", "}", ";", "$", "propertyMatcher", "=", "function", "(", "$", "criteria", ")", "{", "return", "$", "criteria", "instanceof", "ClassReflector", "\\", "PropertyReflector", ";", "}", ";", "$", "methodMatcher", "=", "function", "(", "$", "criteria", ")", "{", "return", "$", "criteria", "instanceof", "ClassReflector", "\\", "MethodReflector", ";", "}", ";", "$", "argumentMatcher", "=", "function", "(", "$", "criteria", ")", "{", "return", "$", "criteria", "instanceof", "FunctionReflector", "\\", "ArgumentReflector", ";", "}", ";", "$", "functionMatcher", "=", "function", "(", "$", "criteria", ")", "{", "return", "$", "criteria", "instanceof", "FunctionReflector", ";", "}", ";", "$", "authorMatcher", "=", "function", "(", "$", "criteria", ")", "{", "return", "$", "criteria", "instanceof", "AuthorTag", ";", "}", ";", "$", "deprecatedMatcher", "=", "function", "(", "$", "criteria", ")", "{", "return", "$", "criteria", "instanceof", "DeprecatedTag", ";", "}", ";", "$", "exampleMatcher", "=", "function", "(", "$", "criteria", ")", "{", "return", "$", "criteria", "instanceof", "ExampleTag", ";", "}", ";", "$", "linkMatcher", "=", "function", "(", "$", "criteria", ")", "{", "return", "$", "criteria", "instanceof", "LinkTag", ";", "}", ";", "$", "methodTagMatcher", "=", "function", "(", "$", "criteria", ")", "{", "return", "$", "criteria", "instanceof", "MethodTag", ";", "}", ";", "$", "propertyTagMatcher", "=", "function", "(", "$", "criteria", ")", "{", "return", "$", "criteria", "instanceof", "PropertyTag", ";", "}", ";", "$", "paramMatcher", "=", "function", "(", "$", "criteria", ")", "{", "return", "$", "criteria", "instanceof", "ParamTag", ";", "}", ";", "$", "throwsMatcher", "=", "function", "(", "$", "criteria", ")", "{", "return", "$", "criteria", "instanceof", "ThrowsTag", ";", "}", ";", "$", "returnMatcher", "=", "function", "(", "$", "criteria", ")", "{", "return", "$", "criteria", "instanceof", "ReturnTag", ";", "}", ";", "$", "usesMatcher", "=", "function", "(", "$", "criteria", ")", "{", "return", "$", "criteria", "instanceof", "UsesTag", ";", "}", ";", "$", "seeMatcher", "=", "function", "(", "$", "criteria", ")", "{", "return", "$", "criteria", "instanceof", "SeeTag", ";", "}", ";", "$", "sinceMatcher", "=", "function", "(", "$", "criteria", ")", "{", "return", "$", "criteria", "instanceof", "SinceTag", ";", "}", ";", "$", "varMatcher", "=", "function", "(", "$", "criteria", ")", "{", "return", "$", "criteria", "instanceof", "VarTag", ";", "}", ";", "$", "versionMatcher", "=", "function", "(", "$", "criteria", ")", "{", "return", "$", "criteria", "instanceof", "Tag", "\\", "VersionTag", ";", "}", ";", "$", "typeCollectionMatcher", "=", "function", "(", "$", "criteria", ")", "{", "return", "$", "criteria", "instanceof", "TypeCollection", ";", "}", ";", "$", "tagFallbackMatcher", "=", "function", "(", "$", "criteria", ")", "{", "return", "$", "criteria", "instanceof", "Tag", ";", "}", ";", "// @codingStandardsIgnoreEnd", "$", "argumentAssembler", "=", "new", "ArgumentAssembler", "(", ")", ";", "$", "factory", "->", "register", "(", "$", "fileMatcher", ",", "new", "FileAssembler", "(", ")", ")", ";", "$", "factory", "->", "register", "(", "$", "constantMatcher", ",", "new", "ConstantAssembler", "(", ")", ")", ";", "$", "factory", "->", "register", "(", "$", "traitMatcher", ",", "new", "TraitAssembler", "(", ")", ")", ";", "$", "factory", "->", "register", "(", "$", "classMatcher", ",", "new", "ClassAssembler", "(", ")", ")", ";", "$", "factory", "->", "register", "(", "$", "interfaceMatcher", ",", "new", "InterfaceAssembler", "(", ")", ")", ";", "$", "factory", "->", "register", "(", "$", "propertyMatcher", ",", "new", "PropertyAssembler", "(", ")", ")", ";", "$", "factory", "->", "register", "(", "$", "argumentMatcher", ",", "$", "argumentAssembler", ")", ";", "$", "factory", "->", "register", "(", "$", "methodMatcher", ",", "new", "MethodAssembler", "(", "$", "argumentAssembler", ")", ")", ";", "$", "factory", "->", "register", "(", "$", "functionMatcher", ",", "new", "FunctionAssembler", "(", "$", "argumentAssembler", ")", ")", ";", "$", "factory", "->", "register", "(", "$", "authorMatcher", ",", "new", "AuthorAssembler", "(", ")", ")", ";", "$", "factory", "->", "register", "(", "$", "deprecatedMatcher", ",", "new", "DeprecatedAssembler", "(", ")", ")", ";", "$", "factory", "->", "register", "(", "$", "exampleMatcher", ",", "new", "ExampleAssembler", "(", "$", "app", "[", "'parser.example.finder'", "]", ")", ")", ";", "$", "factory", "->", "register", "(", "$", "linkMatcher", ",", "new", "LinkAssembler", "(", ")", ")", ";", "$", "factory", "->", "register", "(", "$", "methodTagMatcher", ",", "new", "MethodTagAssembler", "(", ")", ")", ";", "$", "factory", "->", "register", "(", "$", "propertyTagMatcher", ",", "new", "PropertyTagAssembler", "(", ")", ")", ";", "$", "factory", "->", "register", "(", "$", "varMatcher", ",", "new", "VarAssembler", "(", ")", ")", ";", "$", "factory", "->", "register", "(", "$", "paramMatcher", ",", "new", "ParamAssembler", "(", ")", ")", ";", "$", "factory", "->", "register", "(", "$", "throwsMatcher", ",", "new", "ThrowsAssembler", "(", ")", ")", ";", "$", "factory", "->", "register", "(", "$", "returnMatcher", ",", "new", "ReturnAssembler", "(", ")", ")", ";", "$", "factory", "->", "register", "(", "$", "usesMatcher", ",", "new", "UsesAssembler", "(", ")", ")", ";", "$", "factory", "->", "register", "(", "$", "seeMatcher", ",", "new", "SeeAssembler", "(", ")", ")", ";", "$", "factory", "->", "register", "(", "$", "sinceMatcher", ",", "new", "SinceAssembler", "(", ")", ")", ";", "$", "factory", "->", "register", "(", "$", "versionMatcher", ",", "new", "VersionAssembler", "(", ")", ")", ";", "$", "factory", "->", "register", "(", "$", "typeCollectionMatcher", ",", "new", "TypeCollectionAssembler", "(", ")", ")", ";", "$", "factory", "->", "registerFallback", "(", "$", "tagFallbackMatcher", ",", "new", "GenericTagAssembler", "(", ")", ")", ";", "return", "$", "factory", ";", "}" ]
Registers the Assemblers used to convert Reflection objects to Descriptors. @param AssemblerFactory $factory @param \Cilex\Application $app @return AssemblerFactory
[ "Registers", "the", "Assemblers", "used", "to", "convert", "Reflection", "objects", "to", "Descriptors", "." ]
train
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Descriptor/ServiceProvider.php#L115-L181
heidelpay/PhpDoc
src/phpDocumentor/Descriptor/ServiceProvider.php
ServiceProvider.attachFiltersToManager
public function attachFiltersToManager(Filter $filterManager, Application $app) { $stripOnVisibility = new StripOnVisibility($app['descriptor.builder']); $filtersOnAllDescriptors = array( new StripInternal($app['descriptor.builder']), new StripIgnore($app['descriptor.builder']) ); foreach ($filtersOnAllDescriptors as $filter) { $filterManager->attach('phpDocumentor\Descriptor\ConstantDescriptor', $filter); $filterManager->attach('phpDocumentor\Descriptor\FunctionDescriptor', $filter); $filterManager->attach('phpDocumentor\Descriptor\InterfaceDescriptor', $filter); $filterManager->attach('phpDocumentor\Descriptor\TraitDescriptor', $filter); $filterManager->attach('phpDocumentor\Descriptor\PropertyDescriptor', $filter); $filterManager->attach('phpDocumentor\Descriptor\MethodDescriptor', $filter); } $filterManager->attach('phpDocumentor\Descriptor\PropertyDescriptor', $stripOnVisibility); $filterManager->attach('phpDocumentor\Descriptor\MethodDescriptor', $stripOnVisibility); return $filterManager; }
php
public function attachFiltersToManager(Filter $filterManager, Application $app) { $stripOnVisibility = new StripOnVisibility($app['descriptor.builder']); $filtersOnAllDescriptors = array( new StripInternal($app['descriptor.builder']), new StripIgnore($app['descriptor.builder']) ); foreach ($filtersOnAllDescriptors as $filter) { $filterManager->attach('phpDocumentor\Descriptor\ConstantDescriptor', $filter); $filterManager->attach('phpDocumentor\Descriptor\FunctionDescriptor', $filter); $filterManager->attach('phpDocumentor\Descriptor\InterfaceDescriptor', $filter); $filterManager->attach('phpDocumentor\Descriptor\TraitDescriptor', $filter); $filterManager->attach('phpDocumentor\Descriptor\PropertyDescriptor', $filter); $filterManager->attach('phpDocumentor\Descriptor\MethodDescriptor', $filter); } $filterManager->attach('phpDocumentor\Descriptor\PropertyDescriptor', $stripOnVisibility); $filterManager->attach('phpDocumentor\Descriptor\MethodDescriptor', $stripOnVisibility); return $filterManager; }
[ "public", "function", "attachFiltersToManager", "(", "Filter", "$", "filterManager", ",", "Application", "$", "app", ")", "{", "$", "stripOnVisibility", "=", "new", "StripOnVisibility", "(", "$", "app", "[", "'descriptor.builder'", "]", ")", ";", "$", "filtersOnAllDescriptors", "=", "array", "(", "new", "StripInternal", "(", "$", "app", "[", "'descriptor.builder'", "]", ")", ",", "new", "StripIgnore", "(", "$", "app", "[", "'descriptor.builder'", "]", ")", ")", ";", "foreach", "(", "$", "filtersOnAllDescriptors", "as", "$", "filter", ")", "{", "$", "filterManager", "->", "attach", "(", "'phpDocumentor\\Descriptor\\ConstantDescriptor'", ",", "$", "filter", ")", ";", "$", "filterManager", "->", "attach", "(", "'phpDocumentor\\Descriptor\\FunctionDescriptor'", ",", "$", "filter", ")", ";", "$", "filterManager", "->", "attach", "(", "'phpDocumentor\\Descriptor\\InterfaceDescriptor'", ",", "$", "filter", ")", ";", "$", "filterManager", "->", "attach", "(", "'phpDocumentor\\Descriptor\\TraitDescriptor'", ",", "$", "filter", ")", ";", "$", "filterManager", "->", "attach", "(", "'phpDocumentor\\Descriptor\\PropertyDescriptor'", ",", "$", "filter", ")", ";", "$", "filterManager", "->", "attach", "(", "'phpDocumentor\\Descriptor\\MethodDescriptor'", ",", "$", "filter", ")", ";", "}", "$", "filterManager", "->", "attach", "(", "'phpDocumentor\\Descriptor\\PropertyDescriptor'", ",", "$", "stripOnVisibility", ")", ";", "$", "filterManager", "->", "attach", "(", "'phpDocumentor\\Descriptor\\MethodDescriptor'", ",", "$", "stripOnVisibility", ")", ";", "return", "$", "filterManager", ";", "}" ]
Attaches filters to the manager. @param Filter $filterManager @param Application $app @return Filter
[ "Attaches", "filters", "to", "the", "manager", "." ]
train
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Descriptor/ServiceProvider.php#L191-L212
heidelpay/PhpDoc
src/phpDocumentor/Descriptor/ServiceProvider.php
ServiceProvider.attachValidators
public function attachValidators(Validator $validator) { /** @var ClassMetadata $fileMetadata */ $fileMetadata = $validator->getMetadataFor('phpDocumentor\Descriptor\FileDescriptor'); /** @var ClassMetadata $constantMetadata */ $constantMetadata = $validator->getMetadataFor('phpDocumentor\Descriptor\ConstantDescriptor'); /** @var ClassMetadata $functionMetadata */ $functionMetadata = $validator->getMetadataFor('phpDocumentor\Descriptor\FunctionDescriptor'); /** @var ClassMetadata $classMetadata */ $classMetadata = $validator->getMetadataFor('phpDocumentor\Descriptor\ClassDescriptor'); /** @var ClassMetadata $interfaceMetadata */ $interfaceMetadata = $validator->getMetadataFor('phpDocumentor\Descriptor\InterfaceDescriptor'); /** @var ClassMetadata $traitMetadata */ $traitMetadata = $validator->getMetadataFor('phpDocumentor\Descriptor\TraitDescriptor'); /** @var ClassMetadata $propertyMetadata */ $propertyMetadata = $validator->getMetadataFor('phpDocumentor\Descriptor\PropertyDescriptor'); /** @var ClassMetadata $methodMetadata */ $methodMetadata = $validator->getMetadataFor('phpDocumentor\Descriptor\MethodDescriptor'); $fileMetadata->addPropertyConstraint('summary', new Assert\NotBlank(array('message' => 'PPC:ERR-50000'))); $classMetadata->addPropertyConstraint('summary', new Assert\NotBlank(array('message' => 'PPC:ERR-50005'))); $propertyMetadata->addConstraint(new phpDocAssert\Property\HasSummary()); $methodMetadata->addPropertyConstraint('summary', new Assert\NotBlank(array('message' => 'PPC:ERR-50008'))); $interfaceMetadata->addPropertyConstraint('summary', new Assert\NotBlank(array('message' => 'PPC:ERR-50009'))); $traitMetadata->addPropertyConstraint('summary', new Assert\NotBlank(array('message' => 'PPC:ERR-50010'))); $functionMetadata->addPropertyConstraint('summary', new Assert\NotBlank(array('message' => 'PPC:ERR-50011'))); $functionMetadata->addConstraint(new phpDocAssert\Functions\IsReturnTypeNotAnIdeDefault()); $methodMetadata->addConstraint(new phpDocAssert\Functions\IsReturnTypeNotAnIdeDefault()); $functionMetadata->addConstraint(new phpDocAssert\Functions\IsParamTypeNotAnIdeDefault()); $methodMetadata->addConstraint(new phpDocAssert\Functions\IsParamTypeNotAnIdeDefault()); $functionMetadata->addConstraint(new phpDocAssert\Functions\AreAllArgumentsValid()); $methodMetadata->addConstraint(new phpDocAssert\Functions\AreAllArgumentsValid()); $classMetadata->addConstraint(new phpDocAssert\Classes\HasSinglePackage()); $interfaceMetadata->addConstraint(new phpDocAssert\Classes\HasSinglePackage()); $traitMetadata->addConstraint(new phpDocAssert\Classes\HasSinglePackage()); $fileMetadata->addConstraint(new phpDocAssert\Classes\HasSinglePackage()); $classMetadata->addConstraint(new phpDocAssert\Classes\HasSingleSubpackage()); $interfaceMetadata->addConstraint(new phpDocAssert\Classes\HasSingleSubpackage()); $traitMetadata->addConstraint(new phpDocAssert\Classes\HasSingleSubpackage()); $fileMetadata->addConstraint(new phpDocAssert\Classes\HasSingleSubpackage()); $classMetadata->addConstraint(new phpDocAssert\Classes\HasPackageWithSubpackage()); $interfaceMetadata->addConstraint(new phpDocAssert\Classes\HasPackageWithSubpackage()); $traitMetadata->addConstraint(new phpDocAssert\Classes\HasPackageWithSubpackage()); $fileMetadata->addConstraint(new phpDocAssert\Classes\HasPackageWithSubpackage()); return $validator; }
php
public function attachValidators(Validator $validator) { /** @var ClassMetadata $fileMetadata */ $fileMetadata = $validator->getMetadataFor('phpDocumentor\Descriptor\FileDescriptor'); /** @var ClassMetadata $constantMetadata */ $constantMetadata = $validator->getMetadataFor('phpDocumentor\Descriptor\ConstantDescriptor'); /** @var ClassMetadata $functionMetadata */ $functionMetadata = $validator->getMetadataFor('phpDocumentor\Descriptor\FunctionDescriptor'); /** @var ClassMetadata $classMetadata */ $classMetadata = $validator->getMetadataFor('phpDocumentor\Descriptor\ClassDescriptor'); /** @var ClassMetadata $interfaceMetadata */ $interfaceMetadata = $validator->getMetadataFor('phpDocumentor\Descriptor\InterfaceDescriptor'); /** @var ClassMetadata $traitMetadata */ $traitMetadata = $validator->getMetadataFor('phpDocumentor\Descriptor\TraitDescriptor'); /** @var ClassMetadata $propertyMetadata */ $propertyMetadata = $validator->getMetadataFor('phpDocumentor\Descriptor\PropertyDescriptor'); /** @var ClassMetadata $methodMetadata */ $methodMetadata = $validator->getMetadataFor('phpDocumentor\Descriptor\MethodDescriptor'); $fileMetadata->addPropertyConstraint('summary', new Assert\NotBlank(array('message' => 'PPC:ERR-50000'))); $classMetadata->addPropertyConstraint('summary', new Assert\NotBlank(array('message' => 'PPC:ERR-50005'))); $propertyMetadata->addConstraint(new phpDocAssert\Property\HasSummary()); $methodMetadata->addPropertyConstraint('summary', new Assert\NotBlank(array('message' => 'PPC:ERR-50008'))); $interfaceMetadata->addPropertyConstraint('summary', new Assert\NotBlank(array('message' => 'PPC:ERR-50009'))); $traitMetadata->addPropertyConstraint('summary', new Assert\NotBlank(array('message' => 'PPC:ERR-50010'))); $functionMetadata->addPropertyConstraint('summary', new Assert\NotBlank(array('message' => 'PPC:ERR-50011'))); $functionMetadata->addConstraint(new phpDocAssert\Functions\IsReturnTypeNotAnIdeDefault()); $methodMetadata->addConstraint(new phpDocAssert\Functions\IsReturnTypeNotAnIdeDefault()); $functionMetadata->addConstraint(new phpDocAssert\Functions\IsParamTypeNotAnIdeDefault()); $methodMetadata->addConstraint(new phpDocAssert\Functions\IsParamTypeNotAnIdeDefault()); $functionMetadata->addConstraint(new phpDocAssert\Functions\AreAllArgumentsValid()); $methodMetadata->addConstraint(new phpDocAssert\Functions\AreAllArgumentsValid()); $classMetadata->addConstraint(new phpDocAssert\Classes\HasSinglePackage()); $interfaceMetadata->addConstraint(new phpDocAssert\Classes\HasSinglePackage()); $traitMetadata->addConstraint(new phpDocAssert\Classes\HasSinglePackage()); $fileMetadata->addConstraint(new phpDocAssert\Classes\HasSinglePackage()); $classMetadata->addConstraint(new phpDocAssert\Classes\HasSingleSubpackage()); $interfaceMetadata->addConstraint(new phpDocAssert\Classes\HasSingleSubpackage()); $traitMetadata->addConstraint(new phpDocAssert\Classes\HasSingleSubpackage()); $fileMetadata->addConstraint(new phpDocAssert\Classes\HasSingleSubpackage()); $classMetadata->addConstraint(new phpDocAssert\Classes\HasPackageWithSubpackage()); $interfaceMetadata->addConstraint(new phpDocAssert\Classes\HasPackageWithSubpackage()); $traitMetadata->addConstraint(new phpDocAssert\Classes\HasPackageWithSubpackage()); $fileMetadata->addConstraint(new phpDocAssert\Classes\HasPackageWithSubpackage()); return $validator; }
[ "public", "function", "attachValidators", "(", "Validator", "$", "validator", ")", "{", "/** @var ClassMetadata $fileMetadata */", "$", "fileMetadata", "=", "$", "validator", "->", "getMetadataFor", "(", "'phpDocumentor\\Descriptor\\FileDescriptor'", ")", ";", "/** @var ClassMetadata $constantMetadata */", "$", "constantMetadata", "=", "$", "validator", "->", "getMetadataFor", "(", "'phpDocumentor\\Descriptor\\ConstantDescriptor'", ")", ";", "/** @var ClassMetadata $functionMetadata */", "$", "functionMetadata", "=", "$", "validator", "->", "getMetadataFor", "(", "'phpDocumentor\\Descriptor\\FunctionDescriptor'", ")", ";", "/** @var ClassMetadata $classMetadata */", "$", "classMetadata", "=", "$", "validator", "->", "getMetadataFor", "(", "'phpDocumentor\\Descriptor\\ClassDescriptor'", ")", ";", "/** @var ClassMetadata $interfaceMetadata */", "$", "interfaceMetadata", "=", "$", "validator", "->", "getMetadataFor", "(", "'phpDocumentor\\Descriptor\\InterfaceDescriptor'", ")", ";", "/** @var ClassMetadata $traitMetadata */", "$", "traitMetadata", "=", "$", "validator", "->", "getMetadataFor", "(", "'phpDocumentor\\Descriptor\\TraitDescriptor'", ")", ";", "/** @var ClassMetadata $propertyMetadata */", "$", "propertyMetadata", "=", "$", "validator", "->", "getMetadataFor", "(", "'phpDocumentor\\Descriptor\\PropertyDescriptor'", ")", ";", "/** @var ClassMetadata $methodMetadata */", "$", "methodMetadata", "=", "$", "validator", "->", "getMetadataFor", "(", "'phpDocumentor\\Descriptor\\MethodDescriptor'", ")", ";", "$", "fileMetadata", "->", "addPropertyConstraint", "(", "'summary'", ",", "new", "Assert", "\\", "NotBlank", "(", "array", "(", "'message'", "=>", "'PPC:ERR-50000'", ")", ")", ")", ";", "$", "classMetadata", "->", "addPropertyConstraint", "(", "'summary'", ",", "new", "Assert", "\\", "NotBlank", "(", "array", "(", "'message'", "=>", "'PPC:ERR-50005'", ")", ")", ")", ";", "$", "propertyMetadata", "->", "addConstraint", "(", "new", "phpDocAssert", "\\", "Property", "\\", "HasSummary", "(", ")", ")", ";", "$", "methodMetadata", "->", "addPropertyConstraint", "(", "'summary'", ",", "new", "Assert", "\\", "NotBlank", "(", "array", "(", "'message'", "=>", "'PPC:ERR-50008'", ")", ")", ")", ";", "$", "interfaceMetadata", "->", "addPropertyConstraint", "(", "'summary'", ",", "new", "Assert", "\\", "NotBlank", "(", "array", "(", "'message'", "=>", "'PPC:ERR-50009'", ")", ")", ")", ";", "$", "traitMetadata", "->", "addPropertyConstraint", "(", "'summary'", ",", "new", "Assert", "\\", "NotBlank", "(", "array", "(", "'message'", "=>", "'PPC:ERR-50010'", ")", ")", ")", ";", "$", "functionMetadata", "->", "addPropertyConstraint", "(", "'summary'", ",", "new", "Assert", "\\", "NotBlank", "(", "array", "(", "'message'", "=>", "'PPC:ERR-50011'", ")", ")", ")", ";", "$", "functionMetadata", "->", "addConstraint", "(", "new", "phpDocAssert", "\\", "Functions", "\\", "IsReturnTypeNotAnIdeDefault", "(", ")", ")", ";", "$", "methodMetadata", "->", "addConstraint", "(", "new", "phpDocAssert", "\\", "Functions", "\\", "IsReturnTypeNotAnIdeDefault", "(", ")", ")", ";", "$", "functionMetadata", "->", "addConstraint", "(", "new", "phpDocAssert", "\\", "Functions", "\\", "IsParamTypeNotAnIdeDefault", "(", ")", ")", ";", "$", "methodMetadata", "->", "addConstraint", "(", "new", "phpDocAssert", "\\", "Functions", "\\", "IsParamTypeNotAnIdeDefault", "(", ")", ")", ";", "$", "functionMetadata", "->", "addConstraint", "(", "new", "phpDocAssert", "\\", "Functions", "\\", "AreAllArgumentsValid", "(", ")", ")", ";", "$", "methodMetadata", "->", "addConstraint", "(", "new", "phpDocAssert", "\\", "Functions", "\\", "AreAllArgumentsValid", "(", ")", ")", ";", "$", "classMetadata", "->", "addConstraint", "(", "new", "phpDocAssert", "\\", "Classes", "\\", "HasSinglePackage", "(", ")", ")", ";", "$", "interfaceMetadata", "->", "addConstraint", "(", "new", "phpDocAssert", "\\", "Classes", "\\", "HasSinglePackage", "(", ")", ")", ";", "$", "traitMetadata", "->", "addConstraint", "(", "new", "phpDocAssert", "\\", "Classes", "\\", "HasSinglePackage", "(", ")", ")", ";", "$", "fileMetadata", "->", "addConstraint", "(", "new", "phpDocAssert", "\\", "Classes", "\\", "HasSinglePackage", "(", ")", ")", ";", "$", "classMetadata", "->", "addConstraint", "(", "new", "phpDocAssert", "\\", "Classes", "\\", "HasSingleSubpackage", "(", ")", ")", ";", "$", "interfaceMetadata", "->", "addConstraint", "(", "new", "phpDocAssert", "\\", "Classes", "\\", "HasSingleSubpackage", "(", ")", ")", ";", "$", "traitMetadata", "->", "addConstraint", "(", "new", "phpDocAssert", "\\", "Classes", "\\", "HasSingleSubpackage", "(", ")", ")", ";", "$", "fileMetadata", "->", "addConstraint", "(", "new", "phpDocAssert", "\\", "Classes", "\\", "HasSingleSubpackage", "(", ")", ")", ";", "$", "classMetadata", "->", "addConstraint", "(", "new", "phpDocAssert", "\\", "Classes", "\\", "HasPackageWithSubpackage", "(", ")", ")", ";", "$", "interfaceMetadata", "->", "addConstraint", "(", "new", "phpDocAssert", "\\", "Classes", "\\", "HasPackageWithSubpackage", "(", ")", ")", ";", "$", "traitMetadata", "->", "addConstraint", "(", "new", "phpDocAssert", "\\", "Classes", "\\", "HasPackageWithSubpackage", "(", ")", ")", ";", "$", "fileMetadata", "->", "addConstraint", "(", "new", "phpDocAssert", "\\", "Classes", "\\", "HasPackageWithSubpackage", "(", ")", ")", ";", "return", "$", "validator", ";", "}" ]
Adds validators to check the Descriptors. @param Validator $validator @return Validator
[ "Adds", "validators", "to", "check", "the", "Descriptors", "." ]
train
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Descriptor/ServiceProvider.php#L221-L272
heidelpay/PhpDoc
src/phpDocumentor/Descriptor/ServiceProvider.php
ServiceProvider.addCache
protected function addCache(Application $app) { $app['descriptor.cache'] = $app->share( function () { $cache = new Filesystem(); $cache->setOptions( array( 'namespace' => 'phpdoc-cache', 'cache_dir' => sys_get_temp_dir(), ) ); $plugin = new SerializerPlugin(); if (extension_loaded('igbinary')) { $options = new PluginOptions(); $options->setSerializer('igbinary'); $plugin->setOptions($options); } $cache->addPlugin($plugin); return $cache; } ); }
php
protected function addCache(Application $app) { $app['descriptor.cache'] = $app->share( function () { $cache = new Filesystem(); $cache->setOptions( array( 'namespace' => 'phpdoc-cache', 'cache_dir' => sys_get_temp_dir(), ) ); $plugin = new SerializerPlugin(); if (extension_loaded('igbinary')) { $options = new PluginOptions(); $options->setSerializer('igbinary'); $plugin->setOptions($options); } $cache->addPlugin($plugin); return $cache; } ); }
[ "protected", "function", "addCache", "(", "Application", "$", "app", ")", "{", "$", "app", "[", "'descriptor.cache'", "]", "=", "$", "app", "->", "share", "(", "function", "(", ")", "{", "$", "cache", "=", "new", "Filesystem", "(", ")", ";", "$", "cache", "->", "setOptions", "(", "array", "(", "'namespace'", "=>", "'phpdoc-cache'", ",", "'cache_dir'", "=>", "sys_get_temp_dir", "(", ")", ",", ")", ")", ";", "$", "plugin", "=", "new", "SerializerPlugin", "(", ")", ";", "if", "(", "extension_loaded", "(", "'igbinary'", ")", ")", "{", "$", "options", "=", "new", "PluginOptions", "(", ")", ";", "$", "options", "->", "setSerializer", "(", "'igbinary'", ")", ";", "$", "plugin", "->", "setOptions", "(", "$", "options", ")", ";", "}", "$", "cache", "->", "addPlugin", "(", "$", "plugin", ")", ";", "return", "$", "cache", ";", "}", ")", ";", "}" ]
Adds the caching mechanism to the dependency injection container with key 'descriptor.cache'. @param Application $app @return void
[ "Adds", "the", "caching", "mechanism", "to", "the", "dependency", "injection", "container", "with", "key", "descriptor", ".", "cache", "." ]
train
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Descriptor/ServiceProvider.php#L281-L306
heidelpay/PhpDoc
src/phpDocumentor/Descriptor/ServiceProvider.php
ServiceProvider.addBuilder
protected function addBuilder(Application $app) { if (extension_loaded('igbinary')) { $app['descriptor.builder.serializer'] = 'IgBinary'; } else { $app['descriptor.builder.serializer'] = 'PhpSerialize'; } $app['descriptor.builder'] = $app->share( function ($container) { $builder = new ProjectDescriptorBuilder( $container['descriptor.builder.assembler.factory'], $container['descriptor.filter'], $container['validator'] ); $builder->setTranslator($container['translator']); return $builder; } ); }
php
protected function addBuilder(Application $app) { if (extension_loaded('igbinary')) { $app['descriptor.builder.serializer'] = 'IgBinary'; } else { $app['descriptor.builder.serializer'] = 'PhpSerialize'; } $app['descriptor.builder'] = $app->share( function ($container) { $builder = new ProjectDescriptorBuilder( $container['descriptor.builder.assembler.factory'], $container['descriptor.filter'], $container['validator'] ); $builder->setTranslator($container['translator']); return $builder; } ); }
[ "protected", "function", "addBuilder", "(", "Application", "$", "app", ")", "{", "if", "(", "extension_loaded", "(", "'igbinary'", ")", ")", "{", "$", "app", "[", "'descriptor.builder.serializer'", "]", "=", "'IgBinary'", ";", "}", "else", "{", "$", "app", "[", "'descriptor.builder.serializer'", "]", "=", "'PhpSerialize'", ";", "}", "$", "app", "[", "'descriptor.builder'", "]", "=", "$", "app", "->", "share", "(", "function", "(", "$", "container", ")", "{", "$", "builder", "=", "new", "ProjectDescriptorBuilder", "(", "$", "container", "[", "'descriptor.builder.assembler.factory'", "]", ",", "$", "container", "[", "'descriptor.filter'", "]", ",", "$", "container", "[", "'validator'", "]", ")", ";", "$", "builder", "->", "setTranslator", "(", "$", "container", "[", "'translator'", "]", ")", ";", "return", "$", "builder", ";", "}", ")", ";", "}" ]
Adds the Building mechanism using the key 'descriptor.builder'. Please note that the type of serializer can be configured using the parameter 'descriptor.builder.serializer'; it accepts any parameter that Zend\Serializer supports. @param Application $app @return void
[ "Adds", "the", "Building", "mechanism", "using", "the", "key", "descriptor", ".", "builder", "." ]
train
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Descriptor/ServiceProvider.php#L318-L338
heidelpay/PhpDoc
src/phpDocumentor/Descriptor/ServiceProvider.php
ServiceProvider.addAssemblers
protected function addAssemblers(Application $app) { $app['descriptor.builder.assembler.factory'] = $app->share( function () { return new AssemblerFactory(); } ); $provider = $this; $app['descriptor.builder.assembler.factory'] = $app->share( $app->extend( 'descriptor.builder.assembler.factory', function ($factory) use ($provider, $app) { return $provider->attachAssemblersToFactory($factory, $app); } ) ); }
php
protected function addAssemblers(Application $app) { $app['descriptor.builder.assembler.factory'] = $app->share( function () { return new AssemblerFactory(); } ); $provider = $this; $app['descriptor.builder.assembler.factory'] = $app->share( $app->extend( 'descriptor.builder.assembler.factory', function ($factory) use ($provider, $app) { return $provider->attachAssemblersToFactory($factory, $app); } ) ); }
[ "protected", "function", "addAssemblers", "(", "Application", "$", "app", ")", "{", "$", "app", "[", "'descriptor.builder.assembler.factory'", "]", "=", "$", "app", "->", "share", "(", "function", "(", ")", "{", "return", "new", "AssemblerFactory", "(", ")", ";", "}", ")", ";", "$", "provider", "=", "$", "this", ";", "$", "app", "[", "'descriptor.builder.assembler.factory'", "]", "=", "$", "app", "->", "share", "(", "$", "app", "->", "extend", "(", "'descriptor.builder.assembler.factory'", ",", "function", "(", "$", "factory", ")", "use", "(", "$", "provider", ",", "$", "app", ")", "{", "return", "$", "provider", "->", "attachAssemblersToFactory", "(", "$", "factory", ",", "$", "app", ")", ";", "}", ")", ")", ";", "}" ]
Adds the assembler factory and attaches the basic assemblers with key 'descriptor.builder.assembler.factory'. @param Application $app @return void
[ "Adds", "the", "assembler", "factory", "and", "attaches", "the", "basic", "assemblers", "with", "key", "descriptor", ".", "builder", ".", "assembler", ".", "factory", "." ]
train
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Descriptor/ServiceProvider.php#L347-L364
heidelpay/PhpDoc
src/phpDocumentor/Descriptor/ServiceProvider.php
ServiceProvider.addValidators
protected function addValidators(Application $app) { if (!isset($app['validator'])) { throw new Exception\MissingDependencyException('The validator manager is missing'); } $provider = $this; $app['validator'] = $app->share( $app->extend( 'validator', function ($validatorManager) use ($provider) { return $provider->attachValidators($validatorManager); } ) ); }
php
protected function addValidators(Application $app) { if (!isset($app['validator'])) { throw new Exception\MissingDependencyException('The validator manager is missing'); } $provider = $this; $app['validator'] = $app->share( $app->extend( 'validator', function ($validatorManager) use ($provider) { return $provider->attachValidators($validatorManager); } ) ); }
[ "protected", "function", "addValidators", "(", "Application", "$", "app", ")", "{", "if", "(", "!", "isset", "(", "$", "app", "[", "'validator'", "]", ")", ")", "{", "throw", "new", "Exception", "\\", "MissingDependencyException", "(", "'The validator manager is missing'", ")", ";", "}", "$", "provider", "=", "$", "this", ";", "$", "app", "[", "'validator'", "]", "=", "$", "app", "->", "share", "(", "$", "app", "->", "extend", "(", "'validator'", ",", "function", "(", "$", "validatorManager", ")", "use", "(", "$", "provider", ")", "{", "return", "$", "provider", "->", "attachValidators", "(", "$", "validatorManager", ")", ";", "}", ")", ")", ";", "}" ]
Adds validators for the descriptors to the validator manager. @param Application $app @throws Exception\MissingDependencyException if the validator could not be found. @return void
[ "Adds", "validators", "for", "the", "descriptors", "to", "the", "validator", "manager", "." ]
train
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Descriptor/ServiceProvider.php#L394-L409
oroinc/OroLayoutComponent
ImportLayoutManipulator.php
ImportLayoutManipulator.add
public function add( $id, $parentId, $blockType, array $options = [], $siblingId = null, $prepend = null ) { $this->addAdditionalBlockPrefixOption($id, $options); $this ->replaceRoot($parentId) ->replaceRoot($siblingId); $this ->replaceNamespace($id) ->replaceNamespace($parentId) ->replaceNamespace($siblingId); $this->layoutManipulator->add($id, $parentId, $blockType, $options, $siblingId, $prepend); return $this; }
php
public function add( $id, $parentId, $blockType, array $options = [], $siblingId = null, $prepend = null ) { $this->addAdditionalBlockPrefixOption($id, $options); $this ->replaceRoot($parentId) ->replaceRoot($siblingId); $this ->replaceNamespace($id) ->replaceNamespace($parentId) ->replaceNamespace($siblingId); $this->layoutManipulator->add($id, $parentId, $blockType, $options, $siblingId, $prepend); return $this; }
[ "public", "function", "add", "(", "$", "id", ",", "$", "parentId", ",", "$", "blockType", ",", "array", "$", "options", "=", "[", "]", ",", "$", "siblingId", "=", "null", ",", "$", "prepend", "=", "null", ")", "{", "$", "this", "->", "addAdditionalBlockPrefixOption", "(", "$", "id", ",", "$", "options", ")", ";", "$", "this", "->", "replaceRoot", "(", "$", "parentId", ")", "->", "replaceRoot", "(", "$", "siblingId", ")", ";", "$", "this", "->", "replaceNamespace", "(", "$", "id", ")", "->", "replaceNamespace", "(", "$", "parentId", ")", "->", "replaceNamespace", "(", "$", "siblingId", ")", ";", "$", "this", "->", "layoutManipulator", "->", "add", "(", "$", "id", ",", "$", "parentId", ",", "$", "blockType", ",", "$", "options", ",", "$", "siblingId", ",", "$", "prepend", ")", ";", "return", "$", "this", ";", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/ImportLayoutManipulator.php#L42-L64
oroinc/OroLayoutComponent
ImportLayoutManipulator.php
ImportLayoutManipulator.remove
public function remove($id) { $this->replaceRoot($id); $this->replaceNamespace($id); $this->layoutManipulator->remove($id); return $this; }
php
public function remove($id) { $this->replaceRoot($id); $this->replaceNamespace($id); $this->layoutManipulator->remove($id); return $this; }
[ "public", "function", "remove", "(", "$", "id", ")", "{", "$", "this", "->", "replaceRoot", "(", "$", "id", ")", ";", "$", "this", "->", "replaceNamespace", "(", "$", "id", ")", ";", "$", "this", "->", "layoutManipulator", "->", "remove", "(", "$", "id", ")", ";", "return", "$", "this", ";", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/ImportLayoutManipulator.php#L69-L77
oroinc/OroLayoutComponent
ImportLayoutManipulator.php
ImportLayoutManipulator.move
public function move($id, $parentId = null, $siblingId = null, $prepend = null) { $this ->replaceRoot($id) ->replaceRoot($parentId) ->replaceRoot($siblingId); $this ->replaceNamespace($id) ->replaceNamespace($parentId) ->replaceNamespace($siblingId); $this->layoutManipulator->move($id, $parentId, $siblingId, $prepend); return $this; }
php
public function move($id, $parentId = null, $siblingId = null, $prepend = null) { $this ->replaceRoot($id) ->replaceRoot($parentId) ->replaceRoot($siblingId); $this ->replaceNamespace($id) ->replaceNamespace($parentId) ->replaceNamespace($siblingId); $this->layoutManipulator->move($id, $parentId, $siblingId, $prepend); return $this; }
[ "public", "function", "move", "(", "$", "id", ",", "$", "parentId", "=", "null", ",", "$", "siblingId", "=", "null", ",", "$", "prepend", "=", "null", ")", "{", "$", "this", "->", "replaceRoot", "(", "$", "id", ")", "->", "replaceRoot", "(", "$", "parentId", ")", "->", "replaceRoot", "(", "$", "siblingId", ")", ";", "$", "this", "->", "replaceNamespace", "(", "$", "id", ")", "->", "replaceNamespace", "(", "$", "parentId", ")", "->", "replaceNamespace", "(", "$", "siblingId", ")", ";", "$", "this", "->", "layoutManipulator", "->", "move", "(", "$", "id", ",", "$", "parentId", ",", "$", "siblingId", ",", "$", "prepend", ")", ";", "return", "$", "this", ";", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/ImportLayoutManipulator.php#L82-L96
oroinc/OroLayoutComponent
ImportLayoutManipulator.php
ImportLayoutManipulator.addAlias
public function addAlias($alias, $id) { $this->replaceRoot($id); $this ->replaceNamespace($alias) ->replaceNamespace($id); $this->layoutManipulator->addAlias($alias, $id); return $this; }
php
public function addAlias($alias, $id) { $this->replaceRoot($id); $this ->replaceNamespace($alias) ->replaceNamespace($id); $this->layoutManipulator->addAlias($alias, $id); return $this; }
[ "public", "function", "addAlias", "(", "$", "alias", ",", "$", "id", ")", "{", "$", "this", "->", "replaceRoot", "(", "$", "id", ")", ";", "$", "this", "->", "replaceNamespace", "(", "$", "alias", ")", "->", "replaceNamespace", "(", "$", "id", ")", ";", "$", "this", "->", "layoutManipulator", "->", "addAlias", "(", "$", "alias", ",", "$", "id", ")", ";", "return", "$", "this", ";", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/ImportLayoutManipulator.php#L101-L111
oroinc/OroLayoutComponent
ImportLayoutManipulator.php
ImportLayoutManipulator.removeAlias
public function removeAlias($alias) { $this->replaceNamespace($alias); $this->layoutManipulator->removeAlias($alias); return $this; }
php
public function removeAlias($alias) { $this->replaceNamespace($alias); $this->layoutManipulator->removeAlias($alias); return $this; }
[ "public", "function", "removeAlias", "(", "$", "alias", ")", "{", "$", "this", "->", "replaceNamespace", "(", "$", "alias", ")", ";", "$", "this", "->", "layoutManipulator", "->", "removeAlias", "(", "$", "alias", ")", ";", "return", "$", "this", ";", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/ImportLayoutManipulator.php#L116-L123
oroinc/OroLayoutComponent
ImportLayoutManipulator.php
ImportLayoutManipulator.setOption
public function setOption($id, $optionName, $optionValue) { $this->replaceRoot($id); $this->replaceNamespace($id); $this->layoutManipulator->setOption($id, $optionName, $optionValue); return $this; }
php
public function setOption($id, $optionName, $optionValue) { $this->replaceRoot($id); $this->replaceNamespace($id); $this->layoutManipulator->setOption($id, $optionName, $optionValue); return $this; }
[ "public", "function", "setOption", "(", "$", "id", ",", "$", "optionName", ",", "$", "optionValue", ")", "{", "$", "this", "->", "replaceRoot", "(", "$", "id", ")", ";", "$", "this", "->", "replaceNamespace", "(", "$", "id", ")", ";", "$", "this", "->", "layoutManipulator", "->", "setOption", "(", "$", "id", ",", "$", "optionName", ",", "$", "optionValue", ")", ";", "return", "$", "this", ";", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/ImportLayoutManipulator.php#L128-L136
oroinc/OroLayoutComponent
ImportLayoutManipulator.php
ImportLayoutManipulator.appendOption
public function appendOption($id, $optionName, $optionValue) { $this->replaceRoot($id); $this->replaceNamespace($id); $this->layoutManipulator->appendOption($id, $optionName, $optionValue); return $this; }
php
public function appendOption($id, $optionName, $optionValue) { $this->replaceRoot($id); $this->replaceNamespace($id); $this->layoutManipulator->appendOption($id, $optionName, $optionValue); return $this; }
[ "public", "function", "appendOption", "(", "$", "id", ",", "$", "optionName", ",", "$", "optionValue", ")", "{", "$", "this", "->", "replaceRoot", "(", "$", "id", ")", ";", "$", "this", "->", "replaceNamespace", "(", "$", "id", ")", ";", "$", "this", "->", "layoutManipulator", "->", "appendOption", "(", "$", "id", ",", "$", "optionName", ",", "$", "optionValue", ")", ";", "return", "$", "this", ";", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/ImportLayoutManipulator.php#L141-L149