The Gra points out that there is a fundamental machlokes harishonim about a rented חצר. Rashi, Tosafos, Ritva and others hold that if you rent a חצר you, the renter is קונה with the חצר. The Rambam on the other hand (quoted in שו"ע סי' שי"ג) holds that the משכיר is קונה. The Rambam is difficult based on the Gemara on י"א by ר"ג. The Gemara says that ר"ג was מקנה to ר' יהושע with a קנין חצר by renting out the place where the grain was. We see clearly that the שוכר is קונה with a קנין חצר. The acharonim on the shulchan aruch give various answers עיי"ש.
This is also relevant to pshat in the Gemara. According to Rashi you have to say that בחצר דאגר ליה לשוכר ותורי דשוכר is either or because since the שוכר is קונה if he rented the חצר then why would it need to be his animals? On the other hand according to the Rambam you may need both.