1

With all the new upgrades released in PHP 8.2 with readonly classes, is it possible to do:

declare(strict_types=1);

globally in a project?

RG Servers
  • 1,726
  • 2
  • 11
  • 27
  • 1
    @dev_mustafa with all due respect, `php 7` (2015 released) != `php 8.2` (2022 released) – RG Servers Jan 11 '23 at 08:48
  • 1
    Although some of the concepts may be different, the main substance of the link from @dev_mustafa may still be correct. Will have to see if there is any further input. – Nigel Ren Jan 11 '23 at 09:16
  • 1
    @NigelRen I would hope so, especially since PHP has been consistently releasing new changes thought the years to the type system and type casting, it would seems as if they will eventually make it a requirement, especially since major Frameworks & IDEs are incorporating it now. I would personally love to hear if anyone has discovered a way to make it globally enforced. – RG Servers Jan 11 '23 at 09:30
  • Not good - but also just found https://stackoverflow.com/questions/71097200/do-we-still-need-declarestrict-types-1-in-php-8-1 – Nigel Ren Jan 11 '23 at 13:26
  • 1
    To define that globally, it would possible be needed to resolve this before being able to do so: [Function calls from within internal functions will not be affected by the strict_types declaration](https://www.php.net/manual/en/language.types.declarations.php#language.types.declarations.strict:~:text=Function%20calls%20from%20within%20internal%20functions%20will%20not%20be%20affected%20by%20the%20strict_types%20declaration) ? – Luuk Feb 04 '23 at 11:34

0 Answers0