Re: C# properties vs. accessors RFC

From: Date: Thu, 24 Jan 2013 13:45:06 +0000
Subject: Re: C# properties vs. accessors RFC
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
Am 24.01.2013 02:12, schrieb Levi Morrison:
I also don't like the ? for nullable. Just stick with PHP convention and do:
      class Foo {
          public Bar $bar = NULL;
      }
There is no such PHP convention. The PHP convention is *not restrict type* (+"loosely typed" addons). So NULL is automatically allowed. For properties, yes, but the idea it stems from is type-hints. Given the following type-hint, passing a null is not allowed:
     class Foo {
       function bar(Bar $bar) {}
     }
Whereas in the following NULL is allowed:
     class Foo {
       function bar(Bar $bar = NULL) {}
     }
This is what I mean by the PHP convention for allowing NULL. Hello Levi, you absolutly right. I was confused by the syntax. This properties are normal methods and should behave the same. Mixing "initialize-with-NULL" and "optional/nullable" is somewhat messy though. cryptocompress

Thread (19 messages)

« previous php.internals (#65147) next »