There has been some confusion on the part of posters in past threads on this topic. A foreign-flagged yacht that is simply transiting the waters, or one that has cleared in and is simply making an occasional stop here and there, only has to follow the safety
requirements of the flag state.
At some point you are no longer "passing through" but you are considered to be sojourning in the country, and at that point IIRC Portugal and/or Spain have required vessels which will be operating in their waters to meet their safety
codes. It is definitely a matter of duration of your presence in their country, not something that applies to vessels which are merely passing through one way or another. If you take out a 30 or 90 day contract
at a marina? That might trigger enough "residency" to cause a problem, where an overnight stay or a week would not.
If you keep expired flares on board as extras, keep them separately stowed out of sight of the regular pyros. Having expired flares as extras has been argued as "having expired flares", even though having them IN ADDITION TO a set of legal
and proper flares is not illegal in the US, and "should" not be illegal anywhere else. But why give anyone an opening to argue?