News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

WebTutor.pl:
Strong data typing in PHP, part II autoboxing and indestructable objects
April 14, 2011 @ 12:09:40

In the second part of their series looking at data typing in PHP, the WebTutor blog takes a different approach to supporting strong typing in PHP, using autoboxing and indestructible objects.

In an earlier article on the strong typing I've described the typehint mechanism that provides data type enforcement for the values sent to the methods and functions. Unfortunately said implementation does not protect against another problem associated with the dynamic typing of variables: a lack of type enforcement when overwritting value of an existing variable. In order to control the type of data, I decided to introduce to PHP the concept of autoboxing known from other languages such as C# and Java.

He talks briefly about what autoboxing is (wrapping primitive types into objects automatically) and links to a library that can be used to accomplish it. A bit of sample code is included showing how to create an AutoBoxedObject and how to use it in practice on some string values.

0 comments voice your opinion now!
strong data type autoboxing indestructible object


blog comments powered by Disqus

Similar Posts

Gonzalo Ayuso's Blog: Building a simple SQL wrapper with PHP. Part 2.

Pavel Shevaev's Blog: A reliable way to serialize/unserialize objects in PHP

Refulz.com: The __toString() Method - Objects as Strings

Stubbles Blog: Lazy loading of classes stored in a session without __autoload()

DevShed: The Basics of Implementing Adapter Objects with PHP


Community Events

Don't see your event here?
Let us know!


php7 interview extension laravel release laravel5 version community unittest api framework introduction library opinion series development voicesoftheelephpant security language podcast

All content copyright, 2015 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework