本文整理汇总了PHP中Type::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Type::get方法的具体用法?PHP Type::get怎么用?PHP Type::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Type
的用法示例。
在下文中一共展示了Type::get方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createTable
private static function createTable($type)
{
$class = new ReflectionClass($type);
$columns = $class->getStaticPropertyValue('columns', array());
$columns['id'] = 'identifier';
$declarations = "";
foreach ($columns as $name => $typeName) {
$declarations .= "`{$name}` " . Type::get($typeName)->mySqlName() . ", ";
}
$query = "CREATE TABLE `" . self::tableName($type) . "` (";
$query .= $declarations;
$query .= "PRIMARY KEY (`id`)";
//// TODO: Put foreign key constraints back when creation of tables can have topological order imposed.
//if ($type != __CLASS__)
// $query .= ", FOREIGN KEY (`id`) REFERENCES `" . self::tableName($class->getParentClass()->getName()) . "` (`id`) ON DELETE CASCADE";
$query .= ") engine=" . Options::dbEngine() . ";";
Database::query($query, "{$type} table");
}
示例2: analyze
/**
* @param array $parametersA
* @param array $parametersB
* @return array
*/
public static function analyze(array $parametersA, array $parametersB)
{
$changes = ['parameter_added' => false, 'parameter_removed' => false, 'parameter_renamed' => false, 'parameter_typing_added' => false, 'parameter_typing_removed' => false, 'parameter_default_added' => false, 'parameter_default_removed' => false, 'parameter_default_value_changed' => false];
$lengthA = count($parametersA);
$lengthB = count($parametersB);
// TODO(tom@tomrochette.com): This is only true if newer params do not have defaults
if ($lengthA < $lengthB) {
$changes['parameter_added'] = true;
} elseif ($lengthA > $lengthB) {
$changes['parameter_removed'] = true;
}
$iterations = min($lengthA, $lengthB);
for ($i = 0; $i < $iterations; ++$i) {
// Name checking
if ($parametersA[$i]->name !== $parametersB[$i]->name) {
$changes['parameter_renamed'] = true;
}
// Type checking
if (Type::get($parametersA[$i]->type) !== Type::get($parametersB[$i]->type)) {
// if ($paramsA[$i]->default !== null && $paramsB[$i]->default !== null) {
// $changes['parameter_default_value_changed'] = true;
if ($parametersA[$i]->type !== null) {
$changes['parameter_typing_removed'] = true;
}
if ($parametersB[$i]->type !== null) {
$changes['parameter_typing_added'] = true;
}
}
// Default checking
if ($parametersA[$i]->default === null && $parametersB[$i]->default === null) {
// Do nothing
} elseif ($parametersA[$i]->default !== null && $parametersB[$i]->default === null) {
$changes['parameter_default_removed'] = true;
} elseif ($parametersA[$i]->default === null && $parametersB[$i]->default !== null) {
$changes['parameter_default_added'] = true;
// TODO(tom@tomrochette.com): Not all nodes have a value property
} elseif (!Node::isEqual($parametersA[$i]->default, $parametersB[$i]->default)) {
$changes['parameter_default_value_changed'] = true;
}
}
return $changes;
}
示例3: call
public static function call()
{
$task = $_POST['task'];
if ($task == 'getContent' && isset($_POST['title'])) {
include_once 'Content.php';
Content::getFromTitle();
} else {
if ($task == 'getContent') {
include_once 'Content.php';
Content::get();
} else {
if ($task == 'addContent') {
include_once 'Content.php';
Content::add();
} else {
if ($task == 'editContent') {
include_once 'Content.php';
Content::edit();
} else {
if ($task == 'deleteContent') {
include_once 'Content.php';
Content::remove();
} else {
if ($task == 'getType') {
include_once 'Type.php';
Type::get();
} else {
if ($task == 'addType') {
include_once 'Type.php';
Type::add();
} else {
if ($task == 'editType') {
include_once 'Type.php';
Type::edit();
} else {
if ($task == 'deleteType') {
include_once 'Type.php';
Type::remove();
} else {
if ($task == 'getContentOnUser') {
include_once 'ContentOnUser.php';
ContentOnUser::get();
} else {
if ($task == 'addContentToUser') {
include_once 'ContentOnUser.php';
ContentOnUser::add();
} else {
if ($task == 'editContentOnUser') {
include_once 'ContentOnUser.php';
ContentOnUser::edit();
} else {
if ($task == 'removeContentFromUser') {
include_once 'ContentOnUser.php';
ContentOnUser::remove();
} else {
if ($task == 'useContentOnUser') {
include_once 'ContentOnUser.php';
ContentOnUser::useContentOnUser();
} else {
if ($task == 'getUser') {
include_once 'User.php';
User::get();
} else {
echo "Task not recognized.<br>";
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}