News Feed
Sections




News Archive
feed this:

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

DZone.com:
Closure Object Binding in PHP 5.4
October 28, 2011 @ 08:43:26

In a new post to DZone.com Mitchell Pronschinske looks at closure object binding in PHP 5.4 applications (yes, we know PHP 5.4 isn't released yet). He explains what this is an shows some sample use cases for you to consider in your development.

For the people who read PHP's NEWS file, it's no surprise - but for all who don't here's is probably one of the biggest features of PHP 5.4: Closure Object Support is back. For me it's something I missed the most, when Closures were introduced in PHP 5.3. So I'm very happy, that's finally here (or back). I'm going to tell you about the rocky road which closure object binding support had and show you some simple use cases for it.

The functionality, based on this RFC, lets you more correctly bind closures to objects instead of having to pass the objects into the closure at create time. He includes an example from a Silex framework application and an example that refactors a helper method as a part of rendering a simple template.

0 comments voice your opinion now!
object binding support tutorial template example


Eric Hogue's Blog:
Late Static Binding
April 22, 2011 @ 09:14:34

Eric Hogue has a recent post to his blog looking at one of the more tricky aspects of the latest versions of PHP (the 5.3.x series) - late static binding. In a nutshell, late static binding (LSB) lets static classes and methods work more correctly than before. Eric gets into a bit more detail than that:

It came out almost 2 years ago, but it to me that many programmers around me have no idea about it. Myself, I have learned about it around 6 months ago. The PHP documentation defines late static binding as a way to "reference the called class in a context of static inheritance." This definition didn't really help me the first time I read it. Fortunately, there are more explanations in the documentation, and there are good examples. If you haven't, you should read it.

To clarify, he includes a code snippet showing the use of the "static" keyword to correctly reference a static method. He also includes in interesting bit about when's a good time to use it.

0 comments voice your opinion now!
late static binding lsb tutorial explaination


Alexey Zakhlestins' Blog:
GObject for PHP (new bindings project)
February 24, 2011 @ 08:25:23

In a new post Alexey Zakhlestins talks about a project he's been working on, a part of the split up with PHP-GTK out into separate projects. His part of the group is GObject with has now been moved over to github.

This new PHP extension is called "GObject for PHP", so, my main concern, obviously is building comfortable bridge between GObject objects and PHP's objects. It starts to work, but there's a lot of stuff to be done. Please join the project, if you are interested. We need more hands!

He describes some of the features already in the library - counterparts for parts of the current GObject world in PHP including GType, GSignal and GParamSpec. This is all on the master branch. In his "introspection" branch he's working on the introspection idea the GNOME community has been working towards too.

0 comments voice your opinion now!
phpgtk gobject binding github master introspection


C7Y:
Late Static Binding a practical example
February 12, 2008 @ 15:52:36

Sean Coates has posted a new article today about one of the features that will be included in the next major release of PHP (5.3) - late static bindings.

Late Static Binding (LSB) is a topic that's been brought up numerous times in the past three years in various PHP development discussion circles (and we're finally getting it in PHP 5.3)'"but what does it really do, and why should you care? Here's a simple practical example of how it can greatly simplify your code's design.

He shows its usefulness in an example of how it works, letting classes/objects access static methods, constants and properties of inherited classes (besides their own). His example (using beer, of course) shows how an extended class (Ale) can reference the constant (NAME) in the parent class (Beer). Thanks to a new keyword in PHP 5.3 - "static::" - helps define the difference even clearer.

Check out the rest of the article for a more practical usage too.

0 comments voice your opinion now!
late static binding tutorial example beer


Joshua Thompson's Blog:
Return to Prototype Based Programming in PHP
October 31, 2007 @ 16:38:00

Taking full advantage of the upcoming features in the PHP 5.3.x series (and in PHP6 for that matter), Joshua Thompson has come up with a way to accomplish some prototype-based programming in a PHP application:

With the implementation of the get_called_class() function in PHP, prototype based programming in PHP is possible. The new function is in both PHP5.3 and PHP6 snapshots. So, I went back to the drawing board and came up with a fully capable class. The $this keyword is usable, as well as being able to use the self, parent, and static (new with the late static binding patch) keywords.

Prototype-based programming is (basically) a method where classes aren't prebuilt. Instead they are created on the fly based on other objects and interfaces. Joshua's post is a huge code dump of a prototype class and an example of it in use, dynamically creating two methods and making the three objects available.

0 comments voice your opinion now!
prototype programming object clone interface namespace static binding prototype programming object clone interface namespace static binding


Mike Lively's Blog:
Late static binding....sorta /
September 27, 2007 @ 12:58:00

Mike Lively is happy about one thing - that late static binding (definition) has been committed and will be included with PHP 5.3. Unfortunately, he has a downside too:

The good news is late static binding has been introduced into head and looks like it will be merged into 5.3 before it is released. The horrible news is I really don't think the patch went as far as it needs to.

He talks about the original intention of the functionality (flexible inheritance for static methods/properties/constants) and how it was implemented, but with one small issue - that "static will ALWAYS return the 'resolved' name of the class used to call the current function". He illustrates with a code example showing an extended class returning a static property.

He also mentions two suggestions to help fix this issue:

  • setting the behavior of parent:: such that it forwards the calling class through the next function call.
  • introducing another scope [...] using a new keyword so parent:: could remain the same
1 comment voice your opinion now!
late static binding patch missing functionality parent inheritance late static binding patch missing functionality parent inheritance


Etienne Kneuss' Blog:
Late Static Bindings Explained
September 07, 2007 @ 14:26:00

Etienne Kneuss has a new article posted about and introducing a feature that will be implemented in PHP6 - late static bindings.

Late Static Binding (LSB, yes, not LSD) is an OO feature that is meant to be implemented in PHP 6, and maybe even backported to PHP 5. This article will describe what LSB is, what problems it's supposed to solve and how. The patch this article talks about can be found here: late_static_bindings_take6.patch

Etienne explains what they are and includes several code examples to show how they'll work. There's also a mention of "edge cases" where special circumstances might cause the script to fall back on the "magic" functions (__get, __post, etc).

0 comments voice your opinion now!
late static binding php6 explain introduction example late static binding php6 explain introduction example


LivePipe Blog:
What PHP6 Actually Needs
May 15, 2007 @ 10:13:00

On the LivePipe blog, there's a whishlist that Ryan has posted for some of the things he'd like to see in PHP6.

His list consists of:

  • Closures
  • { } is the new array()
  • Parameter Collection in Functions
  • Late Static Binding
  • Backwards Compatibility

Each is explained, some with code to illustrate.

1 comment voice your opinion now!
php6 need wishlist closures array parameter static binding php6 need wishlist closures array parameter static binding


DevShed:
PHP 5 and Polymorphism
March 07, 2006 @ 07:19:08

From DevShed, there's a more advanced tutorial that might interest PHP developers out there looking for more info on "polymorphism" for their apps.

This article explains what polymorphism is and how it applies to object oriented design in particular. It also explains the pros and cons of polymorphism when working with certain versions of PHP.

They start with a definition on the topic that doesn't seem to help much: "The occurrence of different forms, stages, or types in individual organisms or in organisms of the same species, independent of sexual variations." They do, however, follow that with what it means to programming: "...an interface or base class without regard to an object's concrete class." They also include a simple example (no code, that's later).

With that concept in place, they move to the next step - working with the example to create code that can be used as a reference point. They talk about using a switch to make the script respond differently to different inputs and the lack of "late binding" support in PHP5.

0 comments voice your opinion now!
php5 polymorphism late binding switch php5 polymorphism late binding switch



Community Events





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


language wordpress api library introduction release code podcast series application configure interview threedevsandamaybe unittest list install community laravel developer framework

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