protected function generateHashes(): array
    {
        $dirLength = strlen($this->dir);
        foreach ($this->createIterator() as $file) {
            if (!$file->isFile()) {
                continue;
            }
            $realpath = $file->getRealPath();
            $path = $file->getPath().DIRECTORY_SEPARATOR.$file->getFilename();

            # skip aliases
            if ($realpath !== $path) {
                continue;
            }

            # remove the relative directory from the file path
            $path = substr($realpath, $dirLength);

            # map hashes by a lowercase version of the path
            # this should prevent issues caused by case sensitive filesystems
            $lowerPath = strtolower($path);
            if (isset($this->hashes[$lowerPath])) {
                $message = "duplicate file encountered: $path ($lowerPath)";
                throw new \RuntimeException($message);
            }

            $this->hashes[$lowerPath] = sha1_file($realpath);
        }

        ksort($this->hashes);
        return $this->hashes;
    }
protected function generateHashes(): array
    {
        $dirLength = strlen($this->dir);
        foreach ($this->createIterator() as $file) {
            if (!$file->isFile()) {
                continue;
            }
            $realpath = $file->getRealPath();
            $path = $file->getPath().DIRECTORY_SEPARATOR.$file->getFilename();

            # skip aliases
            if ($realpath !== $path) {
                continue;
            }

            # remove the relative directory from the file path
            $path = substr($realpath, $dirLength);

            # map hashes by a lowercase version of the path
            # this should prevent issues caused by case sensitive filesystems
            $lowerPath = strtolower($path);
            if (isset($this->hashes[$lowerPath])) {
                $message = "duplicate file encountered: $path ($lowerPath)";
                throw new \RuntimeException($message);
            }

            $this->hashes[$lowerPath] = sha1_file($realpath);
        }

        ksort($this->hashes);
        return $this->hashes;
    }
protected function generateHashes ( ) : array { $ dirLength = strlen ( $ this -> dir ) ; foreach ( $ this -> createIterator ( ) as $ file ) { if ( ! $ file -> isFile ( ) ) { continue ; } $ realpath = $ file -> getRealPath ( ) ; $ path = $ file -> getPath ( ) . DIRECTORY_SEPARATOR . $ file -> getFilename ( ) ; # skip aliases if ( $ realpath !== $ path ) { continue ; } # remove the relative directory from the file path $ path = substr ( $ realpath , $ dirLength ) ; # map hashes by a lowercase version of the path # this should prevent issues caused by case sensitive filesystems $ lowerPath = strtolower ( $ path ) ; if ( isset ( $ this -> hashes [ $ lowerPath ] ) ) { $ message = "duplicate file encountered: $path ($lowerPath)" ; throw new \ RuntimeException ( $ message ) ; } $ this -> hashes [ $ lowerPath ] = sha1_file ( $ realpath ) ; } ksort ( $ this -> hashes ) ; return $ this -> hashes ; }
Generate hashes for all files found using an iterator

@return array<string,string>
@throws \RuntimeException If a duplicate directory is encountered
Generate hashes for all files found using an iterator