In a standing mixer fitted with the whisk attachment, whip the yolks and sugar on high speed until pale and thick enough to hold a ribbon, 3 to 4 minutes. Reduce the speed to low and slowly add the flour, beating until combined. Gradually add the milk, mixing until well combined.
In a medium saucepan, cook the yolk mixture over medium heat, whisking constantly, just until the mixture boils, 3 to 4 minutes. Remove from the heat; stir in the butter and vanilla.
Strain the pastry cream through a fine-mesh sieve. Let cool slightly. Cover with plastic, putting plastic directly on the pastry cream so that it doesn't form a skin. Refrigerate until chilled completely.