[TYPO3-core] superfluous curly brackets {}

Stefan Neufeind typo3.neufeind at speedpartner.de
Sat Oct 13 12:07:32 CEST 2012


On 10/13/2012 12:02 PM, François Suter wrote:
> Hi,
> 
>> Well, looking into the code it turned out this reads:
>>
>>    $this->{$offset}
> 
> Ah, that's quite different ;-)
> 
>> or so. So imho the brackets make sense there and I'd favour if we could
>> add it for the CGL.
> 
> I agree that it would improve readability. OTOH I don't much like such
> constructs, as they make the code quite unreadable. I would rather we
> used some accessor method.

It's only used in some small functions like:

  public function offsetExists($offset) {
    $offsetExists = FALSE;
    if (in_array($offset, $this->gettableProperties, TRUE) &&
isset($this->{$offset})) {
      $offsetExists = TRUE;
    }
    return $offsetExists;
  }


  public function offsetSet($offset, $value) {
    if (in_array($offset, $this->settableProperties, TRUE)) {
      $this->{$offset} = $offset;
    }
  }

Within such a limited scope it's imho okay.


Regards,
 Stefan


More information about the TYPO3-team-core mailing list