Re: Re: [RFC-Discuss] Scalar Type Declarations v0.5

From: Date: Wed, 25 Feb 2015 12:54:20 +0000
Subject: Re: Re: [RFC-Discuss] Scalar Type Declarations v0.5
References: 1 2 3 4 5 6  Groups: php.internals 
Request: Send a blank email to internals+get-83779@lists.php.net to get a copy of this message
On Wed, Feb 25, 2015 at 4:30 AM, Dmitry Stogov <dmitry@zend.com> wrote: > anyone may tell, what this will print without running :) > > main.php > ======== > <?php > declare(strict_types=1) > include "a.php"; > include "b.php"; > var_dump(foo("5")); > ?> > > a.php > ===== > <?php > declare(strict_types=0) > function foo(string $a): string { > bar($a); > return $a; > } > ?> > > b.php > ===== > <?php > declare(strict_types=1) > function bar(int &$a) { > var_dump($a); > } > ?> > > Thank. Dmitry. > > As I understand the proposal and above example, it's possible to change the 'strict_type' settings per file. So, for an enterprise application being developed over many years, it's a very realistic scenario that this setting will be different in different files especially if coding conventions are not followed (happens very often). Does that mean when reading or writing code, in addition to checking the signature of a function, I have to check the 'strict_types' setting at the top as well, to understand how that signature behaves? Thanks Shashank

« previous php.internals (#83779) next »