CButtonColumn - change is_string test(s).

I’ld prefer to see CButtonColumn->renderButton:




		if(isset($button['imageUrl']) && is_string($button['imageUrl']))

			echo CHtml::link(CHtml::image($button['imageUrl'],$label),$url,$options);

		else

			echo CHtml::link($label,$url,$options);

change into




		if(isset($button['imageUrl']) && ''!==''.$button['imageUrl']))

			echo CHtml::link(CHtml::image($button['imageUrl'],$label),$url,$options);

		else

			echo CHtml::link($label,$url,$options);

or

change into




		if(isset($button['imageUrl']) && $button['imageUrl']!==null))

			echo CHtml::link(CHtml::image($button['imageUrl'],$label),$url,$options);

		else

			echo CHtml::link($label,$url,$options);

Rationale:

  • When the button’s ‘imageUrl’ is defined and not ‘null’, the framework can suppose that it is a string. If an exception is thrown, then this is a bug in the applicaiton.

  • $button[‘imageUrl’] can be an object with a ‘__toString’ providing a User dependent rendering of the setup (see Wiki). ‘is_string’ does not check that.

  • Checking against an empty string seems more general than checking the type - an empty string is not an image and could implicitaly mean that text rendering is wanted.

There are surely other places in the framework where I’ld prefer to see such an evolution.