@@ -27,12 +27,12 @@ add a PDF brochure for each product. To do so, add a new property called
2727 #[ORM\Column(type: 'string')]
2828 private $brochureFilename;
2929
30- public function getBrochureFilename()
30+ public function getBrochureFilename(): string
3131 {
3232 return $this->brochureFilename;
3333 }
3434
35- public function setBrochureFilename($brochureFilename)
35+ public function setBrochureFilename(string $brochureFilename)
3636 {
3737 $this->brochureFilename = $brochureFilename;
3838
@@ -126,13 +126,14 @@ Finally, you need to update the code of the controller that handles the form::
126126 use Symfony\Component\HttpFoundation\File\Exception\FileException;
127127 use Symfony\Component\HttpFoundation\File\UploadedFile;
128128 use Symfony\Component\HttpFoundation\Request;
129+ use Symfony\Component\HttpFoundation\Response;
129130 use Symfony\Component\Routing\Annotation\Route;
130131 use Symfony\Component\String\Slugger\SluggerInterface;
131132
132133 class ProductController extends AbstractController
133134 {
134135 #[Route('/product/new', name: 'app_product_new')]
135- public function new(Request $request, SluggerInterface $slugger)
136+ public function new(Request $request, SluggerInterface $slugger): Response
136137 {
137138 $product = new Product();
138139 $form = $this->createForm(ProductType::class, $product);
@@ -245,7 +246,7 @@ logic to a separate service::
245246 ) {
246247 }
247248
248- public function upload(UploadedFile $file)
249+ public function upload(UploadedFile $file): string
249250 {
250251 $originalFilename = pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME);
251252 $safeFilename = $this->slugger->slug($originalFilename);
@@ -260,7 +261,7 @@ logic to a separate service::
260261 return $fileName;
261262 }
262263
263- public function getTargetDirectory()
264+ public function getTargetDirectory(): string
264265 {
265266 return $this->targetDirectory;
266267 }
0 commit comments