lechimp-p /
flightcontrol
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | /****************************************************************************** |
||
| 3 | * An iterator interface over the Leagues flysystem. |
||
| 4 | * Copyright (c) 2021, 2015 Richard Klees <[email protected]> |
||
| 5 | * |
||
| 6 | * This software is licensed under GPLv3. You should have received |
||
| 7 | * a copy of the along with the code. |
||
| 8 | */ |
||
| 9 | |||
| 10 | require_once("tests/autoloader.php"); |
||
| 11 | |||
| 12 | $adapter = new \League\Flysystem\Adapter\Local(__DIR__); |
||
| 13 | $flysystem = new \League\Flysystem\Filesystem($adapter); |
||
| 14 | $flightcontrol_strict = new \Lechimp\Flightcontrol\Flightcontrol($flysystem); |
||
| 15 | |||
| 16 | $dir = $flightcontrol_strict->directory(""); |
||
| 17 | |||
| 18 | $runs = 100; |
||
| 19 | $count = 0; |
||
| 20 | |||
| 21 | $start = microtime(true); |
||
| 22 | for($i = 0; $i < $runs; $i++) { |
||
| 23 | $count = 0; |
||
| 24 | $dir |
||
|
0 ignored issues
–
show
|
|||
| 25 | ->iterateOn() |
||
| 26 | ->iterateOn() |
||
| 27 | ->with(function($obj) use (&$count) { |
||
|
0 ignored issues
–
show
|
|||
| 28 | $count += 1; |
||
| 29 | }); |
||
| 30 | } |
||
| 31 | $end = microtime(true); |
||
| 32 | $diff = $end - $start; |
||
| 33 | |||
| 34 | echo "Flightcontrol: ".sprintf("%10.4f", $diff)." s (and counted $count)\n"; |
||
| 35 | |||
| 36 | $start = microtime(true); |
||
| 37 | for ($i = 0; $i < $runs; $i++) { |
||
| 38 | $count = 0; |
||
| 39 | foreach($flysystem->listContents() as $dir) { |
||
| 40 | foreach($flysystem->listContents($dir["path"]) as $dir2) { |
||
| 41 | $count += 1; |
||
| 42 | } |
||
| 43 | } |
||
| 44 | } |
||
| 45 | $end = microtime(true); |
||
| 46 | $diff = $end - $start; |
||
| 47 | |||
| 48 | echo "Flysystem: ".sprintf("%10.4f", $diff)." s (and counted $count)\n"; |
||
| 49 | |||
| 50 | $start = microtime(true); |
||
| 51 | for ($i = 0; $i < $runs; $i++) { |
||
| 52 | $count = 0; |
||
| 53 | foreach(scandir(".") as $dir) { |
||
| 54 | if (!is_dir($dir) or $dir == "." or $dir == "..") { |
||
| 55 | continue; |
||
| 56 | } |
||
| 57 | foreach(scandir("./$dir") as $dir2) { |
||
| 58 | if ($dir2 == "." or $dir2 == "..") { |
||
| 59 | continue; |
||
| 60 | } |
||
| 61 | $count += 1; |
||
| 62 | } |
||
| 63 | } |
||
| 64 | } |
||
| 65 | $end = microtime(true); |
||
| 66 | $diff = $end - $start; |
||
| 67 | |||
| 68 | echo "scandir: ".sprintf("%10.4f", $diff)." s (and counted $count)\n"; |
||
| 69 | |||
| 70 | |||
| 71 |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: