This might be a suprise for lots of people that PHP supports strict typing,Since it’s not enabled by default, PHP by default has Type Jggling enabled which is a way to automaticlly detect types without specifying it,Although Type Juggling is nice sometimes especially at the beggining of a new project, After you reach around 400 lines of code the errors tends to make no sense and not specific,Since you haven’t been specific with types in your Sourse Code

To enable Strict Typing

Add the following at the begining of your PHP file

1<?php declare(strict_types=1);

To specify Argument Types

Here you can see a function where we add two integers, if you try to pass any Argument with any type other than integer, You would get an error, a specific and helpful one, just like other languages where they use static typing like C.

1<?php declare(strict_types=1);
2
3function add(int $firstNum,int $secondNum){
4  return $firstNum+$secondNum;
5}
6add(1,1);