SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: Syntax help

Hybrid View

  1. #1
    SitePoint Addict Banana Man's Avatar
    Join Date
    Dec 2005
    Posts
    391
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Syntax help

    Hi,

    I'm looking at some source code and dont understand some of the syntax. In the example below what does the "Storage\StorageInterface" section mean?

    Code:
    public function setStorage(Storage\StorageInterface $storage) {
    
    }
    Thanks!

  2. #2
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,118
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    Storage is a namespace, the slash is a separator, and StorageInterface is likely an Interface defined elsewhere in the system (it is an object).

    The string as a whole is placing a constraint on the parameter $storage stating it should be of type StorageInterface which is located in the Storage namespace.

    Hope that helps.

  3. #3
    Community Advisor bronze trophy
    fretburner's Avatar
    Join Date
    Apr 2013
    Location
    Brazil
    Posts
    1,395
    Mentioned
    45 Post(s)
    Tagged
    12 Thread(s)
    Hi Banana Man (your real name's not Eric, is it?)

    Storage\StorageInterface is a type hint, it tells the method setStorage that the parameter $storage must be an object that implements an interface called Storage\StorageInterface.

  4. #4
    SitePoint Addict Banana Man's Avatar
    Join Date
    Dec 2005
    Posts
    391
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by fretburner View Post
    Hi Banana Man (your real name's not Eric, is it?)
    Sorry, i cant reveal my true identity!

    Thanks for the responses. That clarifies it for me.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •