move $length variable outsite foreach (#6828)
move $length variable outsite foreach (#6828)

the `foreach` over the `prefixDirsPsr4[$search]` won't affect `$length`. 

It's used for the offset of `$logicalPathPsr4`.
localheinz/composer,milleruk/composer,dzuelke/composer,erasys/composer,slbmeh/composer,andrerom/composer,floverdevel/composer,alcohol/composer,stof/composer,fabpot/composer,gencer/composer,naderman/composer,staabm/composer,nicolas-grekas/composer,SpacePossum/composer,pierredup/composer,composer/composer,johnstevenson/composer,stefangr/composer,vdm-io/composer