Whats this called when...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Kadanis
Forum Contributor
Posts: 180
Joined: Tue Jun 20, 2006 8:55 am
Location: Dorset, UK
Contact:

Whats this called when...

Post by Kadanis »

Sorry for the obscure title, couldn't think of how to phrase it without running out of room ;)

Basically, I was wondering what you would call the $type variable in the following code. As in $data is an object, $type is a ....... (fill in the blank)

In the code fragment from a class in our application, there are 2 params. 1 is an object from a mysqli_fetch_object method, the other is technically an integer, but actually should be passed one of 3 class constants. Is the var type still an integer, or is there another name for it, in order to reference it back to the constants.

In my old VB6 days, I seem to recall this being a custom ENUM, but not sure if there is anything like that in php.

It's more for curiousity than anything else, as I was writing up the phpDocs and wondered if there was a specific name for this.

Code: Select all

 
 
    const PRESEND = 0;
    const REMAINDER = 1;
    const FULL = 2;
    
    /**
     * Builds an array of packets that require renaming in order to initiate send
     *
     * @param unknown_type $data
     * @param unknown_type $type
     */
    protected function packets_for_rename($data , $type) {
        $packet_array = unserialize($data->packets);
        $campaign_id = $data->CID;
        $template_id = $data->TemplateID;
        
        foreach ($packet_array as $packet_file) {
            if ( strstr($packet_file, $type) ) {        
                $this->packets_for_rename[] = $packet_file;
            }
        }
 
    }
 
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Whats this called when...

Post by Chris Corbyn »

I'm becoming increasingly frustrated with the lack of enum support in PHP but I guess I mustn't grumble given that PHP is a loosely typed language.

It's just documented as "int" yep :) I usually document the parameter as an int, then use @see or @link{} tags to refer users to the class constants I've defined to get those ints.
Post Reply