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

php[architect]:
The Case for Generics in PHP
Dec 04, 2018 @ 20:30:55

The php[architect] site has posted an article pulled from their November 2018 issue providing a case for generics in PHP.

To elucidate their merit, we will look at how they might fit within the evolution of PHP’s type system to put us in a position to write more robust software:

“How can I signal that my method will return a Collection of User objects? And why would I want to do that?”

The article starts with a look at generics in other languages and how they're handled (such as Java and C#). From there they shift over to PHP, giving a code sample of a class that is typed to only accept one kind of value for its constructor. They provide an update for this that would work in PHP 7.4 (with typed properties) and how with the help of generics it would be simpler to define a more dynamic type requirement, allowing for more generalized class descriptions.

tagged: phparchitect article november2018 issue generics tutorial php74

Link: https://www.phparch.com/2018/11/the-case-for-generics-in-php/

php[architect]:
November 2018 Issue Release - Generics and Project Success
Nov 01, 2018 @ 14:25:56

php[architect] magazine has released their latest issue for November 2018: Generics and Project Success. In this issue they feature articles like:

  • "The Case for Generics in PHP" by Chris Holland
  • "Maintaining Laravel Applications" by Jason McCreary
  • "Getting Started With Php? Let’s Start the Right Way!" by Junior Grossi
  • "How to Knock Down Any Project in Ten Steps" by Pawe? Lewtak

The usual columns are all returning including Joe Ferguson continuing his series on creating packages, Eric Mann covering five security risks to look for in a code review, and James Titcumb with some resources you can use to continue "leveling up" in your development career.

If you want to "try before you buy", they're also offering a free article, "The Case for Generics in PHP" by Chris Holland. You can pick up a copy of your own directly from the php[architect] site or subscribe to their print or PDF versions!

tagged: phparchitect magazine nov2018 issue release generics project success

Link: https://www.phparch.com/2018/10/generics-project-success/

Stitcher.io:
PHP Generics and why we need them
May 23, 2017 @ 14:48:56

On the Stitcher.io blog there's a post that's advocating the addition of a feature to the core PHP language that several others have: generics. The basic idea behind generics is to provide functionality that allows the definition of entity types that can be reused as a default (like a "collection" generic that could be used instead of a base collection class).

In today's blog post we'll explore some common problems with arrays in PHP. All the problems and issues listed could be solved with a pending RFC which adds generics to PHP. We won't explore in too much detail what generics are. But at the end of this read, you should have a good idea as to why they are useful, and why we really want them in PHP. So without further ado, let's dive into the subject.

They start off with a common use case in PHP: a collection of blog posts and getting information from them. There's no guarantee that the contents of the set are always post objects leading to specific checks to ensure data quality before use. The post then uses a common example from PHP, the creation of a collection class to handle a set of objects and then showing how (with pseudo-code as generics aren't in the language) how that same functionality might look defined as a generic collection instead.

tagged: generics language feature example rfc collection

Link: https://www.stitcher.io/blog/php-generics-and-why-we-need-them

PHPClasses.org:
Lately in PHP, Episode 28 - Should PHP be Copying the Java features and practices?
Nov 13, 2012 @ 19:31:04

PHPClasses.org has posted the latest episode of their "Lately in PHP" podcast series - episode #29, Should PHP be Copying the Java features and practices?.

Particularly since version 5.0, PHP has been copying many of Java features and practices of Java programmers. This means that if Java programmers practices tend to be bureacratic and less productive, PHP programmers that use those features or adopt those Java practices may also become less productive. This was one of the main topics discussed by Manuel Lemos and Michael Kimsal on the episode 29 of the Lately in PHP podcast.

There's also a bit of discussion about adding generics to PHP and using OAuth in PHP. You can listen to this latest episode either via the in-page player, by downloading the mp3 or by watching the video of the recording. You can also subscribe to their feed to get the latest in the podcast series.

tagged: latelyinphp podcast java functionality oauth generics

Link:


Trending Topics: