1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Nicklas\Comment\Modules; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* A database driven model. |
7
|
|
|
*/ |
8
|
|
|
class Post extends ActiveRecordModelExtender |
9
|
|
|
{ |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* @var string $tableName name of the database table. |
13
|
|
|
*/ |
14
|
|
|
protected $tableName = "coffee_posts"; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Columns in the table. |
18
|
|
|
* |
19
|
|
|
* @var integer $id primary key auto incremented. |
20
|
|
|
*/ |
21
|
|
|
public $id; |
22
|
|
|
public $user; |
23
|
|
|
public $questionId; # Connection to new Question() |
24
|
|
|
public $accepted; # default "no" |
25
|
|
|
|
26
|
|
|
public $type; # question/answer |
27
|
|
|
public $text; |
28
|
|
|
|
29
|
|
|
public $created; |
30
|
|
|
|
31
|
|
|
public $di; |
32
|
|
|
|
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Set ups the question |
36
|
|
|
* @param object $post |
37
|
|
|
* |
38
|
|
|
* @return object |
39
|
|
|
*/ |
40
|
8 |
|
public function setupPost($post) |
41
|
|
|
{ |
42
|
|
|
|
43
|
8 |
|
$user = new User($this->db); |
44
|
8 |
|
$comment = new Comment($this->db); |
45
|
8 |
|
$vote = new Vote($this->db); |
46
|
|
|
|
47
|
8 |
|
$post->img = $user->getGravatar($post->user); |
48
|
8 |
|
$post->comments = $comment->getComments("parentId = ?", [$post->id]); |
49
|
8 |
|
$post->vote = $vote->getVote("parentId = ? AND parentType = ?", [$post->id, "post"]); |
50
|
8 |
|
$post->markdown = $this->getMD($post->text); |
51
|
|
|
|
52
|
8 |
|
return $post; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Returns post with markdown and gravatar |
57
|
|
|
* @param string $sql |
58
|
|
|
* @param array $param |
|
|
|
|
59
|
|
|
* |
60
|
|
|
* @return objects[] |
61
|
|
|
*/ |
62
|
9 |
|
public function getAllPosts($sql, $params) |
63
|
|
|
{ |
64
|
9 |
|
$posts = $this->findAllWhere("$sql", $params); |
65
|
|
|
|
66
|
|
|
// array_reverse so latest order question gets returned |
67
|
9 |
|
return array_map(array($this, 'setupPost'), $posts); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* return question/answer, three attributes are set, comments connected to them is an array. |
72
|
|
|
* @param string $sql |
73
|
|
|
* @param array $param |
|
|
|
|
74
|
|
|
* |
75
|
|
|
* @return object |
76
|
|
|
*/ |
77
|
8 |
|
public function getPost($sql, $params) |
78
|
|
|
{ |
79
|
8 |
|
$post = $this->findWhere("$sql", $params); |
80
|
8 |
|
return $post->setupPost($post); |
|
|
|
|
81
|
|
|
} |
82
|
|
|
} |
83
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.
Consider the following example. The parameter
$ireland
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was changed, but the annotation was not.