On Wed, Mar 8, 2023, at 6:26 PM, Hamza Ahmad wrote: > In my second project, I did not receive a warning when I passed the > wrong parameters. To give you an example, I have two constructors: > 1. ` public function __construct(int $date, int$month, int $year) ` > 2. ` public function __construct(string ...$names) ` > When I initialized the latter object with the former object's > signature i.e., `new LatterObject(date: 1, month: 1, year: 1970); > `, I did not receive a warning of passing the wrong parameters.
Is the code in strict mode? If not, then that is the expected behavior. You should get a $names array that has 3 associative keys, each with a numeric value that's been cast to a string. In strict mode, I would expect that to give a TypeError, but not in weak mode. --Larry Garfield -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: https://www.php.net/unsub.php