1 | <?php |
||
20 | class MongoGridFSFile |
||
21 | { |
||
22 | /** |
||
23 | * @link http://php.net/manual/en/class.mongogridfsfile.php#mongogridfsfile.props.file |
||
24 | * @var array |
||
25 | */ |
||
26 | public $file; |
||
27 | |||
28 | /** |
||
29 | * @link http://php.net/manual/en/class.mongogridfsfile.php#mongogridfsfile.props.gridfs |
||
30 | * @var $gridfs |
||
31 | */ |
||
32 | protected $gridfs; |
||
33 | |||
34 | /** |
||
35 | * @link http://php.net/manual/en/mongogridfsfile.construct.php |
||
36 | * |
||
37 | * @param MongoGridFS $gridfs The parent MongoGridFS instance |
||
38 | * @param array $file A file from the database |
||
39 | */ |
||
40 | public function __construct(MongoGridFS $gridfs, array $file) |
||
45 | |||
46 | /** |
||
47 | * Returns this file's filename |
||
48 | * @link http://php.net/manual/en/mongogridfsfile.getfilename.php |
||
49 | * @return string Returns the filename |
||
50 | */ |
||
51 | public function getFilename() |
||
55 | |||
56 | /** |
||
57 | * Returns this file's size |
||
58 | * @link http://php.net/manual/en/mongogridfsfile.getsize.php |
||
59 | * @return int Returns this file's size |
||
60 | */ |
||
61 | public function getSize() |
||
65 | |||
66 | /** |
||
67 | * Writes this file to the filesystem |
||
68 | * @link http://php.net/manual/en/mongogridfsfile.write.php |
||
69 | * @param string $filename The location to which to write the file (path+filename+extension). If none is given, the stored filename will be used. |
||
70 | * @return int Returns the number of bytes written |
||
71 | */ |
||
72 | public function write($filename = null) |
||
91 | |||
92 | /** |
||
93 | * This will load the file into memory. If the file is bigger than your memory, this will cause problems! |
||
94 | * @link http://php.net/manual/en/mongogridfsfile.getbytes.php |
||
95 | * @return string Returns a string of the bytes in the file |
||
96 | */ |
||
97 | public function getBytes() |
||
106 | |||
107 | /** |
||
108 | * This method returns a stream resource that can be used to read the stored file with all file functions in PHP. |
||
109 | * The contents of the file are pulled out of MongoDB on the fly, so that the whole file does not have to be loaded into memory first. |
||
110 | * At most two GridFSFile chunks will be loaded in memory. |
||
111 | * |
||
112 | * @link http://php.net/manual/en/mongogridfsfile.getresource.php |
||
113 | * @return resource Returns a resource that can be used to read the file with |
||
114 | */ |
||
115 | public function getResource() |
||
123 | |||
124 | private function copyToResource($handle) |
||
133 | |||
134 | private function getChunks() |
||
142 | } |
||
143 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
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.