Basic types

From The Smartest Wiki
Jump to: navigation, search

The basic types are a variety of different classes and formats that are used to store and represent data in useful ways. The types are partly based on the classic computer-science notion of a Type system, and to some extent PHP's own loose types, but there are significant differences in the classification of Smartest's basic types.

About the basic types

PHP is a loosely typed language, which makes it easy to program.

However, this also means that the data you store and manipulate in it is essentially all the same.

To build rich websites quickly, without having to write lots of code, it makes sense to build on the idea of a type system and give every kind of information specific functionalities that will help the developer.

Why, for instance, should colour values simply be stored as a string? A colour should be treated and understood as such: the user in Smartest should be able to input it with a colour picker, and similarly the developer ought to be able to output it as hex or rgb, or even convert between hex and rgb, without any need for more coding.

To help users and developers alike to treat different types of data appropriately, Smartest has a variety of different data types. The Basic types in Smartest are a set of classes that correspond to simple values. Basic types, though they can always be stored in a database, never correspond to records in a database - only single fields. Every basic type implements the SmartestStorableValue interface, which means it can be converted to and from a string for storage in a database without any chance of loss or damage.

Some of the basic types have also been extended into extended types.

The types listed on this page are all classes - that is, this is a page about classes. For a list of Smartest's built in data types, some of which share classes, see Data types.



An integer from 0-255. Not used much in a user-facing capacity, but is important in other classes, such as SmartestRgbColor.

See Smartest8BitInteger for full details and offsets.


In many ways this is just a wrapper for a real array, and away from templates there's little point in using it, but any array-like data that goes to the presentation layer shouldgo in a SmartestArray object so that its offsets are available.

Importantly, SmartestArray uses SPL interfaces so that it responds to count() and foreach() like an ordinary array. Note however that behaviour with empty() does not work. !count() is a reliable replacement. The count of a SmartestArray object is available via the SmartestArray._count offset.

See SmartestArray for full details and offsets.


Stores a True or False value, which can be formatted and tested for in a variety of ways.

See SmartestBoolean for full details and offsets.


Stores two SmartestDateTime objects, one for the beginning and one for the end of the event.

See SmartestCalendarEvent for full details and offsets.


Effectively a wrapper for a UNIX time stamp, in a resolution of seconds. Can also be used to refer only to days, months or years.

See SmartestDateTime for full details and offsets.


Contains a URL to some web address, almost always to one on another website (note that internal links are handled differently).

See SmartestExternalUrl for full details and offsets.


Corresponds to an actual image file, usually stored in the Public/Resources/Images/ folder on the server. This is importantly distinct from a SmartestAsset object which corresponds to any file that has been imported into Smartest. A SmartestAsset object contains and uses a SmartestImage object when it refers to an image.

See SmartestImage for full details and offsets.


Stores any numeric value, whether an integer or a float.

See SmartestNumeric for full details and offsets.


A SmartestParameterHolder is similar to SmartestArray in some ways, but is not iterable and does not have order. A bit like a plain javascript object or hash, it stores named parameters, which are accessible via offsets derived from the parameter names.

See SmartestParameterHolder for full details and offsets.


Stores a 24-bit RGB colour. Uses three Smartest8BitInteger objects to store red, green and blue channels. Offsets can be used to format and represent the colour in a variety of ways.

See SmartestRgbColor for full details and offsets.


Used for when a vertical and horizontal position need to be collected and stored together, and will eventually use a form input that makes more sense to a user than simply two numeric inputs.

See SmartestScreenPosition for full details and offsets.


Holds a string, but has a wide array of offsets for reformatting and displaying in templates, which makes it very useful.

See SmartestString for full details and offsets.