
Principles
What is NOLOH?
What's so Bad About Markup?
Development and Philosophy
Features
Syntactical Sugars
Multiple Inheritance
Bookmarks and NOLOH
User State Management
Search Engine Friendly
Getting Started
PHP and NOLOH Syntax
Hello World
Constructors
Installing NOLOH
Crash Course
NOLOH and CSS
Layout in NOLOH
Databases
Data::$Links
Events in NOLOH
Moving and Resizing Your Objects
Multiple Inheritance
Bookmarks and NOLOH
Data Binding
Advanced Topics
Custom Events
Clientside Functions
Syntactic Sugars
Syntactical Sugars
Cascading
Coding Guidelines
Best Practices
NOLOH Naming ConventionsNOLOH has numerous syntactical sugars, many of which were laboriously implemented to provide an easy and intuitive experience. Some syntactical sugars allow for a consistent use of PHP syntax, while others are more notable and are mentioned in this document.
Any function whose name is prefixed with "Get" or "Set" can alternatively be called as a property, provided that there is no class variable of the same name which can also be accessed. This allows for a developer to write code that responds to retrieving or assigning properties, but keep the simple and easy-to-read notation of variables. This can used for, but is not limited to, validating input, computing live results rather than storing them, or even for overloading the default behavior of some NOLOH properties.
class TestObj extends Panel { private $SomeProperty; function TestObj() { parent::Panel(); } //This is a Get function, that in this case returns the SomeProperty variable of TestObj function GetSomeProperty() { return $this->SomeProperty; } //This is a Set function, that in this case sets the SomeProperty variable of TestObj function SetSomeProperty($someValue) { $this->SomeProperty = $someValue; } }
So, if you had an instance of the above TestObj, you could call the GetProperty and SetProperty functions as follows.
$test = new TestObj(); $test ->SomeProperty = 2; $property = $tmpObj->SomeProperty; //this line will set $property to 2; //The ability to call Get and Set functions as properties allows for easy chaining. $property = $test->SomeProperty = 2; //In the above example BOTH $property, and $test's SomeProperty member will be 2
Furthermore, you can even chain these Get or Set Properties as follows:
$test = new TestObj(); $test->SomeProperty = new TestObj(); //You could do the following $test->SomeProperty->SomeProperty = 2; /*The first SomeProperty returns the TestObj you just created. It then sets the SomeProperty member of that TestObj to 2.*/
Similar to an array, NOLOH allows you to use ArrayLists as though they were actual PHP arrays.
$arr = new ArrayList();
You can add to the ArrayList through the Add function
$arr->Add("something");
or you can add as if it were an array.
$arr[] = 2;
or use non-numerical indices
$arr[0] = 2; $arr['idx'] = 2;
This is also true for ArrayLists such as the Controls ArrayList of a Panel. You can do:
$panel = new Panel(); //To add you can do any of the following $panel->Controls->Add(new Button("SomeButton"); $panel->Controls[] = new Button("AnotherButton"); $panel->Controls[0] = new Button("OtherButton"); $panel->Controls['idx'] = new Button("LastButton");
You can immediately see how the above is helpful if you wanted to add via a loop, or through a foreach. If you give the index an identifier such as idx you can immediately retrieve that element through that index rather than having to do a search through the ArrayList.
Consider the following search, which also demonstrates iterating through an ArrayList using a foreach construct:
foreach($panel->Controls as $control) { if($control->Text == "LastButton") { $found = $control; break; } }
Or using a string as an associative index
if(isset($panel->Controls["idx"])) $found = $panel->Controls["idx"];
You can immediately see how the second example is significantly faster than the first. Instead of looping through elements, you can immediately return what you want.






classconstantpropertymethodarticle
