This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Ergare17\Articles\Http\Controllers; |
||
4 | |||
5 | use App\User; |
||
6 | use Ergare17\Articles\Http\Requests\DestroyArticle; |
||
7 | use Ergare17\Articles\Http\Requests\ShowArticle; |
||
8 | use Ergare17\Articles\Http\Requests\StoreArticle; |
||
9 | use Ergare17\Articles\Http\Requests\UpdateArticle; |
||
10 | use Ergare17\Articles\Models\Article; |
||
11 | use Illuminate\Http\Request; |
||
12 | use Illuminate\Support\Facades\App; |
||
13 | use Redirect; |
||
14 | use Session; |
||
15 | |||
16 | class ArticleController extends Controller |
||
17 | { |
||
18 | /** |
||
19 | * Display a listing of the resource. |
||
20 | * |
||
21 | * @return \Illuminate\Http\Response |
||
22 | */ |
||
23 | public function index() |
||
24 | { |
||
25 | // CRUD -> Retrieve --> List |
||
26 | // BREAD -> Browse Read Edit Add Delete |
||
27 | $articles = Article::all(); |
||
28 | return view('articles::list_article', ['articles' => $articles]); |
||
29 | } |
||
30 | |||
31 | /** |
||
32 | * Show the form for creating a new resource. |
||
33 | * |
||
34 | * @return \Illuminate\Http\Response |
||
35 | */ |
||
36 | public function create() |
||
37 | { |
||
38 | $users = User::all(); |
||
39 | |||
40 | return view('articles::create_article', ['users' => $users]); |
||
41 | } |
||
42 | |||
43 | /** |
||
44 | * Store a newly created resource in storage. |
||
45 | * |
||
46 | * @param \Illuminate\Http\Request $request |
||
47 | * @return \Illuminate\Http\Response |
||
48 | */ |
||
49 | public function store(StoreArticle $request) |
||
50 | { |
||
51 | Article::create([ |
||
0 ignored issues
–
show
|
|||
52 | 'title' => $request->title, |
||
53 | 'description' => $request->description, |
||
54 | 'user_id' => $request->user_id, |
||
55 | 'read' => false, |
||
56 | ]); |
||
57 | |||
58 | Session::flash('status', 'Created ok!'); |
||
59 | return Redirect::to('/articles_php/create'); |
||
60 | } |
||
61 | |||
62 | /** |
||
63 | * Display the specified resource. |
||
64 | * |
||
65 | * @param \App\Article $article |
||
66 | * @return \Illuminate\Http\Response |
||
67 | */ |
||
68 | public function show(ShowArticle $request, Article $article) |
||
69 | { |
||
70 | // return view('show_article',compact('article')); |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
70% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
71 | return view('articles::show_article', compact('article')); |
||
72 | } |
||
73 | |||
74 | /** |
||
75 | * Display the specified resource. |
||
76 | * |
||
77 | * @param \App\Article $article |
||
0 ignored issues
–
show
There is no parameter named
$article . Was it maybe removed?
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. Consider the following example. The parameter /**
* @param array $germany
* @param array $island
* @param array $italy
*/
function finale($germany, $island) {
return "2:1";
}
The most likely cause is that the parameter was removed, but the annotation was not. ![]() |
|||
78 | * @return \Illuminate\Http\Response |
||
79 | */ |
||
80 | public function show1($id) |
||
81 | { |
||
82 | dump($id); |
||
83 | dump($article = Article::find($id)); |
||
84 | |||
85 | // if ($article == null)abort(404); |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
53% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
86 | // try{ |
||
87 | // $article = Article::findOrFail($id); |
||
88 | // } catch(\Exception $e){ |
||
89 | // abort(404); |
||
90 | // } |
||
91 | $article = Article::findOrFail($id); |
||
92 | |||
93 | dump($article->title); |
||
94 | // return $article; |
||
95 | } |
||
96 | |||
97 | /** |
||
98 | * Show the form for editing the specified resource. |
||
99 | * |
||
100 | * @param \App\Article $article |
||
101 | * @return \Illuminate\Http\Response |
||
102 | */ |
||
103 | public function edit(Article $article) |
||
104 | { |
||
105 | $users = User::all(); |
||
106 | |||
107 | return view('articles::edit_article', ['article' => $article,'users' => $users]); |
||
108 | } |
||
109 | |||
110 | /** |
||
111 | * Update the specified resource in storage. |
||
112 | * |
||
113 | * @param \Illuminate\Http\Request $request |
||
114 | * @param \App\Article $article |
||
115 | * @return \Illuminate\Http\Response |
||
116 | */ |
||
117 | public function update(UpdateArticle $request, Article $article) |
||
118 | { |
||
119 | $article->update($request->only(['title','description','user_id'])); |
||
120 | |||
121 | Session::flash('status', 'Edited ok!'); |
||
122 | return Redirect::to('/articles_php/edit/'.$article->id); |
||
0 ignored issues
–
show
The property
id does not exist on object<Ergare17\Articles\Models\Article> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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. ![]() |
|||
123 | } |
||
124 | |||
125 | /** |
||
126 | * Remove the specified resource from storage. |
||
127 | * |
||
128 | * @param \App\Article $article |
||
129 | * @return \Illuminate\Http\Response |
||
130 | */ |
||
131 | public function destroy(DestroyArticle $request, Article $article) |
||
132 | { |
||
133 | $article->delete(); |
||
134 | Session::flash('status', 'Article was deleted successful!'); |
||
135 | return Redirect::to('/articles_php'); |
||
136 | } |
||
137 | } |
||
138 |
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.