本文整理汇总了PHP中Annotation类的典型用法代码示例。如果您正苦于以下问题:PHP Annotation类的具体用法?PHP Annotation怎么用?PHP Annotation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Annotation类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: index
function index()
{
$url = $this->url;
$webpage = $this->webpage->create($url);
$tutor = $webpage->get_tutor();
$annotation = new Annotation(1017);
$user = $annotation->get_user();
$unread_count = $user->get_unread_notification_count();
$this->unit->run($unread_count, 'is_int', '先看一下user的未讀通知有幾封');
$tutor->setup_recommend($annotation);
$recommend = $annotation->get_recommend();
$this->unit->run($recommend->get_id(), 'is_int', '有取得建議');
$recommend_annotation = $recommend->get_recommend_by();
$this->unit->run($recommend_annotation, NULL, '沒有推薦標註');
$tips = $recommend->get_tips_text_array();
$this->unit->run_false(count($tips), 0, '有建議');
//------------------------------------------------
$recommend_annotation = new Annotation(783);
$recommend_annotation->set_score(0, 3);
$recommend_annotation->update();
$scope = new Annotation_scope(129);
$recommend_scope = new Annotation_scope_collection();
$recommend_scope->add_scope($scope);
$annotation->set_recommend_scopes($recommend_scope);
$tutor->setup_recommend($annotation);
$recommend->reload();
$recommend_annotation = $recommend->get_recommend_by();
$this->unit->run($recommend_annotation->get_id(), 783, '有找到推薦標註');
$this->unit->run($user->get_unread_notification_count(TRUE), $unread_count + 2, '因為新增了兩次推薦,所以應該有兩封通知?');
// $this->unit->run($test_result
// , $expected_result
// , $test_name);
//context_complete();
unit_test_report($this, __METHOD__);
}
开发者ID:119155012,项目名称:kals,代码行数:35,代码来源:ut_tutor.php
示例2: throwsReflectionExceptionForMethodCallsWithoutGetOrIsOnSpecialValue
/**
* @test
*/
public function throwsReflectionExceptionForMethodCallsWithoutGetOrIsOnSpecialValue()
{
expect(function () {
$annotation = new Annotation('Example', 'someFunction()', ['__value' => 'true']);
$annotation->invalid();
})->throws(\ReflectionException::class)->withMessage('The value with name "invalid" for annotation @Example at someFunction() does not exist');
}
开发者ID:stubbles,项目名称:stubbles-reflect,代码行数:10,代码来源:AnnotationTest.php
示例3: generate
/**
* Generates the actual interfaces
*/
public function generate()
{
$interfacesData = json_decode($this->json, true);
foreach ($interfacesData as $interface) {
$filename = $interface['name'] . '.java';
$interfaceObject = new JAVAInterfaceObject();
$interfaceObject->setName($interface['name']);
foreach ($interface['methods'] as $method) {
$methodObject = new JAVAMethod();
$methodObject->setName($method['name']);
$methodObject->setReturnValue($method['returnType']);
$methodObject->setScope($method['scope']);
$methodObject->setComment($method['comment']);
foreach ($method['parameters'] as $parameter) {
$parameterObject = new Parameter();
$parameterObject->setName($parameter['name']);
$parameterObject->setType($parameter['type']);
$methodObject->addParameter($parameterObject);
}
foreach ($method['annotations'] as $annotation) {
$annotationObject = new Annotation();
$annotationObject->setName($annotation['name']);
$annotationObject->setValue($annotation['value']);
$annotationObject->setInterpreter('@');
$methodObject->addAnnotation($annotationObject);
}
$interfaceObject->addMethod($methodObject);
}
file_put_contents($this->folder . DIRECTORY_SEPARATOR . $filename, $interfaceObject->toString());
}
}
开发者ID:herrwalter,项目名称:InterfaceGenerator,代码行数:34,代码来源:JAVAGenerator.php
示例4: parse
public function parse($text)
{
$ret = new Collection();
if (preg_match_all('/@([^@\\n\\r\\t]*)/', $text, $globalMatches) > 0) {
foreach ($globalMatches[1] as $annotationText) {
preg_match('/([a-zA-Z0-9]+)/', $annotationText, $localMatches);
if (in_array($localMatches[1], self::$ignoredAnnotations)) {
continue;
}
$annotation = new Annotation($localMatches[1]);
$optsStart = strpos($annotationText, '(');
if ($optsStart !== false) {
$optsEnd = strrpos($annotationText, ')');
$optsLength = $optsEnd - $optsStart - 1;
$opts = trim(substr($annotationText, $optsStart + 1, $optsLength));
foreach ($this->_parseOptions($opts) as $key => $values) {
foreach ($values as $value) {
$annotation->addOption($key, $value);
}
}
}
$ret->add($annotation);
}
}
return $ret;
}
开发者ID:im286er,项目名称:Ding,代码行数:26,代码来源:Parser.php
示例5: get_feature
protected function get_feature(Annotation $annotation)
{
//if ($annotation->get_id() == 2363)
// test_msg('Language_variable_consensus', array($annotation->get_id(), $annotation->get_consensus_count()));
$feature = $annotation->get_consensus_count();
return $feature;
}
开发者ID:119155012,项目名称:kals,代码行数:7,代码来源:Language_variable_consensus.php
示例6: annotationDeleted
/**
* @param Annotation $annotation
*/
protected function annotationDeleted(Annotation $annotation)
{
$children = $annotation->getChildren();
foreach ($children as $child) {
$child->setStatus($annotation->getStatus());
$child->save();
}
}
开发者ID:richhl,项目名称:kalturaCE,代码行数:11,代码来源:kAnnotationManager.php
示例7: annotations_from_hits
function annotations_from_hits($uri, $page, $hits)
{
$EXTEND_BY = 3;
$annotations = array();
foreach ($hits as $hit) {
print_r($hit);
// what word does hit start in?
$starting_word = $page->characters[$hit->start];
// offset with respect to the starting word
$starting_position = $hit->start - $page->word_start[$starting_word] - 1;
// what word does hit end in?
$ending_word = $page->characters[$hit->end];
// offset with respect to the ending word
$ending_position = $hit->end - $page->word_start[$ending_word];
echo $starting_word . ' ' . $starting_position . "\n";
echo $ending_word . ' ' . $ending_position . "\n";
$prefix_words = array();
if ($starting_word > 0) {
$prefix_pos = max(0, $starting_word - $EXTEND_BY);
$prefix_count = $starting_word - $prefix_pos;
$prefix_words = array_slice($page->words, $prefix_pos, $prefix_count);
$prefix = substr($page->words[$starting_word], 0, $starting_position);
if ($prefix != '') {
$prefix_words[] = $prefix;
}
}
$num_words = count($page->words);
$suffix_words = array();
if ($ending_word < $num_words - 1) {
$suffix_pos = min($ending_word + $EXTEND_BY, $num_words);
$suffix_count = $suffix_pos - $ending_word;
$suffix_words = array_slice($page->words, $ending_word + 1, $suffix_count);
$suffix = substr($page->words[$ending_word], $ending_position);
if ($suffix != '') {
array_unshift($suffix_words, $suffix);
}
}
$a = new Annotation($uri);
$a->add_permissions("acct:[email protected]");
$a->add_text_quote(str_replace(" ", "\n", $hit->mid), join("\n", $prefix_words), join("\n", $suffix_words));
// Not sure that we need this, and doesn't seme to be working
/*
$a->add_range(
"//div[@id='" . ($starting_word + 1) . "']",
$starting_position,
"//div[@id='" . ($ending_word + 1) . "']",
$ending_position
);
*/
$a->add_tag($hit->type);
if (isset($hit->text)) {
$a->set_text($hit->text);
}
$annotations[] = $a;
}
return $annotations;
}
开发者ID:rdmpage,项目名称:biostor-annotations,代码行数:57,代码来源:annotations.php
示例8: process
public static function process(Annotation $a)
{
$classes = $a->getValues();
foreach ($classes as $class) {
$classFile = "../{$class}.class.php";
if (file_exists($classFile)) {
include_once $classFile;
} else {
throw new Exception("{$classFile} DO NOT EXIST");
}
}
}
开发者ID:Jupaba,项目名称:ccientifica,代码行数:12,代码来源:Annotation.class.php
示例9: punish_comments
function punish_comments($hours = 6)
{
global $globals, $db;
$log = new Annotation('punish-comment');
if ($log->read() && $log->time > time() - 3600 * $hours) {
echo "Comments already verified at: " . get_date_time($log->time) . "\n";
return false;
}
if ($globals['min_karma_for_comments'] > 0) {
$min_karma = $globals['min_karma_for_comments'];
} else {
$min_karma = 4.5;
}
$votes_from = time() - $hours * 3600;
// 'date_sub(now(), interval 6 hour)';
$comments_from = time() - 2 * $hours * 3600;
//'date_sub(now(), interval 12 hour)';
echo "Starting karma_comments...\n";
$users = "SELECT SQL_NO_CACHE distinct comment_user_id as user_id from comments, users where comment_date > from_unixtime({$comments_from}) and comment_karma < -50 and comment_user_id = user_id and user_level != 'disabled' and user_karma >= {$min_karma}";
$result = $db->get_results($users);
$log->store();
if (!$result) {
return;
}
foreach ($result as $dbuser) {
$user = new User();
$user->id = $dbuser->user_id;
$user->read();
printf("%07d %s\n", $user->id, $user->username);
$punish = 0;
$comment_votes_count = (int) $db->get_var("SELECT SQL_NO_CACHE count(*) from votes, comments where comment_user_id = {$user->id} and comment_date > from_unixtime({$comments_from}) and vote_type='comments' and vote_link_id = comment_id and vote_date > from_unixtime({$votes_from}) and vote_user_id != {$user->id}");
if ($comment_votes_count > 5) {
$votes_karma = (int) $db->get_var("SELECT SQL_NO_CACHE sum(vote_value) from votes, comments where comment_user_id = {$user->id} and comment_date > from_unixtime({$comments_from}) and vote_type='comments' and vote_link_id = comment_id and vote_date > from_unixtime({$votes_from}) and vote_user_id != {$user->id}");
if ($votes_karma < 50) {
$distinct_votes_count = (int) $db->get_var("SELECT SQL_NO_CACHE count(distinct comment_id) from votes, comments where comment_user_id = {$user->id} and comment_date > from_unixtime({$comments_from}) and vote_type='comments' and vote_link_id = comment_id and vote_date > from_unixtime({$votes_from}) and vote_user_id != {$user->id}");
$comments_count = (int) $db->get_var("SELECT SQL_NO_CACHE count(*) from comments where comment_user_id = {$user->id} and comment_date > from_unixtime({$comments_from})");
$comment_coeff = min($comments_count / 10, 1) * min($distinct_votes_count / ($comments_count * 0.75), 1);
$punish = max(-2, round($votes_karma * $comment_coeff * 1 / 1000, 2));
}
}
if ($punish < -0.1) {
echo "comments: {$comments_count} votes distinct: {$distinct_votes_count} karma: {$votes_karma} coef: {$comment_coeff} -> {$punish}\n";
$user->karma += $punish;
//$user->store();
$annotation = new Annotation("karma-{$user->id}");
//$annotation->append(_('Penalización por comentarios').": $punish, nuevo karma: $user->karma\n");
echo _('Penalización por comentarios') . ": {$punish}, nuevo karma: {$user->karma}\n";
$log->append(_('Penalización') . " {$user->username}: {$punish}, nuevo karma: {$user->karma}\n");
}
$db->barrier();
}
}
开发者ID:brainsqueezer,项目名称:fffff,代码行数:52,代码来源:discard3.php
示例10: do_load
function do_load() {
global $db, $current_user;
$annotation = new Annotation('ec2-autoscaler');
if (!$annotation->read()) {
return _('no hay estadísticas disponibles');
}
$group = unserialize($annotation->text);
$str = "web instances: $group->instances, ";
$str .= "cpu average load: ".round($group->load, 2) . "%, ";
$str .= "cpu max average ($group->measures periods): ".round($group->load_max, 2)."%, ";
$str .= "stored at: ". get_date_time($annotation->time);
return $str;
}
开发者ID:rasomu,项目名称:chuza,代码行数:13,代码来源:sneaker-stats.php
示例11: do_load
function do_load()
{
global $db, $current_user;
$annotation = new Annotation('ec2_watch');
if (!$annotation->read()) {
return _('no hay estadísticas disponibles');
}
$group = json_decode($annotation->text);
$str = "web instances: {$group->instances}, ";
$str .= "cpu average load: " . round($group->avg_load, 2) . "%, ";
$str .= "last action: {$group->action} ";
$str .= "last change: " . get_date_time($group->changed_ts) . " ";
$str .= "stored at: " . get_date_time($annotation->time);
return $str;
}
开发者ID:brainsqueezer,项目名称:fffff,代码行数:15,代码来源:sneaker-stats.php
示例12: getKeyValuePropertiesByEntity
/**
* This functions builds an array (key\value) with entity data, to later insert on the db
*
* @param Entity $entity
*
* @return array
*/
private function getKeyValuePropertiesByEntity(Entity $entity)
{
$properties = array_keys($entity->getProperties());
$keyValueProperties = array();
foreach ($properties as $property) {
$method = $this->getterMethodToGetPropertyValue($property);
$propertyValue = $entity->{$method}();
if (is_null($propertyValue)) {
continue;
}
$annotations = $this->annotation->getAnnotationsByProperty($property, $entity);
$propertyKey = $this->getValueOfAnnotation($annotations, self::PROPERTY_ANNOTATION);
$keyValueProperties[$propertyKey] = $propertyValue;
}
return $keyValueProperties;
}
开发者ID:karlozz157,项目名称:orm,代码行数:23,代码来源:UnitOfWork.php
示例13: discover
/**
* Discovers all the annotations of a given class file
*
* @param string $class a class file
* @return array
*/
public static function discover($class)
{
try {
if (!file_exists($class)) {
throw new Exception($class . " does not exist");
}
$text = file($class, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
$annotations = array();
$currentAnnotations = array();
foreach ($text as $key => $line) {
if (strpos($line, "* @annotation") !== false) {
$currentAnnotations[] = trim(str_replace("* @annotation", "", $line));
} else {
$functionName = "";
if (count($currentAnnotations) > 0 && Annotation::discoverFunctionName($line, $functionName)) {
$annotations[$functionName] = $currentAnnotations;
$currentAnnotations = array();
}
unset($text[$key]);
}
}
return $annotations;
} catch (Exception $e) {
Functions::dump($e->getMessage());
return NULL;
}
}
开发者ID:Romayne,项目名称:MVC-MVVM-Annotations-Framework,代码行数:33,代码来源:Annotation.class.php
示例14: calculate_type
public static function calculate_type($reflection)
{
$annotations = Annotation::parse($reflection);
if (isset($annotations['type'])) {
return $annotations['type'];
} else {
$defaults = $reflection->getDeclaringClass()->getDefaultProperties();
$default_value = $defaults[$reflection->getName()];
if (is_null($default_value)) {
return 'null';
}
if (is_string($default_value)) {
return 'string';
} else {
if (is_integer($default_value)) {
return 'integer';
} else {
if (is_float($default_value)) {
return 'float';
} else {
if (is_bool($default_value)) {
return 'boolean';
} else {
if (is_array($default_value)) {
return 'array';
}
}
}
}
}
}
}
开发者ID:jaz303,项目名称:spitfire,代码行数:32,代码来源:Utilities.php
示例15: getTable
/**
* Ler um model e gera um SQL referente
* @param Model $model instância do model para gerar o SQL
* @return string retorna o SQL do model
*/
protected function getTable(Model $model)
{
$annotation = Annotation::get(get_class($model));
$class = $annotation->getClass();
if ($class->Entity) {
$table = new stdClass();
$table->Name = $class->Entity->Name ? $class->Entity->Name : get_class($model);
$table->Columns = array();
$table->Keys = array();
foreach ($model as $field => $value) {
$property = $annotation->getProperty($field);
if ($this->isField($property)) {
$column = new stdClass();
$column->Name = $this->getField($field, $property);
if (!$column->Name) {
$column->Name = $field;
}
$column->Type = $this->getType($property);
$column->Nullable = $this->getNullable($property);
$table->Columns[] = $column;
if ($this->isKey($property)) {
$table->Keys[] = $this->getKey($field, $property);
}
}
}
return $this->getSql($table);
}
}
开发者ID:nylmarcos,项目名称:estagio,代码行数:33,代码来源:Guita.php
示例16: insert
static function insert($type, $ref_id, $user_id = 0, $annotation = false)
{
global $db, $globals;
$ip = $globals['user_ip'];
$ip_int = $globals['user_ip_int'];
$sub = SitesMgr::my_id();
// Get this subsite's parent id (or itself if it's a parent)
$res = $db->query("insert into logs (log_sub, log_date, log_type, log_ref_id, log_user_id, log_ip_int, log_ip) values ({$sub}, now(), '{$type}', {$ref_id}, {$user_id}, {$ip_int}, '{$ip}')");
if ($res && $annotation) {
$a = new Annotation('log-' . $db->insert_id);
$a->text = $annotation;
$a->store(time() + 86400 * 30);
// Valid for one month
}
return $res;
}
开发者ID:GallardoAlba,项目名称:Meneame,代码行数:16,代码来源:log.php
示例17: save
public function save()
{
$annotation = new Annotation($this);
$table = $annotation->getClassAnnotation('table');
$reflector = new ReflectionClass($this);
$properties = $reflector->getProperties();
$data = array();
foreach ($properties as $property) {
$isPersistent = $annotation->getPropertyAnnotation($property->getName(), 'persistent');
$field_name = $annotation->getPropertyAnnotation($property->getName(), 'field');
var_dump($field_name);
if (true === $isPersistent) {
$data[$field_name] = $property->getValue();
}
}
var_dump($data);
}
开发者ID:nicolaspar,项目名称:Testings,代码行数:17,代码来源:baseRecord.class.php
示例18: initAnnotation
/**
* Initialize the annotation.
*/
public function initAnnotation($properties)
{
$this->_map($properties, array('format'));
parent::initAnnotation($properties);
if (!isset($this->format)) {
throw new AnnotationException('FormatAnnotation requires a format property');
}
}
开发者ID:BGCX261,项目名称:zool-php-framework-svn-to-git,代码行数:11,代码来源:FormatAnnotation.php
示例19: ofFunction
/**
* Resolve if callable is closure or function
*
* @param $callable
* @return Invokable
*/
public static function ofFunction($callable)
{
if ($callable instanceof \Closure or is_string($callable) and function_exists($callable)) {
$annotations = Annotation::ofFunction($callable);
$reflector = new \ReflectionFunction($callable);
return new Invokable($callable, Invokable::CLOSURE, $annotations, $reflector);
}
}
开发者ID:colorium,项目名称:runtime,代码行数:14,代码来源:Resolver.php
示例20: fire
/**
* Execute the console command.
*
* @return mixed
*/
public function fire()
{
$doc_id = $this->argument('doc_id');
$filename = $this->argument('filename');
$doc = Doc::where('id', $doc_id)->first();
$this->info("Exporting activity for " . $doc->title);
$annotations = Annotation::where('doc_id', $this->argument('doc_id'))->with('user')->with('comments')->get();
$comments = Comment::where('doc_id', $this->argument('doc_id'))->with('user')->get();
$headers = array("Created At", "Link", "Display Name", "Full Name", "Email", "Type", "Quote", "Text");
$toExport = array();
foreach ($annotations as $annotation) {
$annotationArray = array();
$annotationArray['date'] = $annotation->created_at;
$annotationArray['link'] = URL::to('/') . $annotation->uri . '#annotation_' . $annotation->id;
$annotationArray['display_name'] = $annotation->user->fname . " " . substr($annotation->user->lname, 0, 1);
$annotationArray['full_name'] = $annotation->user->fname . " " . $annotation->user->lname;
$annotationArray['email'] = $annotation->user->email;
$annotationArray['type'] = 'Annotation';
$annotationArray['quote'] = $annotation->quote;
$annotationArray['text'] = $annotation->text;
array_push($toExport, $annotationArray);
foreach ($annotation->comments as $comment) {
$user = User::find($comment->user_id);
$commentArray = array();
$commentArray['date'] = $comment->created_at;
$commentArray['link'] = "";
$commentArray['display_name'] = $user->fname . " " . substr($user->lname, 0, 1);
$commentArray['full_name'] = $user->fname . " " . $user->lname;
$commentArray['email'] = $user->email;
$commentArray['type'] = "Annotation Comment";
$commentArray['quote'] = "";
$commentArray['text'] = $comment->text;
array_push($toExport, $commentArray);
}
}
foreach ($comments as $comment) {
$commentArray = array();
$commentArray['date'] = $comment->created_at;
$commentArray['link'] = "";
$commentArray['display_name'] = $comment->user->fname . " " . substr($comment->user->lname, 0, 1);
$commentArray['full_name'] = $comment->user->fname . " " . $comment->user->lname;
$commentArray['email'] = $comment->user->email;
$commentArray['type'] = $comment->parent_id === null ? "Comment" : "Sub-comment";
$commentArray['quote'] = "";
$commentArray['text'] = $comment->text;
array_push($toExport, $commentArray);
}
$this->info('Saving export to ' . $filename);
$fp = fopen($filename, 'w');
fputcsv($fp, $headers);
foreach ($toExport as $row) {
fputcsv($fp, $row);
}
fclose($fp);
$this->info('Done.');
}
开发者ID:iaincollins,项目名称:madison,代码行数:61,代码来源:ActivityExport.php
注:本文中的Annotation类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论