BlogController::softDeleteAction()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 8

Duplication

Lines 15
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 15
loc 15
rs 9.4285
cc 2
eloc 8
nc 2
nop 1
1
<?php
2
3
namespace Anax\Blog;
4
 
5
/**
6
 * A controller for a blog and its posts.
7
 *
8
 */
9
class BlogController implements \Anax\DI\IInjectionAware
10
{
11
    use \Anax\DI\TInjectable,
12
        \Anax\MVC\TRedirectHelpers;
13
	
14
	public $blog;
15
	
16
	/**
17
	 * Initialize the controller.
18
	 *
19
	 * @return void
20
	 */
21
	public function initialize()
22
	{
23
		$this->blog = new \Anax\Blog\Blog();
24
		$this->blog->setDI($this->di);
0 ignored issues
show
Bug introduced by
It seems like $this->di can also be of type array or null; however, Anax\DI\TInjectable::setDI() does only seem to accept object<Anax\DI\class>, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
25
	}
26
	
27
	public function setupAction()
28
	{
29
		require('setup.php');
30
		
31
		$this->redirectTo('blog/list');
32
	}
33
	
34
	public function indexAction()
35
	{
36
		$all = $this->blog->findAllOrder('id', 'DESC');
37
	 
38
		$this->theme->setTitle("A blog");
0 ignored issues
show
Documentation introduced by
The property theme does not exist on object<Anax\Blog\BlogController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
39
		$this->views->add('blog/view-blog', [
0 ignored issues
show
Documentation introduced by
The property views does not exist on object<Anax\Blog\BlogController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
40
			'posts' => $all,
41
			'title' => "A Blog",
42
		]);
43
	}
44
	
45
	/**
46
	 * List all blogposts.
47
	 *
48
	 * @return void
49
	 */
50 View Code Duplication
	public function listAction()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
51
	{
52
		$all = $this->blog->findAll();
53
	 
54
		$this->theme->setTitle("List all posts");
0 ignored issues
show
Documentation introduced by
The property theme does not exist on object<Anax\Blog\BlogController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
55
		$this->views->add('blog/list', [
0 ignored issues
show
Documentation introduced by
The property views does not exist on object<Anax\Blog\BlogController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
56
			'posts' => $all,
57
			'title' => "All blogposts",
58
		]);
59
	}
60
	
61
	/**
62
	 * View blogpost with slug.
63
	 *
64
	 * @param int $slug of post to display
65
	 *
66
	 * @return void
67
	 */
68 View Code Duplication
	public function viewAction($slug = null)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
69
	{
70
		$blog = $this->blog->findWhere('slug', $slug);
71
		
72
		if (empty($blog)) {
73
			die('No such post!');
74
		}
75
		
76
		$post = $blog[0];	 
77
	 
78
		$this->theme->setTitle("View post with id");
0 ignored issues
show
Documentation introduced by
The property theme does not exist on object<Anax\Blog\BlogController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
79
		$this->views->add('blog/view-post', [
0 ignored issues
show
Documentation introduced by
The property views does not exist on object<Anax\Blog\BlogController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
80
			'post' => $post,
81
		]);
82
	}
83
	
84
	/**
85
	 * Add new blogpost.
86
	 *
87
	 *
88
	 * @return void
89
	 */
90 View Code Duplication
	public function addAction()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
91
	{
92
		
93
		$form = new \Anax\Blog\CFormAddPost();
94
        $form->setDI($this->di);
0 ignored issues
show
Bug introduced by
It seems like $this->di can also be of type array or null; however, Anax\DI\TInjectionAware::setDI() does only seem to accept object<Anax\DI\class>, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
95
		
96
		// Check the status of the form
97
        $form->check();
98
	 
99
		$this->di->theme->setTitle("Add blogpost");
100
        $this->di->views->add('default/page', [
101
            'title' => "Add a blogpost",
102
            'content' => $form->getHTML()
103
        ]);
104
	}
105
	
106
	/**
107
	 * Edit a blogpost.
108
	 *
109
	 * @param string $id of post to edit.
110
	 *
111
	 * @return void
112
	 */
113 View Code Duplication
	public function updateAction($id = null)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
114
	{
115
		
116
		if (!$id) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $id of type string|null is loosely compared to false; this is ambiguous if the string can be empty. You might want to explicitly use === null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
117
			$this->redirectTo('blog');
118
		}
119
		
120
		$blog = $this->blog->find($id);
121
		
122
		$form = new \Anax\Blog\CFormUpdatePost($blog);
123
        $form->setDI($this->di);
0 ignored issues
show
Bug introduced by
It seems like $this->di can also be of type array or null; however, Anax\DI\TInjectionAware::setDI() does only seem to accept object<Anax\DI\class>, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
124
		
125
		// Check the status of the form
126
        $form->check();
127
	 
128
		$this->di->theme->setTitle("Update blogpost");
129
        $this->di->views->add('default/page', [
130
            'title' => "Update a blogpost",
131
            'content' => $form->getHTML()
132
        ]);
133
	}
134
	
135
	/**
136
	 * Delete blogpost.
137
	 *
138
	 * @param integer $id of post to delete.
139
	 *
140
	 * @return void
141
	 */
142
	public function deleteAction($id = null)
143
	{
144
		if (!isset($id)) {
145
			die("Missing id");
146
		}
147
	 
148
		$res = $this->blog->delete($id);
0 ignored issues
show
Unused Code introduced by
$res is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
149
	 
150
		$this->redirectTo('blog/list');
151
	}
152
	
153
	/**
154
	 * Delete (soft) blogpost.
155
	 *
156
	 * @param integer $id of post to delete.
157
	 *
158
	 * @return void
159
	 */
160 View Code Duplication
	public function softDeleteAction($id = null)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
161
	{
162
		if (!isset($id)) {
163
			die("Missing id");
164
		}
165
	 
166
		$now = gmdate('Y-m-d H:i:s');
167
	 
168
		$blog = $this->blog->find($id);
169
	 
170
		$blog->deleted = $now;
171
		$blog->save();
172
	
173
		$this->redirectTo('blog/trash');
174
	}
175
	
176
	/**
177
	 * Restore (soft) deleted blogpost.
178
	 *
179
	 * @param integer $id of post to restore.
180
	 *
181
	 * @return void
182
	 */
183 View Code Duplication
	public function restoreAction($id = null)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
184
	{
185
		if (!isset($id)) {
186
			die("Missing id");
187
		}
188
	 
189
		$blog = $this->blog->find($id);
190
	 
191
		$blog->deleted = null;
192
		$blog->save();
193
	 
194
		$this->redirectTo('blog');
195
	}
196
	
197
	/**
198
	 * Activate blogpost.
199
	 *
200
	 * @param integer $id of upost to activate.
201
	 *
202
	 * @return void
203
	 */
204
	public function activateAction($id = null)
205
	{
206
		if (!isset($id)) {
207
			die("Missing id");
208
		}
209
	 
210
		$blog = $this->blog->find($id);
211
	 
212
		$blog->inactivated = null;
213
		$blog->save();
214
	 
215
		$this->redirectTo('blog/list');
216
	}
217
	
218
	/**
219
	 * Inactivate blogpost.
220
	 *
221
	 * @param integer $id of post to inactivate.
222
	 *
223
	 * @return void
224
	 */
225 View Code Duplication
	public function inactivateAction($id = null)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
226
	{
227
		if (!isset($id)) {
228
			die("Missing id");
229
		}
230
		
231
		$now = gmdate('Y-m-d H:i:s');
232
	 
233
		$blog = $this->blog->find($id);
234
	 
235
		$blog->inactivated = $now;
236
		$blog->save();
237
	 
238
		$this->redirectTo('blog/inactive');
239
	}
240
	
241
	/**
242
	 * List all active and not deleted blogposts.
243
	 *
244
	 * @return void
245
	 */
246 View Code Duplication
	public function activeAction()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
247
	{
248
		$all = $this->blog->query()
249
			->where('inactivated IS NULL')
250
			->andWhere('deleted is NULL')
251
			->execute();
252
	 
253
		$this->theme->setTitle("Posts that are active");
0 ignored issues
show
Documentation introduced by
The property theme does not exist on object<Anax\Blog\BlogController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
254
		$this->views->add('blog/active', [
0 ignored issues
show
Documentation introduced by
The property views does not exist on object<Anax\Blog\BlogController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
255
			'posts' => $all,
256
			'title' => "Blogposts that are active",
257
		]);
258
	}
259
	
260
	/**
261
	 * List all inactive blogposts.
262
	 *
263
	 * @return void
264
	 */
265 View Code Duplication
	public function inactiveAction()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
266
	{
267
		$all = $this->blog->query()
268
			->where('inactivated IS NOT NULL')
269
			->execute();
270
	 
271
		$this->theme->setTitle("Posts that are inactive");
0 ignored issues
show
Documentation introduced by
The property theme does not exist on object<Anax\Blog\BlogController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
272
		$this->views->add('blog/inactive', [
0 ignored issues
show
Documentation introduced by
The property views does not exist on object<Anax\Blog\BlogController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
273
			'posts' => $all,
274
			'title' => "Blogposts that are inactive",
275
		]);
276
	}
277
	
278
	/**
279
	 * List all deleted blogposts.
280
	 *
281
	 * @return void
282
	 */
283 View Code Duplication
	public function trashAction()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
284
	{
285
		$all = $this->blog->query()
286
			->where('deleted IS NOT NULL')
287
			->execute();
288
	 
289
		$this->theme->setTitle("Posts that are deleted");
0 ignored issues
show
Documentation introduced by
The property theme does not exist on object<Anax\Blog\BlogController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
290
		$this->views->add('blog/deleted', [
0 ignored issues
show
Documentation introduced by
The property views does not exist on object<Anax\Blog\BlogController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
291
			'posts' => $all,
292
			'title' => "Blogposts that are deleted",
293
		]);
294
	}
295
	 
296
}