When using Cypher, you'd save a lot of code:
START file=node(1) // or startNode as named parameter
MATCH p=file<-[:download]-()-[:download]->otherFile
RETURN otherFile, count(*) order by count(*) desc
If you want to limit to e.g. best 5 matches, amend limit 5
.
Check out https://github.com/jadell/neo4jphp/wiki/Cypher-and-gremlin-queries for how to use Cypher with neo4jphp.