You may become a Portuguese tax resident if you spend more than 183 days (consecutive or non-consecutive) in Portugal during any 12-month period beginning or ending in the relevant tax year. Tax residency may also arise with fewer days if you have a home in Portugal that indicates an intention to maintain and occupy it as your habitual residence. Adjust the Start Date and End Date to match your actual qualifying period.
https://info.portaldasfinancas.gov.pt/en/tax-information/getting-started-in-portugal/tax-residency/tax-residency-rules/Pages/default.aspx