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 Ridibooks\Platform\Common\Base; |
||
4 | |||
5 | use ReflectionClass; |
||
6 | use ReflectionProperty; |
||
7 | use Symfony\Component\HttpFoundation\Request; |
||
8 | |||
9 | /** |
||
10 | * 이 클래스는 "상속받은 클래스가 DTO" 임을 의미하고, 이와 관련된 최소한의 정보만 다룬다. |
||
11 | */ |
||
12 | class AdminBaseDto |
||
13 | { |
||
14 | /** |
||
15 | * @var |
||
16 | * @depecated Request에 종속적인 정보 |
||
17 | */ |
||
18 | public $command; //명령어 (insert / update / ...) |
||
19 | /** |
||
20 | * @var |
||
21 | * @depecated DB에 종속적인 정보, id는 모델에서 저장하도록 |
||
22 | */ |
||
23 | public $id; //공통으로 쓰이는 id |
||
24 | /** |
||
25 | * @var |
||
26 | * @depecated Request에 종속적인 정보 |
||
27 | */ |
||
28 | public $page; //paging에서 공통으로 쓰이는 page |
||
29 | /** |
||
30 | * @var |
||
31 | * @depecated Request에 종속적인 정보 |
||
32 | */ |
||
33 | public $search_text; //공통으로 쓰이는 검색어 |
||
34 | |||
35 | /** |
||
36 | * AdminBaseDto constructor. |
||
37 | * @param null $param |
||
38 | * @deprecated 암시적으로 생성자 사용하지 않고, 명시적으로 import, export 호출 |
||
39 | */ |
||
40 | public function __construct($param = null) |
||
41 | { |
||
42 | if ($param instanceof Request) { |
||
0 ignored issues
–
show
|
|||
43 | $this->importFromRequest($param); |
||
44 | } elseif ($param instanceof \stdClass) { |
||
45 | $this->importFromStdClass($param); |
||
46 | } elseif (is_array($param)) { |
||
47 | $this->importFromArray($param); |
||
48 | } |
||
49 | } |
||
50 | |||
51 | /** |
||
52 | * Request class를 이용하여 클래스를 초기화한다. |
||
53 | * @param Request $request |
||
54 | * @internal public 이 아닌 protected 로 변경필요 |
||
55 | */ |
||
56 | public function importFromRequest($request) |
||
57 | { |
||
58 | $reflect = new ReflectionClass(get_called_class()); |
||
59 | $properties = $reflect->getProperties(ReflectionProperty::IS_PUBLIC | ReflectionProperty::IS_PROTECTED); |
||
60 | foreach ($properties as $property) { |
||
61 | $property->setValue($this, $request->get($property->getName())); |
||
62 | } |
||
63 | } |
||
64 | |||
65 | /**stdClass 일 경우 클래스 초기화 |
||
66 | * @param \stdClass $stdClass |
||
67 | * @internal public 이 아닌 protected 로 변경필요 |
||
68 | */ |
||
69 | View Code Duplication | public function importFromStdClass($stdClass) |
|
0 ignored issues
–
show
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...
|
|||
70 | { |
||
71 | $reflect = new ReflectionClass(get_called_class()); |
||
72 | $properties = $reflect->getDefaultProperties(); |
||
73 | foreach ($properties as $key => $value) { |
||
74 | $this->{$key} = $stdClass->{$key}; |
||
75 | } |
||
76 | } |
||
77 | |||
78 | /**interface의 function을 가져와 클래스를 초기화 한다. |
||
79 | * @param $reader |
||
80 | * @deprecated UniversalBookReader 를 상속받아 구현할것 |
||
81 | */ |
||
82 | View Code Duplication | public function importFromInterface($reader) |
|
0 ignored issues
–
show
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...
|
|||
83 | { |
||
84 | $reflect = new ReflectionClass(get_called_class()); |
||
85 | $default_properties = $reflect->getDefaultProperties(); |
||
86 | foreach ($default_properties as $key => $value) { |
||
87 | if (method_exists($reader, $key)) { |
||
88 | $this->{$key} = $reader->$key(); |
||
89 | } |
||
90 | } |
||
91 | } |
||
92 | |||
93 | /** |
||
94 | * 배열을 이용하여 클래스를 초기화한다 |
||
95 | * @param array $array |
||
96 | * @throws \Exception |
||
97 | * @internal public 이 아닌 protected 로 변경필요 |
||
98 | */ |
||
99 | public function importFromArray($array) |
||
100 | { |
||
101 | if (!is_array($array)) { |
||
102 | throw new \Exception('invalid array'); |
||
103 | } |
||
104 | $reflect = new ReflectionClass(get_called_class()); |
||
105 | $properties = $reflect->getDefaultProperties(); |
||
106 | foreach ($properties as $key => $value) { |
||
107 | if (array_key_exists($key, $array)) { |
||
108 | $this->{$key} = $array[$key]; |
||
109 | } |
||
110 | } |
||
111 | } |
||
112 | |||
113 | /** |
||
114 | * 함수를 호출한 클래스의 기본 멤버변수만을(동적, 부모 멤버변수 제외) 리턴한다. |
||
115 | * @return array |
||
116 | * @internal public 이 아닌 protected 로 변경필요 |
||
117 | */ |
||
118 | public function exportAsArray() |
||
119 | { |
||
120 | $reflect = new ReflectionClass(get_called_class()); |
||
121 | $reflect_parent = $reflect->getParentClass(); |
||
122 | $default_properties = $reflect->getDefaultProperties(); |
||
123 | |||
124 | $columns = []; |
||
125 | foreach ($default_properties as $key => $value) { |
||
126 | if ($reflect_parent->hasProperty($key)) { |
||
127 | // 부모 클래스의 properties는 무시한다. |
||
128 | continue; |
||
129 | } |
||
130 | $columns = array_merge($columns, [$key => $this->{$key}]); |
||
131 | } |
||
132 | |||
133 | return $columns; |
||
134 | } |
||
135 | |||
136 | /** |
||
137 | * 함수를 호출한 클래스의 기본 멤버변수만큼(동적, 부모 멤버변수 제외) 리턴한다. |
||
138 | * 단, Null값을 가진 column은 제외한다. |
||
139 | * @return array |
||
140 | * @internal public 이 아닌 protected 로 변경필요 |
||
141 | * @deprecated use exportAsArray |
||
142 | */ |
||
143 | public function exportAsArrayExceptNull() |
||
144 | { |
||
145 | $columns = $this->exportAsArray(); |
||
146 | |||
147 | foreach ($columns as $key => $value) { |
||
148 | if ($value === null) { |
||
149 | unset($columns[$key]); |
||
150 | } |
||
151 | } |
||
152 | |||
153 | return $columns; |
||
154 | } |
||
155 | } |
||
156 |
This error could be the result of:
1. Missing dependencies
PHP Analyzer uses your
composer.json
file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects thecomposer.json
to be in the root folder of your repository.Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the
require
orrequire-dev
section?2. Missing use statement
PHP does not complain about undefined classes in
ìnstanceof
checks. For example, the following PHP code will work perfectly fine:If you have not tested against this specific condition, such errors might go unnoticed.