Issues (446)

Security Analysis    no request data  

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

php7/TraitForFileSystem.inc (46 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/*******************************************************************
3
 * Created by:  Marko Kungla @ OkramLabs on Aug 6, 2012 - 9:36:42
4
 * Contact:     [email protected] - https://okramlabs.com
5
 * @copyright   2015 OkramLabs - https://okramlabs.com
6
 * @license     MIT
7
 *
8
 * Package name: libhowi-filesystem
9
 * @category     HOWI3
10
 * @package      libhowi
11
 * @subpackage   filesystem
12
 * 
13
 * Lang:      PHP
14
 * Encoding:  UTF-8
15
 * File:      TraitForFileSystem.inc
16
 * @link      https://
17
 ********************************************************************
18
 * Contributors:
19
 * @author Marko Kungla <[email protected]>
20
 *           Github: https://github.com/mkungla
21
 ********************************************************************
22
 * Comments:
23
 */
24
namespace HOWI3\libhowi\Filesystem\php7;
25
26
use \RecursiveIteratorIterator;
27
use \HOWI3\libhowi\Filesystem\php7\Objects\DirectoryTreeObject;
28
29 View Code Duplication
trait TraitForFileSystem
0 ignored issues
show
This class 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...
30
{
31
32
    /**
33
     *
34
     * {@inheritDoc}
35
     *
36
     */
37 6
    public function cd($path = false, $validate_dir_name = false)
0 ignored issues
show
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
38
    {
39 6
        return $this->setCwd($path, $validate_dir_name);
0 ignored issues
show
It seems like setCwd() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
40
    }
41
42
    /**
43
     * rmdir
44
     *
45
     * {@inheritDoc}
46
     *
47
     */
48 2
    public function rm($pathname, $shred = false)
49
    {
50 2
        $pathname = $this->makeAbsolute($pathname);
0 ignored issues
show
It seems like makeAbsolute() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
51 2
        $response = false;
52 2
        if (is_dir($pathname)) {
53
            
54 2
            $files = array_diff(scandir($pathname), 
55
                array(
56 2
                    '.',
57
                    '..'
58
                ));
59 2
            foreach ($files as $file) {
60
                
61 1
                (is_dir("$pathname/$file") ? $this->rm("$pathname/$file", $shred) : (! empty($shred) &&
62 1
                     ! $this->isLink($pathname . DIRECTORY_SEPARATOR . $file) ? exec(
0 ignored issues
show
It seems like isLink() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
63 1
                        "shred -fzu $pathname" . DIRECTORY_SEPARATOR . "$file") : $this->rm(
64 1
                        $pathname . DIRECTORY_SEPARATOR . $file, $shred)));
65
            }
66
            
67 2
            $response = rmdir($pathname);
68 2
            $this->info(702, $pathname);
0 ignored issues
show
It seems like info() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
69 2
            $this->response()->setStatus($response);
0 ignored issues
show
It seems like response() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
70
        } else {
71 2
            $this->info(702, $pathname);
0 ignored issues
show
It seems like info() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
72 2
            $this->response()->setStatus($response);
0 ignored issues
show
It seems like response() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
73 2
            (! empty($shred) && ! $this->isLink($pathname) ? exec("shred -fzu $pathname") : unlink($pathname));
0 ignored issues
show
It seems like isLink() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
74
        }
75 2
        return $response;
76
    }
77
78
    /**
79
     *
80
     * {@inheritDoc}
81
     *
82
     */
83 1
    public function scandir($path = false)
84
    {
85 1
        return ! empty($path) && is_dir($this->makeAbsolute($path)) ? scandir($this->makeAbsolute($path)) : false;
0 ignored issues
show
It seems like makeAbsolute() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
86
    }
87
88
    /**
89
     *
90
     * {@inheritDoc}
91
     *
92
     */
93 1
    public function stat($filename = false)
94
    {
95 1
        return ! empty($filename) && file_exists($this->makeAbsolute($filename)) ? stat(
0 ignored issues
show
It seems like makeAbsolute() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
96 1
            $this->makeAbsolute($filename)) : false;
0 ignored issues
show
It seems like makeAbsolute() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
97
    }
98
99
    /**
100
     *
101
     * {@inheritDoc}
102
     *
103
     */
104 1
    public function getDiskTotalSpace($partition_location = false, $convert = false)
105
    {
106 1
        if (empty($partition_location))
107 1
            $partition_location = $this->getCwd();
0 ignored issues
show
It seems like getCwd() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
108
        
109 1
        if (empty($convert))
110 1
            return disk_total_space($partition_location);
111
        
112 1
        $bytestotal = 0;
0 ignored issues
show
$bytestotal 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...
113
        $suffixes = array(
114 1
            'B',
115
            'kB',
116
            'MB',
117
            'GB',
118
            'TB',
119
            'PB',
120
            'EB',
121
            'ZB',
122
            'YB'
123
        );
124 1
        $bytestotal = disk_total_space($partition_location);
125
        
126 1
        $base = log($bytestotal, 1024);
127
        return array(
128 1
            round(pow(1024, $base - floor($base)), 2),
129 1
            $suffixes[floor($base)]
130
        );
131
    }
132
133
    /**
134
     *
135
     * {@inheritDoc}
136
     *
137
     */
138 1
    public function getDiskFreeSpace($partition_location = false, $convert = false)
139
    {
140 1
        if (empty($partition_location))
141 1
            $partition_location = $this->getCwd();
0 ignored issues
show
It seems like getCwd() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
142
        
143 1
        if (empty($convert))
144 1
            return disk_free_space($partition_location);
145
        
146
        $result = [
147 1
            0,
148
            'B'
149
        ];
150 1
        $bytestotal = 0;
0 ignored issues
show
$bytestotal 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...
151
        $suffixes = array(
152 1
            'B',
153
            'kB',
154
            'MB',
155
            'GB',
156
            'TB',
157
            'PB',
158
            'EB',
159
            'ZB',
160
            'YB'
161
        );
162 1
        $bytestotal = disk_free_space($partition_location);
163
        
164 1
        $base = log($bytestotal, 1024);
165
        
166 1
        if ($bytestotal > 0) {
167
            $result = array(
168 1
                round(pow(1024, $base - floor($base)), 2),
169 1
                $suffixes[floor($base)]
170
            );
171
        }
172 1
        return $result;
173
    }
174
175
    /**
176
     *
177
     * {@inheritDoc}
178
     *
179
     */
180 1
    public function chgrp($filename = false, $group = false)
181
    {
182 1
        return ! empty($filename) && $this->exists($this->makeAbsolute($filename)) ? chgrp(
0 ignored issues
show
It seems like makeAbsolute() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
It seems like exists() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
183 1
            $this->makeAbsolute($filename), $group) : false;
0 ignored issues
show
It seems like makeAbsolute() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
184
    }
185
186
    /**
187
     *
188
     * {@inheritDoc}
189
     *
190
     */
191 1
    public function chmod($filename = false, $mode = false)
192
    {
193 1
        $filename = $this->makeAbsolute($filename);
0 ignored issues
show
It seems like makeAbsolute() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
194 1
        if (file_exists($filename) && ! empty($mode) && is_int($mode))
195 1
            return chmod($filename, octdec(str_pad($mode, 4, 0, STR_PAD_LEFT)));
196
        else
197 1
            return false;
198
    }
199
200
    /**
201
     *
202
     * {@inheritDoc}
203
     *
204
     */
205 1
    public function chown($filename = false, $user = false)
206
    {
207 1
        $filename = $this->makeAbsolute($filename);
0 ignored issues
show
It seems like makeAbsolute() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
208 1
        if (file_exists($filename) && ! empty($user))
209 1
            return chown($filename, $user);
210
        else
211 1
            return false;
212
    }
213
214
    /**
215
     *
216
     * {@inheritDoc}
217
     *
218
     */
219 2
    public function clearstatcache($clear_realpath_cache = false, $filename = false)
220
    {
221 2
        if (! empty($filename) && ! empty($clear_realpath_cache))
222 1
            clearstatcache($clear_realpath_cache, $this->makeAbsolute($filename));
0 ignored issues
show
It seems like makeAbsolute() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
223
        else
224 2
            clearstatcache();
225 2
    }
226
227
    /**
228
     *
229
     * {@inheritDoc}
230
     *
231
     */
232 1
    public function copy($source = false, $dest = false, $context = false)
233
    {
234 1
        $source = $this->makeAbsolute($source);
0 ignored issues
show
It seems like makeAbsolute() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
235 1
        $dest = $this->makeAbsolute($dest);
0 ignored issues
show
It seems like makeAbsolute() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
236
        
237 1
        if (! empty($source) && ! empty($dest) && ! is_dir($source)) {
238
            
239 1
            if (empty($context))
240 1
                return copy($source, $dest);
241
            else
242 1
                return copy($source, $dest, $context);
243 1
        } elseif ((! empty($source) && ! empty($dest)) && is_dir($source) && ! file_exists($dest)) {
244
            
245 1
            $tmp_key = basename($source);
246 1
            $tmp_key2 = basename($dest);
247 1
            $tmp_src_key = $this->dir($tmp_key, dirname($source));
0 ignored issues
show
It seems like dir() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
248
            
249 1
            $this->dir($tmp_key2, dirname($dest), false, $tmp_src_key->getPerms());
0 ignored issues
show
It seems like dir() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
250 1
            $this->close($tmp_key);
0 ignored issues
show
$tmp_key is of type string, but the function expects a boolean.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
251 1
            $this->close($tmp_key2);
0 ignored issues
show
$tmp_key2 is of type string, but the function expects a boolean.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
252
            
253 1
            foreach ($iterator = new RecursiveIteratorIterator(
254 1
                new \RecursiveDirectoryIterator($source, \RecursiveDirectoryIterator::SKIP_DOTS),  // DirectoryTreeObject::CURRENT_AS_FILEINFO
255 1
                \RecursiveIteratorIterator::SELF_FIRST) as $item) {
256 1
                if ($item->isDir()) {
257 1
                    if (empty($context)) {
258 1
                        mkdir($dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName(), 
259 1
                            octdec(str_pad($iterator->getPerms(), 4, 0, STR_PAD_LEFT)));
260
                    } 
261
262
                    else
263 1
                        mkdir($dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName(), 
264 1
                            octdec(str_pad($iterator->getPerms(), 4, 0, STR_PAD_LEFT)), false, $context);
265
                } else {
266 1
                    if (empty($context))
267 1
                        $this->copy($item, $dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
0 ignored issues
show
$dest . DIRECTORY_SEPARA...rator->getSubPathName() is of type string, but the function expects a boolean.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
268
                    else
269 1
                        $this->copy($item, $dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName(), 
0 ignored issues
show
$dest . DIRECTORY_SEPARA...rator->getSubPathName() is of type string, but the function expects a boolean.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
270
                            $context);
271
                }
272
            }
273
            
274 1
            return true;
275
        } else
276 1
            return false;
277
    }
278
279
    /**
280
     *
281
     * {@inheritDoc}
282
     *
283
     */
284 1
    public function mv($oldname = false, $newname = false, $context = false)
285
    {
286 1
        if (empty($oldname) || empty($newname))
287 1
            return false;
288
        
289 1
        $oldname = $this->makeAbsolute($oldname);
0 ignored issues
show
It seems like makeAbsolute() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
290 1
        $newname = $this->makeAbsolute($newname);
0 ignored issues
show
It seems like makeAbsolute() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
291
        
292 1
        if (! empty($context))
293
            return rename($oldname, $newname, $context);
294
        
295 1
        return rename($oldname, $newname);
296
    }
297
298
    /**
299
     *
300
     * {@inheritDoc}
301
     *
302
     */
303 1
    public function namePatternMatch($pattern = false, $string = false, $flags = false)
304
    {
305 1
        if (empty($pattern))
306 1
            return false;
307
        
308 1
        if (! empty($flags))
309
            return fnmatch($pattern, $string, $flags);
310
        else
311 1
            return fnmatch($pattern, $string);
312
    }
313
314
    /**
315
     *
316
     * {@inheritDoc}
317
     *
318
     */
319 1
    public function getGlob($pattern = false, $flags = 0)
320
    {
321 1
        return glob($pattern, $flags);
322
    }
323
324
    /**
325
     *
326
     * {@inheritDoc}
327
     *
328
     */
329 1
    public function isUploadedFile($filename = false)
330
    {
331 1
        $filename = $this->makeAbsolute($filename);
0 ignored issues
show
It seems like makeAbsolute() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
332 1
        return is_uploaded_file($filename);
333
    }
334
335
    /**
336
     *
337
     * {@inheritDoc}
338
     *
339
     */
340 1
    public function getRealpathCache()
341
    {
342 1
        return realpath_cache_get();
343
    }
344
345
    /**
346
     *
347
     * {@inheritDoc}
348
     *
349
     */
350 1
    public function getRealpathCacheSize()
351
    {
352 1
        return realpath_cache_size();
353
    }
354
355
    /**
356
     *
357
     * {@inheritDoc}
358
     *
359
     */
360 2
    public function close($keyword = false)
361
    {
362 2
        if (!empty($keyword) && array_key_exists($keyword, $this->dirkeys) &&
0 ignored issues
show
The property dirkeys does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
363 2
             array_key_exists($this->dirkeys[$keyword], $this->dirs)) {
0 ignored issues
show
The property dirs does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
364 2
            unset($this->dirs[$this->dirkeys[$keyword]]);
365 2
            unset($this->dirkeys[$keyword]);
366 2
            return true;
367 1
        } elseif(!empty($keyword) && array_key_exists($keyword,$this->files)) {
0 ignored issues
show
The property files does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
368 1
            $this->files[$keyword] = null;
369 1
            unset($this->files[$keyword]);
370 1
            return true;
371
        } else {
372 1
            return false;
373
        }
374
    }
375
376
    /**
377
     *
378
     * {@inheritDoc}
379
     *
380
     */
381 1
    public function touch($filename = false, $time = false, $atime = false)
382
    {
383 1
        if (empty($filename))
384
            return false;
385
        
386 1
        $filename = $this->makeAbsolute($filename);
0 ignored issues
show
It seems like makeAbsolute() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
387
        
388 1
        $time = ! empty($time) ? $time : time();
389 1
        $atime = ! empty($atime) ? $atime : time();
390
        
391 1
        return touch($filename, $time, $atime);
392
    }
393
394
    /**
395
     *
396
     * {@inheritDoc}
397
     *
398
     */
399 1
    public function getDirKeys()
0 ignored issues
show
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
400
    {
401 1
        return $this->dirkeys;
402
    }
403
404
    /**
405
     *
406
     * {@inheritDoc}
407
     *
408
     */
409 1
    public function getFileKeys()
0 ignored issues
show
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
410
    {
411 1
        return $this->files;
412
    }
413
    
414
    /**
415
     *
416
     * {@inheritDoc}
417
     *
418
     */
419 2
    public function createStructure($rootpath, $data_array, $skip_debug = false)
420
    {
421 2
        $absolute_path = $this->makeAbsolute($rootpath);
0 ignored issues
show
It seems like makeAbsolute() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
422 2
        if (empty($skip_debug))
423 2
            $this->debug(810);
0 ignored issues
show
It seems like debug() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
424 2
        if (empty($rootpath) || ! is_array($data_array) ||
425 2
             (! $this->isWritable($absolute_path) && ! $this->isWritable(dirname($absolute_path))))
0 ignored issues
show
It seems like isWritable() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
426 2
            return $this->warning(506) && false;
0 ignored issues
show
It seems like warning() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
427
        
428 2
        if (! $this->isDir($absolute_path))
0 ignored issues
show
It seems like isDir() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
429 2
            mkdir($absolute_path, 0755, true);
430
        
431 2
        foreach ($data_array as $key => $val) {
432 2
            if (is_array($val))
433 2
                ! $this->createStructure($absolute_path . DIRECTORY_SEPARATOR . $key, $val, true);
434
            else
435 2
                touch($absolute_path . DIRECTORY_SEPARATOR . $val);
436
        }
437 2
        if (empty($skip_debug))
438 2
            $this->info(704, $rootpath);
0 ignored issues
show
It seems like info() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
439 2
        return true;
440
    }
441
}
442