This question is specifically aiming at the UK PhD admission system.
Having spent roughly 6 years in the UK - 2 years A-Level and 4 years undergraduate, I am now moving forward into applying for PhD programs. To my surprise, I discovered that I would have to face a lot of difficulties regarding my eligibility for funding.
Most of the funding I applied for were strictly 'UK/EU citizens only', and it is rare to have full funding for international students. I have applied to a lot of places, and received a lot of responses in the form of "... you are a good match, but I don't have funding for overseas students...".
Having chosen the UK to study with the belief that 'as long as I am competent I should be qualified for the job', the reality has really slapped back at me.
Why such discriminations are allowed in a developed country like the UK? I made this claim knowing little to nothing about the US or other countries' systems, but lots of my friends having applied to EU PhDs received their offers without being asked whether they are 'caucasians' or not.
The short version is: Because they can be, and because they have to be. UK universities make money off international students; their funding is limited, and it is designed to go to domestic or European students. The funding bodies will only fund domestics because a) they're probably not allowed to fund anyone else; b) it's in their best interests to fund domestics; c) one international PhD scholarship would be equal to 2 or 3 domestic ones.
There is also the over-arching idea in the UK governmental system that students are supposed to bring in money, not take it. This idea has spiked in magnitude in the past few years.
The UK government limits the funding given to universities, and universities make up for that with international fees. We are essentially cash cows, outside the rare scholarships that are extremely competitive (Rhodes, Fullbright - the second of which neither of us is eligible for).
You also can't go for the option of naturalisation based on the time you've been in the country because -- you guessed it -- time as a student doesn't count.
Source: Same situation as you, left friends, home, and partner to do PhD in France after 5 years in Britain. I had many PhD acceptances, but none of the universities could fund me and we spent months looking at every option. Unless you're rich and you can self-fund (or you're happy to take out loans), it's unfortunately not very doable right now.
You should also keep in mind that, as a student at the end of your education, you are unfortunately likely to be targeted by the immigration police. I would advise you to not do anything like overstay, but also to not leave the UK once you have graduated until you're ready to move away before the expiry of your tier 4 visa -- because you will not be allowed back in even if your visa has months of validity on it. It happened to me. This is unrelated to your question, but it's a warning I think not enough people in our situation get.