Pursuant to the regulations currently in force, the answer to the question will depend on the basis on which a foreigner who is not a Ukrainian citizen currently resides in Poland.
If a foreigner has the right to visa-free travel in the EU (the list of countries whose foreigners are eligible for visa-free travel can be found here: https://eur-lex.europa.eu/legal-content/PL/ALL/?uri=CELEX:32018R1806 – Annex II) and has not yet exhausted the 90-day period of stay in the Schengen area, he will be able to submit an application for international protection in another EU country.
If a foreigner has a residence permit or a visa issued by another country, he will be able to apply for international protection in that country.
If a foreigner has a visa issued by any of the EU countries, he will be able to travel within the EU for 90 days within every 180 days, but he should apply for international protection in the country that issued the visa. Otherwise, it may be sent back to the issuing country for the examination of its application for international protection.
If a foreigner is covered by temporary protection and for this reason he has received a certificate from the Head of the Office for Foreigners, he or she may travel freely in the Schengen countries for 90 days for each subsequent 180 days, as long as he has a valid travel document.
However, if the situation concerns a foreigner who has crossed the border on the basis of a permit issued by the Border Guard Commander in Chief (residence permit for a period of 15 days) and has not been covered by temporary protection, then, according to the regulations, he or she is entitled to stay only in the territory of Poland. In the event of crossing the border and applying for international protection in another country, he may be transferred back to Poland on the basis of the so-called Dublin III Regulation. Of course, whether the transfer actually takes place will depend on the will of the state in which the foreigner submitted the application, as well as whether this state completes all the formalities on time. There are also humanitarian or family reasons that may result in the withdrawal from the transfer of the foreigner to Poland.
It should also be emphasized that individual EU countries may adopt different political decisions regarding the return of foreigners to Poland under the Dublin III Regulation. Other EU countries, despite the possibility of sending a given foreigner to Poland, may decide that they will nevertheless recognize the application for granting international protection of a given foreigner.