FR 8240 then FR 9440 at Madrid
Porto → Madrid → Lisbon
Timetable, Madrid time
16:30FR 8240 from Porto at the gate
16:15FR 9440 to Lisbon leaves the gate
23 h 45 apart on the timetable, overnight
FR 9440 leaves 23 h 45 after FR 8240 arrives on the timetable: more than half a day, so not a connection we count.