Yii Framework Forum: using short array syntax BUT stick to php 5.3 - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

using short array syntax BUT stick to php 5.3

#1 User is offline   thyseus 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 300
  • Joined: 18-April 09
  • Location:Leipzig, Germany

Posted 21 March 2012 - 09:27 AM

I know that Yii 2 is aimed at php 5.3. The short array syntax introduced in php 5.4 is only cosmetic,
but since Yii in general has borrowed so many cool things from ruby on rails, i just CAN´T live with this
ugly array(''=>array(... constructs anymore.

Since the array short syntax is nothing more than replacing all array( with [ and the corresponding ) with ],
there could be a one-liner script converting the yii 2.0 codebase recursively into short-array-syntax. Would
this be possible or am i missing something?
0

#2 User is offline   phpnode 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 141
  • Joined: 18-April 11

Posted 21 March 2012 - 09:58 AM

What's the point? Just use ["short array" => "syntax"] in your application code and don't worry about what syntax Yii uses.
2

#3 User is offline   thyseus 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 300
  • Joined: 18-April 09
  • Location:Leipzig, Germany

Posted 21 March 2012 - 12:52 PM

Yeah, you're right. We wait for Yii3 which will have PHP6 as a requirement. Year 2016 maybe?

Oh and we will pronounce it 3ii ! :)
1

#4 User is offline   zen∞ 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 15
  • Joined: 18-October 11

Posted 22 March 2012 - 05:26 PM

I thinks you are missing the point phpnode is making. If you are using php5.4 in your server, you can easily replace all YOUR files with [syntax] instead of array(syntax) leaving the framework files untouched. Internally everything will work just as usual.
1

#5 User is offline   Jaggi 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 90
  • Joined: 05-September 11

Posted 22 March 2012 - 05:30 PM

I don't get the point of this, its not like javascript where every character counts. It also adds no performance boost. Out of this I like the fact array dereferencing has been added more than anything.
See my development site @ www.CodeTheInter.net (BETA)

Posted Image Posted Image

Quote

If you make it idiot proof, they'll build a better idiot
0

#6 User is offline   wisp 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 192
  • Joined: 04-February 11

Posted 19 May 2012 - 11:28 AM

View PostJaggi, on 22 March 2012 - 05:30 PM, said:

I don't get the point of this, its not like javascript where every character counts. It also adds no performance boost. Out of this I like the fact array dereferencing has been added more than anything.

It makes your scripts easier to read and prettier.. Especially in Yii, where about anything is done in arrays, it would be an improvement. A big advantage is that using square brackets, you can distinguish between method calls and arrays. For example, compare:

 $this->render('product/overview', array('model' => $model, 'dataProvider' => $dataProvider));

 $this->render('product/overview', ['model' => $model, 'dataProvider' => $dataProvider]);

0

#7 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,359
  • Joined: 12-October 09
  • Location:Croatia

Posted 20 May 2012 - 12:59 PM

As @zen pointed above... if you use PHP 5.4 you can do that in your code... without changing anything in the Yii core.
Find more about me.... btw. Do you know your WAN IP?
0

#8 User is offline   wisp 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 192
  • Joined: 04-February 11

Posted 20 May 2012 - 01:59 PM

View Postmdomba, on 20 May 2012 - 12:59 PM, said:

As @zen pointed above... if you use PHP 5.4 you can do that in your code... without changing anything in the Yii core.

Agreed.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users