lists every item in a given dir

see here: https://stackoverflow.com/a/49066335/1966490

@param string $path
@return array
490892
private function _list(string $path): array {
        $result = [];
        $scan = glob($path . '/*');
        foreach ($scan as $item) {
            if (is_dir($item)) {
                $result[basename($item)] = $this->_list($item);
            } else {
                $result[] = basename($item);
            }
        }
        return $result;
    }
1304951
private function pathinfo(string $path): array
    {
        $pathinfo = pathinfo($path) + compact('path');
        $pathinfo['dirname'] = array_key_exists('dirname', $pathinfo) ?
                            $this->normalizeDirname($pathinfo['dirname']) :
                            '';

        return $pathinfo;
    }
169189
private function getDirectoryIterator($path)
    {
        $nodes = new \DirectoryIterator($path);
        $dirs = [];

        foreach ($nodes as $dir) {
            if (!$dir->isDir()) {
                continue;
            }

            if ($dir->isDot()) {
                continue;
            }

            $dirs[hexdec($dir->getFilename())] = $dir->getPathname();
        }

        krsort($dirs);

        return new \ArrayIterator($dirs);
    }
515578
protected function _scandir($path) {
		
		$s3path = preg_replace("/^\//", "", $path) . '/';
		
		$files = $this->s3->ListBucket(array('Bucket' => $this->options['bucket'], 'delimiter' => '/', 'Prefix' => $s3path))->ListBucketResponse->Contents;
	
		$finalfiles = array();
		
		foreach ($files as $file) {
			if (preg_match("|^" . $s3path . "[^/]*/?$|", $file->Key)) {
				$fname = preg_replace("/\/$/", "", $file->Key);
				$fname = $file->Key;
				
				if ($fname != preg_replace("/\/$/", "", $s3path)) {
					
				}
				
				$finalfiles[] = $fname;
			}
		}
		
		sort($finalfiles);
		return $finalfiles;
	}
481208
private function getPhpFilesFromPath(string $path)
    {
        $directoryIterator = new RecursiveDirectoryIterator($path);
        foreach (new RecursiveIteratorIterator($directoryIterator) as $file) {
            if (! in_array($file->getExtension(), $this->fileExtensions)) {
                continue;
            }

            if ($this->fileShouldBeIgnored($file)) {
                continue;
            }

            $this->files->push(new File(['displayPath' => $file->getPathName(), 'fullPath' => $file->getRealPath()]));
        }
    }
812391
public function readFileList($path){
        $open_file = opendir($path);

        while($opendir = readdir($open_file)) {
            if(($opendir != ".") && ($opendir != "..") && is_file($targetdir."/".$opendir)) {
                //$createTime   = filemtime($path.$opendir);
                $fileArr[] = $opendir;
            }
        }
        closedir($open_file);
        return $fileArr;

    }
1165632
private function getModules(string $path) : array
    {
        $result = [];
        foreach (Utility::findDirs($path) as $module) {
            if (! $this->isModule($module)) {
                continue;
            }

            $result[] = $module;
        }

        return $result;
    }
808760
public function _pathAsArray($path)
    {
        $result = explode(self::PS, $path);
        // unset empty nodes
        foreach ($result as $key => $item) {
            if (!$item && $item !== "0") {
                unset($result[$key]);
            }
        }
        // re-index array
        $result = array_values($result);
        return $result;
    }
1178729
protected function findNewFiles(string $path) : array
    {
        $arrReturn = [];
        $arrFolders = scandir($path);
        $arrSkip = [
            '.',
            '..',
        ];
        
        foreach ($arrFolders as $file) {
            //No Folder Defaults
            if (in_array($file, $arrSkip)) {
                continue;
            }
            //Process Subfolders
            if (is_dir($path.$file)) {
                $arrSubFolderFiles = $this->findNewFiles($path.$file."/");
                $arrReturn = $this->addArrayToNewFiles($arrSubFolderFiles, $arrReturn);
                continue;
            }
            $arrReturn[] = $path.$file;
        }
        
        //Remove file from list if already processed
        foreach($arrReturn as $key => $file) {
            if (in_array($file, $this->knownUpdateFiles)) {
                unset($arrReturn[$key]);
            }
        }
        return $arrReturn;
    }
659047
protected function getScandir($path) {
		$files = array();
		
		!isset($this->dirsCache[$path]) && $this->cacheDir($path);

		foreach ($this->dirsCache[$path] as $p) {
			if (($stat = $this->stat($p)) && empty($stat['hidden'])) {
				$files[] = $stat;
			}
		}

		return $files;
	}
243011
private function get_folder_contents( $path ) {

		$items = array();
		$uid   = opendir( $path );
		if ( $uid ) {
			return $this->load_folder_items( $uid, $path );
		}

		return $items;
	}
984965
public function dirList($path){
        if (is_dir($path)){
            $folder = opendir($path);
            while($file = readdir($folder)){
                if ($file == '.' || $file == '..') continue;
                $rtn[]   = $file;
            }
            closedir($folder);
        }

        return $rtn;
    }
1211181
protected function lintDirectory($path)
    {
        $success = true;
        $directory = new \DirectoryIterator($this->phpci->buildPath . $path);

        foreach ($directory as $item) {
            if ($item->isDot()) {
                continue;
            }

            $itemPath = $path . $item->getFilename();

            if (in_array($itemPath, $this->ignore)) {
                continue;
            }

            if (!$this->lintItem($item, $itemPath)) {
                $success = false;
            }
        }

        return $success;
    }
1056507
public function dir($path) {
		$files = [];

		$dh = $this->getState()->opendir($this->buildUrl($path));
		while ($file = $this->getState()->readdir($dh)) {
			$name = $file['name'];
			if ($name !== '.' and $name !== '..') {
				$fullPath = $path . '/' . $name;
				$files [] = new NativeFileInfo($this, $fullPath, $name, function () use ($fullPath) {
					return $this->getStat($fullPath);
				});
			}
		}

		$this->getState()->closedir($dh);
		return $files;
	}
43570
protected function search_folders( $path ) {
		$return       = array();
		$base_folders = array_filter( glob( $this->trailingslashit( $path ) . '*' ), 'is_dir' );

		if ( is_array( $base_folders ) && ! empty( $base_folders ) ) {
			foreach ( $base_folders as $folder ) {
				$_sub = $this->search_folders( $this->untrailingslashit( $folder ) );

				if ( is_array( $_sub ) && ! empty( $_sub ) ) {
					$return = array_merge( $return, $_sub );
				} elseif ( is_string( $_sub ) ) {
					$return = array_merge( $return, array( $_sub ) );
					$return = array_merge( $return, array( $this->untrailingslashit( $path ) ) );
				}
			}
		} else {
			$return = array( $this->trailingslashit( $path ) );
		}

		return $return;
	}
222083
public function getExcludePaths($path)
    {
        $excludePaths = [];

        $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path));
        $objects = new \RegexIterator($iterator, '/.*(.php)$/', \RecursiveRegexIterator::GET_MATCH);

        foreach ($objects as $filename => $object) {
            if (preg_filter($this->ignoredFolder, [], $filename)) {
                $excludePaths[] = dirname($filename);
            }
        }

        $excludePaths = array_unique($excludePaths);

        return $excludePaths;
    }
334108
public function lsFiles(string $path = '') : array
    {
        return array_filter(
            $this->ls($path),
            function(File $file) {
                return $file->isFile();
            }
        );
    }