SlideShare ist ein Scribd-Unternehmen logo
1 von 50
Downloaden Sie, um offline zu lesen
SPL IN THE WILD
The Good, the Bad and the Ugly
If you don’t know SPL
basics, this talk might go
fast for you.

Please rate me -
Feedback is good!
Why SPL?
What SPL?
How SPL?
            A library of standard interfaces,
            classes, and functions designed to
               solve common programming
                problems and allow engine
                        overloading
BUT ISN’T SPL AN EXTENSION?
 SPL is an extension
 SPL is a core extension
 SPL cannot be built shared
 SPL should not be turned off
 SPL is present in PHP since 5.0 (almost 5 years ago)
 As of 5.3, SPL cannot be turned off


         If you don’t have SPL, whoever built your PHP is an idiot.
Don’t let friends use __autoload

AUTOLOAD
AUTOLOAD STACK ERR QUEUE

spl_autoload_register()
spl_autoload_unregister()
spl_autoload_call()
spl_autoload_functions()



 https://gist.github.com/221634
BEWARE THE WEIRDNESS
spl_autoload()
  lowercase
  relative paths
  namespace aware
spl_autoload_extensions()
  include the .
  no spaces in between
  comma separated string
IN THE WILD

Vanilla Forums
  https://github.com/vanillaforums/Garden
  https://github.com/vanillaforums/Garden/blob/23
    d46ffec12624738fabb4d1917178b4a7872ffd/libra
    ry/core/functions.general.php
What went wrong where



EXCEPTIONS
EXCEPTION CLASSES


                  LogicException
BadFunctionCall   InvalidArgument    Domain      Length     OutofRange
   Exception         Exception      Exception   Exception    Exception




BadMethodCall
  Exception
EXCEPTION CLASSES



                     RuntimeException




                                                     Unexpected
OutofBounds   Overflow      Range       UnderflowE      Value
 Exception    Exception   Exception      xception
                                                      Exception
IN THE WILD

ZF2
 https://github.com/zendframework/zf2




 http://ralphschindler.com/2010/09/15/exception-best-practices-in-php-5-3
Yes PHP has a file object
           FILES
SPLFILEINFO
 Metadata about a file
 Returned by directory iterators
 Can set your own superclass for splfileinfo/splfileobject


 In the Wild
    phpcmc
        https://github.com/fqqdk/phpcmc/blob/master/tests/p
          hpcmc/micro/PhpLinterTest.php
SPLFILEOBJECT
 Open file pointer
 Extends splfileinfo



In the Wild
   Utils Plugin for CakePHP
        https://github.com/CakeDC/utils/blob/master/Mo
          del/Behavior/CsvImportBehavior.php
Magic objects oh my

ARRAYS AS OBJECTS
SPECIFICALLY ARRAYOBJECT
 Implements ArrayAccess (with references)
 Implements Countable
 Implements IteratorAggregate
 Implements Serializable (since 5.3.0)
 And other methods that arrays can use (but not all)


 In the Wild
    Rapide Framework
       https://github.com/Hanse/rapide-
         framework/blob/master/lib/Rapide/Utility/ArrayObject.php
Magic and organization

INTERFACES
QUICK TANGENT
Traversable
   (none)
Iterator
   https://github.com/tyohan/WordPress-MVC-
    Framework/blob/11c4c550bf95bed9b142efa46200c9433
    0350105/TPostList.php
IteratorAggregate
   https://github.com/lox/pheasant/blob/d3f4b0806eceb81e
    0351a45d98eb1506134e6b56/lib/Pheasant/Identity.php
MORE CORE INTERFACES
ArrayAccess
   https://github.com/tidal/PEIP/blob/master/src/event/PEIP_
    Event.php
Serializable
   https://github.com/shizzard/RAPIClient/blob/master/Help
    er/Storage.php
Closure
   Do not use (seriously)
SPL - COUNTABLE
 Interface meaning “you can count me”
 Can be put on any class
 Makes count() magical
 Note this is NOT the same as iterator_count()




 https://github.com/ysbaddaden/php5-
  redis/blob/master/lib/Redis/Servers.php
ITERATOR INTERFACES
 Outer Iterator
 Inner Iterator
 Seekable Iterator


 For examples, we’ll look at the iterator classes
SPLSUBJECT SPLOBSERVER
 Are you implementing the observer pattern in your code?
 Do you intend to have other people use your code/library in some way?
 Are you implementing something LIKE the observer pattern?


 In the Wild
    EmailLabs_Sync (SplSubject)
        https://github.com/sankovicmarko/EmailLabs_Sync/blob/master/li
         brary/EmailLabs/Logger.php
    Frapi
       https://github.com/frapi/frapi/blob/master/src/frapi/library/PEAR/
         HTTP/Request2/Observer/Log.php
Take a Drink …

ITERATORS
(RECURSIVE)FILTERITERATOR
 Abstract Class
 Has one method that must be implemented – accept – which should
  return true or false
 Highly useful for many types of iteration
 https://github.com/nishimura/laiz/blob/master/laiz/builder/AutoIncludeFil
  ter.php
 https://github.com/ralphschindler/PHPTools/blob/master/library/PHPToo
  ls/Namespacer/RecursiveFilterIterator.php



     FilterIterator      OuterIterator        Iterator          Traversable
(RECURSIVE)ITERATORITERATOR
 Regular Class
 Stick in something that implements traversable
 Instant Iterator
 https://github.com/halfnelson/LINQ4PHP/blob/master/Iterators/Transfor
  mIterator.php
 https://github.com/symfony/symfony/blob/master/src/Symfony/Compone
  nt/Finder/Iterator/DepthRangeFilterIterator.php




     IteratorIterator   OuterIterator        Iterator        Traversable
(RECURSIVE)ARRAYITERATOR
 Regular Class
 Iterates an array – OR the public properties of an object! (neat trick –
  dirty trick)
 https://github.com/diggin/Diggin_Service_Wedata/blob/master/src/Diggin
  /Service/Wedata/Items.php
 https://github.com/Respect/Validation/blob/master/library/Respect/Valida
  tion/ExceptionIterator.php




ArrayIter         SeekableI                                        ArrayAccess
                                  Iterator        Traversable     and Countable
  ator             terator                                             too!
APPENDITERATOR
 Keep stacking more iterators on the end with append


 https://github.com/WebToad/FashionPolice/blob/master/libs/Nette/Utils/
  Finder.php




     ParentIterator    OuterIterator        Iterator          Traversable
LIMITITERATOR
 Regular Class
 Like mysql’s limit – pick your range and offset and foreach away!


 https://github.com/jasir/ComponentTreePanel/blob/master/ComponentT
  reePanel.php




     LimitIterator      OuterIterator         Iterator          Traversable
FILESYSTEMITERATOR
 Extends directory iterator
 Lets you choose how to get data (just string names possible)


 https://github.com/KnpLabs/Gaufrette/blob/master/tests/Gaufrette/Adap
  ter/LocalTest.php




    FileSystemIterator   DirectoryIterator    Iterator           Traversable
(RECURSIVE)CACHINGITERATOR
   Regular Class
   Manages another iterator by checking whether it has more elements
      each time using a hasNext() method


   https://github.com/bshaffer/Donate-
      Nashville/blob/master/plugins/sfPhpExcelPlugin/lib/PHPExcel/PHPExcel/
      Worksheet/RowIterator.php


   CachingIterator            OuterIterator                   Iterator              Traversable



RecursiveCach        CachingIterator          OuterIterator              Iterator           Traversable
 ingIterator
(RECURSIVE)DIRECTORYITERATOR
 Regular Class
 Walk a Directory


 https://github.com/quentinhill/curator/blob/master/Curator/Project.php
 https://github.com/spidee/PHP-
  Framework/blob/master/libs/Smarty/sysplugins/smarty_internal_utility.p
  hp



   DirectoryIterator    SplFIieInfo         Iterator          Traversable




    RecursiveDirectoryIteerator                 DirectoryIterator
RECURSIVETREEITERATOR
 Regular Class
 Can create an ascii graphic tree (seriously…)
 https://github.com/Respect/Validation/blob/master/library/Respect/Valida
  tion/Exceptions/AbstractNestedException.php




RecursiveTr    RecursiveItera
                                OuterIterator     Iterator       Traversable
 eeIterator     torIterator
(RECURSIVE)REGEXITERATOR
 Regular Class
 Filter an iterator by a regex
 Pick how you want it to match


 https://github.com/felipensp/php-
  tools/blob/master/bughunter/bughunter.php
 https://github.com/lgunsch/victorycms-
  core/blob/master/lib/utilities/Vcms-FileUtils.php


   RegexIterator       FilterIterator        Iterator      Traversable




   RecursiveRegexIteerator                       RegexIterator
EMPTY AND INFINITE ITERATORS
 In the Wild – EmptyIterator
  https://github.com/evilgeny/bob/blob/master/romir/projects/libraries/Bar
  code/Mapper.class.php
 Infinite? Really only useful for testing




 EmptyIterator                     Iterator              Traversable


   InfiniteIterator    IteratorIterator       Iterator        Traversable
MORE EXIST
 ParentIterator
 NoRewindIterator
 MultipleIterator
 GlobIterator
 CallbackFilterIterator
 RecursiveCallbackFilterIterator
New ways of managing data

DATASTRUCTURES
DOUBLYLINKEDLISTS – CS LESSON
 ordered collection of values
 linked to each element before it
 linked to each element after it
 “doubly linked”




 PHP datastructure – a php object with a doublylinkedlist stored inside it
SPLDOUBLYLINKEDLIST
 Don’t use this
 Yes, that’s a terrible thing to say – but this is really nothing more then a
  “base class” with little to recommend on its own
 Has a doublylinkedlist from C underneath instead of a hashtable – if you
  know what that means you may find a real use for this (I have not)


 https://github.com/osebboy/Notification/blob/master/src/Notification/Di
  spatcher.php
SPLSTACK
 Data is in LIFO


 Anything you need to iterate a lot
 Even cooler? Turn on the mode that will autodelete each item as you
  process it


 Any Queue you need to push stuff onto and deal with in LIFO order


 https://github.com/rsesek/phalanx/blob/master/tasks/task_pump.php
SPLQUEUE
 Data is in FIFO


 Anything you need to iterate a lot
 Even cooler? Turn on the mode that will autodelete each item as you
  process it

 Any Queue you need to push stuff onto and deal with in LIFO order


 https://github.com/matthewshafer/fauxThread/blob/master/src/fauxThre
  adPool.php
HEAP – QUICK CS LESSON
 comparison function used to compare the new element to other
  elements
 element is placed according to functions return value
 underlying algorithm does it with minimal comparisons




 PHP datastructure – a php object with a heap stored inside it
USING SPLHEAP
 This is an abstract class
 You need to compare elements




 https://github.com/ckwalsh/LibSprite
 https://github.com/ckwalsh/LibSprite/blob/master/src/php5_3/CKWalsh/
  LibSprite/Util/Block/Heap/Width.php
 https://github.com/ckwalsh/LibSprite/blob/master/src/php5_3/CKWalsh/
  LibSprite/Packer/GreedyHeap.php
SPLMINHEAP, SPLMAXHEAP
 These are concrete heap implementations, designed to grab the lowest
  possible value out, or the highest possible




 https://github.com/tobyS/php-
  snippets/blob/master/datastructures/bottom_k.php
 https://github.com/stormbreakerbg/A---A-Star--pathfinding-class-in-
  PHP/blob/master/AStarWithHeap.php
SPLPRIORITYQUEUE
 Uses heap internally
 Is non-deterministic when identical priorities are used




 https://github.com/ss23/DeBot/blob/master/core/SplFIFOPriorityQueue.
  php
SPLFIXEDARRAY
 You have a large amount of data, you know the final size, you need to
  stick it into an array
 You’re not going to expand it past the final size
 This is not a small amount of data
 You might need it in non-sequential order but can handle having only
  integers for keys


 https://github.com/cboden/gClient/blob/master/lib/gClient/Calendar/Cal
  endar.php
SPLOBJECTSTORAGE

This can be used two ways
   Objects can be keys in an array (with two
    values)
   As a Set (with one value)



 https://github.com/greggles/epm_project_management/blob/master/Que
  ryPath/CssEventHandler.php
WHAT DO YOU WANT TO SEE IN SPL?


More standard interface?
More datastructures?
  trees?
  graphs?
More iterators? really? more?
GET INVOLVED

http://edit.php.net
Blog posts
Articles
Use SPL in the wild
CONTACT ME

 http://emsmith.net
 https://joind.in/6228
 auroraeosrose@gmail.com
 IRC – freenode – auroraeosrose
 #coapp and others

Weitere ähnliche Inhalte

Was ist angesagt? (20)

Cross platform php
Cross platform phpCross platform php
Cross platform php
 
Introduction to Perl
Introduction to PerlIntroduction to Perl
Introduction to Perl
 
Understanding PHP objects
Understanding PHP objectsUnderstanding PHP objects
Understanding PHP objects
 
IO Streams, Files and Directories
IO Streams, Files and DirectoriesIO Streams, Files and Directories
IO Streams, Files and Directories
 
PHP7 is coming
PHP7 is comingPHP7 is coming
PHP7 is coming
 
Anatomy of a reusable module
Anatomy of a reusable moduleAnatomy of a reusable module
Anatomy of a reusable module
 
Building Custom PHP Extensions
Building Custom PHP ExtensionsBuilding Custom PHP Extensions
Building Custom PHP Extensions
 
Php on Windows
Php on WindowsPhp on Windows
Php on Windows
 
Hacking with hhvm
Hacking with hhvmHacking with hhvm
Hacking with hhvm
 
Power of Puppet 4
Power of Puppet 4Power of Puppet 4
Power of Puppet 4
 
Doing It Wrong with Puppet -
Doing It Wrong with Puppet - Doing It Wrong with Puppet -
Doing It Wrong with Puppet -
 
Puppet @ Seat
Puppet @ SeatPuppet @ Seat
Puppet @ Seat
 
Php in 2013 (Web-5 2013 conference)
Php in 2013 (Web-5 2013 conference)Php in 2013 (Web-5 2013 conference)
Php in 2013 (Web-5 2013 conference)
 
Zephir - A Wind of Change for writing PHP extensions
Zephir - A Wind of Change for writing PHP extensionsZephir - A Wind of Change for writing PHP extensions
Zephir - A Wind of Change for writing PHP extensions
 
Yapc::NA::2009 - Command Line Perl
Yapc::NA::2009 - Command Line PerlYapc::NA::2009 - Command Line Perl
Yapc::NA::2009 - Command Line Perl
 
Puppet modules for Fun and Profit
Puppet modules for Fun and ProfitPuppet modules for Fun and Profit
Puppet modules for Fun and Profit
 
PHP5.5 is Here
PHP5.5 is HerePHP5.5 is Here
PHP5.5 is Here
 
Ant
Ant Ant
Ant
 
Programming in Computational Biology
Programming in Computational BiologyProgramming in Computational Biology
Programming in Computational Biology
 
Writing and using php streams and sockets
Writing and using php streams and socketsWriting and using php streams and sockets
Writing and using php streams and sockets
 

Andere mochten auch

TECHINASIA Singapore 2015: Philippine Market Expansion Track by Christian Bes...
TECHINASIA Singapore 2015: Philippine Market Expansion Track by Christian Bes...TECHINASIA Singapore 2015: Philippine Market Expansion Track by Christian Bes...
TECHINASIA Singapore 2015: Philippine Market Expansion Track by Christian Bes...KickstartPH
 
Bizarre Foods of the World
Bizarre Foods of the WorldBizarre Foods of the World
Bizarre Foods of the WorldBrandon T. Luong
 
Creative mornings DXB: The future of #Robots
Creative mornings DXB: The future of #RobotsCreative mornings DXB: The future of #Robots
Creative mornings DXB: The future of #RobotsJose Berengueres
 
Dr. vbn sarma shradhanjali
Dr. vbn sarma shradhanjaliDr. vbn sarma shradhanjali
Dr. vbn sarma shradhanjaliRajendra Nimje
 
SDP - Kymmenen työllisyystoimea
SDP - Kymmenen työllisyystoimeaSDP - Kymmenen työllisyystoimea
SDP - Kymmenen työllisyystoimeaSDP
 
Digital Transformation in Governments
Digital Transformation in GovernmentsDigital Transformation in Governments
Digital Transformation in GovernmentsScopernia
 
Facts about Tuscany
Facts about TuscanyFacts about Tuscany
Facts about TuscanyLinda Meyers
 
Top 25 Places to Visit in 2015: Europe
Top 25 Places to Visit in 2015: EuropeTop 25 Places to Visit in 2015: Europe
Top 25 Places to Visit in 2015: EuropeTravcoa
 
Keep Learning - How Can We Enable & Facilitate This
Keep Learning - How Can We Enable & Facilitate This Keep Learning - How Can We Enable & Facilitate This
Keep Learning - How Can We Enable & Facilitate This Upside Learning Solutions
 
Motor division of nervous system
Motor division of nervous systemMotor division of nervous system
Motor division of nervous systemAbino David
 
10 things you should do in Italy
10 things you should do in Italy10 things you should do in Italy
10 things you should do in ItalyLinda Meyers
 
Digital Government Transformation: The journey to government’s digital future
Digital Government Transformation: The journey to government’s digital futureDigital Government Transformation: The journey to government’s digital future
Digital Government Transformation: The journey to government’s digital futureDeloitte United States
 
Recruitment and selection
Recruitment  and selectionRecruitment  and selection
Recruitment and selectionAditya Kumar
 
Sensing Happiness talk for Accessible Bristol 31 March 2015
Sensing Happiness talk for Accessible Bristol 31 March 2015Sensing Happiness talk for Accessible Bristol 31 March 2015
Sensing Happiness talk for Accessible Bristol 31 March 2015Acuity Design
 
Leadership
LeadershipLeadership
Leadershipachard1
 

Andere mochten auch (20)

Ingles 24 07-2015
Ingles 24 07-2015Ingles 24 07-2015
Ingles 24 07-2015
 
composite functions
composite functionscomposite functions
composite functions
 
TECHINASIA Singapore 2015: Philippine Market Expansion Track by Christian Bes...
TECHINASIA Singapore 2015: Philippine Market Expansion Track by Christian Bes...TECHINASIA Singapore 2015: Philippine Market Expansion Track by Christian Bes...
TECHINASIA Singapore 2015: Philippine Market Expansion Track by Christian Bes...
 
Bizarre Foods of the World
Bizarre Foods of the WorldBizarre Foods of the World
Bizarre Foods of the World
 
Creative mornings DXB: The future of #Robots
Creative mornings DXB: The future of #RobotsCreative mornings DXB: The future of #Robots
Creative mornings DXB: The future of #Robots
 
Dr. vbn sarma shradhanjali
Dr. vbn sarma shradhanjaliDr. vbn sarma shradhanjali
Dr. vbn sarma shradhanjali
 
Ss lugares onde se reza
Ss  lugares onde se rezaSs  lugares onde se reza
Ss lugares onde se reza
 
SDP - Kymmenen työllisyystoimea
SDP - Kymmenen työllisyystoimeaSDP - Kymmenen työllisyystoimea
SDP - Kymmenen työllisyystoimea
 
Digital Transformation in Governments
Digital Transformation in GovernmentsDigital Transformation in Governments
Digital Transformation in Governments
 
Facts about Tuscany
Facts about TuscanyFacts about Tuscany
Facts about Tuscany
 
Top 25 Places to Visit in 2015: Europe
Top 25 Places to Visit in 2015: EuropeTop 25 Places to Visit in 2015: Europe
Top 25 Places to Visit in 2015: Europe
 
Keep Learning - How Can We Enable & Facilitate This
Keep Learning - How Can We Enable & Facilitate This Keep Learning - How Can We Enable & Facilitate This
Keep Learning - How Can We Enable & Facilitate This
 
Motor division of nervous system
Motor division of nervous systemMotor division of nervous system
Motor division of nervous system
 
10 things you should do in Italy
10 things you should do in Italy10 things you should do in Italy
10 things you should do in Italy
 
Native, Hybrid, Web Apps?
Native, Hybrid, Web Apps? Native, Hybrid, Web Apps?
Native, Hybrid, Web Apps?
 
Leadership Ppt
Leadership PptLeadership Ppt
Leadership Ppt
 
Digital Government Transformation: The journey to government’s digital future
Digital Government Transformation: The journey to government’s digital futureDigital Government Transformation: The journey to government’s digital future
Digital Government Transformation: The journey to government’s digital future
 
Recruitment and selection
Recruitment  and selectionRecruitment  and selection
Recruitment and selection
 
Sensing Happiness talk for Accessible Bristol 31 March 2015
Sensing Happiness talk for Accessible Bristol 31 March 2015Sensing Happiness talk for Accessible Bristol 31 March 2015
Sensing Happiness talk for Accessible Bristol 31 March 2015
 
Leadership
LeadershipLeadership
Leadership
 

Ähnlich wie Spl in the wild

Spl in the wild - zendcon2012
Spl in the wild - zendcon2012Spl in the wild - zendcon2012
Spl in the wild - zendcon2012Elizabeth Smith
 
Using spl tools in your code
Using spl tools in your codeUsing spl tools in your code
Using spl tools in your codeElizabeth Smith
 
PHP 7 - A look at the future
PHP 7 - A look at the futurePHP 7 - A look at the future
PHP 7 - A look at the futureRadu Murzea
 
PHP7 - A look at the future
PHP7 - A look at the futurePHP7 - A look at the future
PHP7 - A look at the futureRadu Murzea
 
JDD 2016 - Grzegorz Rozniecki - Java 8 What Could Possibly Go Wrong
JDD 2016 - Grzegorz Rozniecki - Java 8 What Could Possibly Go WrongJDD 2016 - Grzegorz Rozniecki - Java 8 What Could Possibly Go Wrong
JDD 2016 - Grzegorz Rozniecki - Java 8 What Could Possibly Go WrongPROIDEA
 
Looping the Loop with SPL Iterators
Looping the Loop with SPL IteratorsLooping the Loop with SPL Iterators
Looping the Loop with SPL IteratorsMark Baker
 
Php extensions workshop
Php extensions workshopPhp extensions workshop
Php extensions workshopjulien pauli
 
Php 7 compliance workshop singapore
Php 7 compliance workshop singaporePhp 7 compliance workshop singapore
Php 7 compliance workshop singaporeDamien Seguy
 
Php Extensions for Dummies
Php Extensions for DummiesPhp Extensions for Dummies
Php Extensions for DummiesElizabeth Smith
 
An Introduction to SPL, the Standard PHP Library
An Introduction to SPL, the Standard PHP LibraryAn Introduction to SPL, the Standard PHP Library
An Introduction to SPL, the Standard PHP LibraryRobin Fernandes
 
Living With Legacy Code
Living With Legacy CodeLiving With Legacy Code
Living With Legacy CodeRowan Merewood
 
Java Libraries You Can’t Afford to Miss
Java Libraries You Can’t Afford to MissJava Libraries You Can’t Afford to Miss
Java Libraries You Can’t Afford to MissAndres Almiray
 
Php7 extensions workshop
Php7 extensions workshopPhp7 extensions workshop
Php7 extensions workshopjulien pauli
 
How to Reverse Engineer Web Applications
How to Reverse Engineer Web ApplicationsHow to Reverse Engineer Web Applications
How to Reverse Engineer Web ApplicationsJarrod Overson
 
PHP 8: What's New and Changed
PHP 8: What's New and ChangedPHP 8: What's New and Changed
PHP 8: What's New and ChangedAyesh Karunaratne
 
Patterns in Python
Patterns in PythonPatterns in Python
Patterns in Pythondn
 

Ähnlich wie Spl in the wild (20)

Spl in the wild - zendcon2012
Spl in the wild - zendcon2012Spl in the wild - zendcon2012
Spl in the wild - zendcon2012
 
Using spl tools in your code
Using spl tools in your codeUsing spl tools in your code
Using spl tools in your code
 
Php extensions
Php extensionsPhp extensions
Php extensions
 
Php extensions
Php extensionsPhp extensions
Php extensions
 
PHP 7 - A look at the future
PHP 7 - A look at the futurePHP 7 - A look at the future
PHP 7 - A look at the future
 
PHP7 - A look at the future
PHP7 - A look at the futurePHP7 - A look at the future
PHP7 - A look at the future
 
PHP 5
PHP 5PHP 5
PHP 5
 
JDD 2016 - Grzegorz Rozniecki - Java 8 What Could Possibly Go Wrong
JDD 2016 - Grzegorz Rozniecki - Java 8 What Could Possibly Go WrongJDD 2016 - Grzegorz Rozniecki - Java 8 What Could Possibly Go Wrong
JDD 2016 - Grzegorz Rozniecki - Java 8 What Could Possibly Go Wrong
 
Looping the Loop with SPL Iterators
Looping the Loop with SPL IteratorsLooping the Loop with SPL Iterators
Looping the Loop with SPL Iterators
 
Php extensions workshop
Php extensions workshopPhp extensions workshop
Php extensions workshop
 
Php 7 compliance workshop singapore
Php 7 compliance workshop singaporePhp 7 compliance workshop singapore
Php 7 compliance workshop singapore
 
Php extensions
Php extensionsPhp extensions
Php extensions
 
Php Extensions for Dummies
Php Extensions for DummiesPhp Extensions for Dummies
Php Extensions for Dummies
 
An Introduction to SPL, the Standard PHP Library
An Introduction to SPL, the Standard PHP LibraryAn Introduction to SPL, the Standard PHP Library
An Introduction to SPL, the Standard PHP Library
 
Living With Legacy Code
Living With Legacy CodeLiving With Legacy Code
Living With Legacy Code
 
Java Libraries You Can’t Afford to Miss
Java Libraries You Can’t Afford to MissJava Libraries You Can’t Afford to Miss
Java Libraries You Can’t Afford to Miss
 
Php7 extensions workshop
Php7 extensions workshopPhp7 extensions workshop
Php7 extensions workshop
 
How to Reverse Engineer Web Applications
How to Reverse Engineer Web ApplicationsHow to Reverse Engineer Web Applications
How to Reverse Engineer Web Applications
 
PHP 8: What's New and Changed
PHP 8: What's New and ChangedPHP 8: What's New and Changed
PHP 8: What's New and Changed
 
Patterns in Python
Patterns in PythonPatterns in Python
Patterns in Python
 

Mehr von Elizabeth Smith

Database theory and modeling
Database theory and modelingDatabase theory and modeling
Database theory and modelingElizabeth Smith
 
Taming the resource tiger
Taming the resource tigerTaming the resource tiger
Taming the resource tigerElizabeth Smith
 
Taming the resource tiger
Taming the resource tigerTaming the resource tiger
Taming the resource tigerElizabeth Smith
 
Php internal architecture
Php internal architecturePhp internal architecture
Php internal architectureElizabeth Smith
 
Taming the tiger - pnwphp
Taming the tiger - pnwphpTaming the tiger - pnwphp
Taming the tiger - pnwphpElizabeth Smith
 
Security is not a feature
Security is not a featureSecurity is not a feature
Security is not a featureElizabeth Smith
 
Mentoring developers-php benelux-2014
Mentoring developers-php benelux-2014Mentoring developers-php benelux-2014
Mentoring developers-php benelux-2014Elizabeth Smith
 
Socket programming with php
Socket programming with phpSocket programming with php
Socket programming with phpElizabeth Smith
 
Mentoring developers - Zendcon 2012
Mentoring developers - Zendcon 2012Mentoring developers - Zendcon 2012
Mentoring developers - Zendcon 2012Elizabeth Smith
 
Event and Signal Driven Programming Zendcon 2012
Event and Signal Driven Programming Zendcon 2012Event and Signal Driven Programming Zendcon 2012
Event and Signal Driven Programming Zendcon 2012Elizabeth Smith
 
Event and signal driven programming
Event and signal driven programmingEvent and signal driven programming
Event and signal driven programmingElizabeth Smith
 

Mehr von Elizabeth Smith (20)

Welcome to the internet
Welcome to the internetWelcome to the internet
Welcome to the internet
 
Database theory and modeling
Database theory and modelingDatabase theory and modeling
Database theory and modeling
 
Taming the resource tiger
Taming the resource tigerTaming the resource tiger
Taming the resource tiger
 
Modern sql
Modern sqlModern sql
Modern sql
 
Taming the resource tiger
Taming the resource tigerTaming the resource tiger
Taming the resource tiger
 
Php internal architecture
Php internal architecturePhp internal architecture
Php internal architecture
 
Taming the tiger - pnwphp
Taming the tiger - pnwphpTaming the tiger - pnwphp
Taming the tiger - pnwphp
 
Php’s guts
Php’s gutsPhp’s guts
Php’s guts
 
Lexing and parsing
Lexing and parsingLexing and parsing
Lexing and parsing
 
Security is not a feature
Security is not a featureSecurity is not a feature
Security is not a feature
 
Using unicode with php
Using unicode with phpUsing unicode with php
Using unicode with php
 
Mentoring developers-php benelux-2014
Mentoring developers-php benelux-2014Mentoring developers-php benelux-2014
Mentoring developers-php benelux-2014
 
Using unicode with php
Using unicode with phpUsing unicode with php
Using unicode with php
 
Socket programming with php
Socket programming with phpSocket programming with php
Socket programming with php
 
Mentoring developers
Mentoring developersMentoring developers
Mentoring developers
 
Do the mentor thing
Do the mentor thingDo the mentor thing
Do the mentor thing
 
Mentoring developers - Zendcon 2012
Mentoring developers - Zendcon 2012Mentoring developers - Zendcon 2012
Mentoring developers - Zendcon 2012
 
Event and Signal Driven Programming Zendcon 2012
Event and Signal Driven Programming Zendcon 2012Event and Signal Driven Programming Zendcon 2012
Event and Signal Driven Programming Zendcon 2012
 
Mentoring developers
Mentoring developersMentoring developers
Mentoring developers
 
Event and signal driven programming
Event and signal driven programmingEvent and signal driven programming
Event and signal driven programming
 

Kürzlich hochgeladen

TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 

Kürzlich hochgeladen (20)

TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 

Spl in the wild

  • 1. SPL IN THE WILD The Good, the Bad and the Ugly
  • 2. If you don’t know SPL basics, this talk might go fast for you. Please rate me - Feedback is good!
  • 3. Why SPL? What SPL? How SPL? A library of standard interfaces, classes, and functions designed to solve common programming problems and allow engine overloading
  • 4. BUT ISN’T SPL AN EXTENSION?  SPL is an extension  SPL is a core extension  SPL cannot be built shared  SPL should not be turned off  SPL is present in PHP since 5.0 (almost 5 years ago)  As of 5.3, SPL cannot be turned off If you don’t have SPL, whoever built your PHP is an idiot.
  • 5. Don’t let friends use __autoload AUTOLOAD
  • 6. AUTOLOAD STACK ERR QUEUE spl_autoload_register() spl_autoload_unregister() spl_autoload_call() spl_autoload_functions()  https://gist.github.com/221634
  • 7. BEWARE THE WEIRDNESS spl_autoload() lowercase relative paths namespace aware spl_autoload_extensions() include the . no spaces in between comma separated string
  • 8. IN THE WILD Vanilla Forums https://github.com/vanillaforums/Garden https://github.com/vanillaforums/Garden/blob/23 d46ffec12624738fabb4d1917178b4a7872ffd/libra ry/core/functions.general.php
  • 9. What went wrong where EXCEPTIONS
  • 10. EXCEPTION CLASSES LogicException BadFunctionCall InvalidArgument Domain Length OutofRange Exception Exception Exception Exception Exception BadMethodCall Exception
  • 11. EXCEPTION CLASSES RuntimeException Unexpected OutofBounds Overflow Range UnderflowE Value Exception Exception Exception xception Exception
  • 12. IN THE WILD ZF2 https://github.com/zendframework/zf2 http://ralphschindler.com/2010/09/15/exception-best-practices-in-php-5-3
  • 13. Yes PHP has a file object FILES
  • 14. SPLFILEINFO  Metadata about a file  Returned by directory iterators  Can set your own superclass for splfileinfo/splfileobject  In the Wild  phpcmc  https://github.com/fqqdk/phpcmc/blob/master/tests/p hpcmc/micro/PhpLinterTest.php
  • 15. SPLFILEOBJECT  Open file pointer  Extends splfileinfo In the Wild Utils Plugin for CakePHP  https://github.com/CakeDC/utils/blob/master/Mo del/Behavior/CsvImportBehavior.php
  • 16. Magic objects oh my ARRAYS AS OBJECTS
  • 17. SPECIFICALLY ARRAYOBJECT  Implements ArrayAccess (with references)  Implements Countable  Implements IteratorAggregate  Implements Serializable (since 5.3.0)  And other methods that arrays can use (but not all)  In the Wild  Rapide Framework  https://github.com/Hanse/rapide- framework/blob/master/lib/Rapide/Utility/ArrayObject.php
  • 19. QUICK TANGENT Traversable  (none) Iterator  https://github.com/tyohan/WordPress-MVC- Framework/blob/11c4c550bf95bed9b142efa46200c9433 0350105/TPostList.php IteratorAggregate  https://github.com/lox/pheasant/blob/d3f4b0806eceb81e 0351a45d98eb1506134e6b56/lib/Pheasant/Identity.php
  • 20. MORE CORE INTERFACES ArrayAccess  https://github.com/tidal/PEIP/blob/master/src/event/PEIP_ Event.php Serializable  https://github.com/shizzard/RAPIClient/blob/master/Help er/Storage.php Closure  Do not use (seriously)
  • 21. SPL - COUNTABLE  Interface meaning “you can count me”  Can be put on any class  Makes count() magical  Note this is NOT the same as iterator_count()  https://github.com/ysbaddaden/php5- redis/blob/master/lib/Redis/Servers.php
  • 22. ITERATOR INTERFACES  Outer Iterator  Inner Iterator  Seekable Iterator  For examples, we’ll look at the iterator classes
  • 23. SPLSUBJECT SPLOBSERVER  Are you implementing the observer pattern in your code?  Do you intend to have other people use your code/library in some way?  Are you implementing something LIKE the observer pattern?  In the Wild  EmailLabs_Sync (SplSubject)  https://github.com/sankovicmarko/EmailLabs_Sync/blob/master/li brary/EmailLabs/Logger.php  Frapi  https://github.com/frapi/frapi/blob/master/src/frapi/library/PEAR/ HTTP/Request2/Observer/Log.php
  • 24. Take a Drink … ITERATORS
  • 25. (RECURSIVE)FILTERITERATOR  Abstract Class  Has one method that must be implemented – accept – which should return true or false  Highly useful for many types of iteration  https://github.com/nishimura/laiz/blob/master/laiz/builder/AutoIncludeFil ter.php  https://github.com/ralphschindler/PHPTools/blob/master/library/PHPToo ls/Namespacer/RecursiveFilterIterator.php FilterIterator OuterIterator Iterator Traversable
  • 26. (RECURSIVE)ITERATORITERATOR  Regular Class  Stick in something that implements traversable  Instant Iterator  https://github.com/halfnelson/LINQ4PHP/blob/master/Iterators/Transfor mIterator.php  https://github.com/symfony/symfony/blob/master/src/Symfony/Compone nt/Finder/Iterator/DepthRangeFilterIterator.php IteratorIterator OuterIterator Iterator Traversable
  • 27. (RECURSIVE)ARRAYITERATOR  Regular Class  Iterates an array – OR the public properties of an object! (neat trick – dirty trick)  https://github.com/diggin/Diggin_Service_Wedata/blob/master/src/Diggin /Service/Wedata/Items.php  https://github.com/Respect/Validation/blob/master/library/Respect/Valida tion/ExceptionIterator.php ArrayIter SeekableI ArrayAccess Iterator Traversable and Countable ator terator too!
  • 28. APPENDITERATOR  Keep stacking more iterators on the end with append  https://github.com/WebToad/FashionPolice/blob/master/libs/Nette/Utils/ Finder.php ParentIterator OuterIterator Iterator Traversable
  • 29. LIMITITERATOR  Regular Class  Like mysql’s limit – pick your range and offset and foreach away!  https://github.com/jasir/ComponentTreePanel/blob/master/ComponentT reePanel.php LimitIterator OuterIterator Iterator Traversable
  • 30. FILESYSTEMITERATOR  Extends directory iterator  Lets you choose how to get data (just string names possible)  https://github.com/KnpLabs/Gaufrette/blob/master/tests/Gaufrette/Adap ter/LocalTest.php FileSystemIterator DirectoryIterator Iterator Traversable
  • 31. (RECURSIVE)CACHINGITERATOR  Regular Class  Manages another iterator by checking whether it has more elements each time using a hasNext() method  https://github.com/bshaffer/Donate- Nashville/blob/master/plugins/sfPhpExcelPlugin/lib/PHPExcel/PHPExcel/ Worksheet/RowIterator.php CachingIterator OuterIterator Iterator Traversable RecursiveCach CachingIterator OuterIterator Iterator Traversable ingIterator
  • 32. (RECURSIVE)DIRECTORYITERATOR  Regular Class  Walk a Directory  https://github.com/quentinhill/curator/blob/master/Curator/Project.php  https://github.com/spidee/PHP- Framework/blob/master/libs/Smarty/sysplugins/smarty_internal_utility.p hp DirectoryIterator SplFIieInfo Iterator Traversable RecursiveDirectoryIteerator DirectoryIterator
  • 33. RECURSIVETREEITERATOR  Regular Class  Can create an ascii graphic tree (seriously…)  https://github.com/Respect/Validation/blob/master/library/Respect/Valida tion/Exceptions/AbstractNestedException.php RecursiveTr RecursiveItera OuterIterator Iterator Traversable eeIterator torIterator
  • 34. (RECURSIVE)REGEXITERATOR  Regular Class  Filter an iterator by a regex  Pick how you want it to match  https://github.com/felipensp/php- tools/blob/master/bughunter/bughunter.php  https://github.com/lgunsch/victorycms- core/blob/master/lib/utilities/Vcms-FileUtils.php RegexIterator FilterIterator Iterator Traversable RecursiveRegexIteerator RegexIterator
  • 35. EMPTY AND INFINITE ITERATORS  In the Wild – EmptyIterator https://github.com/evilgeny/bob/blob/master/romir/projects/libraries/Bar code/Mapper.class.php  Infinite? Really only useful for testing EmptyIterator Iterator Traversable InfiniteIterator IteratorIterator Iterator Traversable
  • 36. MORE EXIST  ParentIterator  NoRewindIterator  MultipleIterator  GlobIterator  CallbackFilterIterator  RecursiveCallbackFilterIterator
  • 37. New ways of managing data DATASTRUCTURES
  • 38. DOUBLYLINKEDLISTS – CS LESSON  ordered collection of values  linked to each element before it  linked to each element after it  “doubly linked”  PHP datastructure – a php object with a doublylinkedlist stored inside it
  • 39. SPLDOUBLYLINKEDLIST  Don’t use this  Yes, that’s a terrible thing to say – but this is really nothing more then a “base class” with little to recommend on its own  Has a doublylinkedlist from C underneath instead of a hashtable – if you know what that means you may find a real use for this (I have not)  https://github.com/osebboy/Notification/blob/master/src/Notification/Di spatcher.php
  • 40. SPLSTACK  Data is in LIFO  Anything you need to iterate a lot  Even cooler? Turn on the mode that will autodelete each item as you process it  Any Queue you need to push stuff onto and deal with in LIFO order  https://github.com/rsesek/phalanx/blob/master/tasks/task_pump.php
  • 41. SPLQUEUE  Data is in FIFO  Anything you need to iterate a lot  Even cooler? Turn on the mode that will autodelete each item as you process it  Any Queue you need to push stuff onto and deal with in LIFO order  https://github.com/matthewshafer/fauxThread/blob/master/src/fauxThre adPool.php
  • 42. HEAP – QUICK CS LESSON  comparison function used to compare the new element to other elements  element is placed according to functions return value  underlying algorithm does it with minimal comparisons  PHP datastructure – a php object with a heap stored inside it
  • 43. USING SPLHEAP  This is an abstract class  You need to compare elements  https://github.com/ckwalsh/LibSprite  https://github.com/ckwalsh/LibSprite/blob/master/src/php5_3/CKWalsh/ LibSprite/Util/Block/Heap/Width.php  https://github.com/ckwalsh/LibSprite/blob/master/src/php5_3/CKWalsh/ LibSprite/Packer/GreedyHeap.php
  • 44. SPLMINHEAP, SPLMAXHEAP  These are concrete heap implementations, designed to grab the lowest possible value out, or the highest possible  https://github.com/tobyS/php- snippets/blob/master/datastructures/bottom_k.php  https://github.com/stormbreakerbg/A---A-Star--pathfinding-class-in- PHP/blob/master/AStarWithHeap.php
  • 45. SPLPRIORITYQUEUE  Uses heap internally  Is non-deterministic when identical priorities are used  https://github.com/ss23/DeBot/blob/master/core/SplFIFOPriorityQueue. php
  • 46. SPLFIXEDARRAY  You have a large amount of data, you know the final size, you need to stick it into an array  You’re not going to expand it past the final size  This is not a small amount of data  You might need it in non-sequential order but can handle having only integers for keys  https://github.com/cboden/gClient/blob/master/lib/gClient/Calendar/Cal endar.php
  • 47. SPLOBJECTSTORAGE This can be used two ways Objects can be keys in an array (with two values) As a Set (with one value)  https://github.com/greggles/epm_project_management/blob/master/Que ryPath/CssEventHandler.php
  • 48. WHAT DO YOU WANT TO SEE IN SPL? More standard interface? More datastructures? trees? graphs? More iterators? really? more?
  • 50. CONTACT ME  http://emsmith.net  https://joind.in/6228  auroraeosrose@gmail.com  IRC – freenode – auroraeosrose  #coapp and others