Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6626445
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:53:36+00:00 2026-05-25T21:53:36+00:00

Background: I am creating a method addAll that adds all of the values passed

  • 0

Background:
I am creating a method addAll that adds all of the values passed to the method to my class. Here’s what I was thinking:

public function addAll() {
    if(func_num_args()===0) {
        throw new BadMethodCallException(get_class($this).'::addAll() must have arguments.');
    }

    $args = func_get_args();

    foreach($args as &$arg) {
        $this->add($arg);
    }
}

And it works great. Then I got to documenting it with phpDocumentor:

/**
 * @param mixed ... All of the values to add.
 */

. . . but I don’t have a name for my @param because, frankly, it doesn’t exist.

Question: How do I construct and define something like this?


Since I want it to have at least one value passed in, I came up with this but am unsure:

/**
 * @param mixed $value,... All of the values to add.
 */
public function addAll($value) {
    $args = func_get_args();

    foreach($args as &$arg) {
        $this->add($arg);
    }
}

It seems so wrong because $value is never directly used. . .

Also, I already have add which adds one, so shouldn’t addAll semantically require at least two parameters? What would you recommend for defining and documenting that?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T21:53:36+00:00Added an answer on May 25, 2026 at 9:53 pm

    Answer: use an @example tag.

    I also changed my setup, and it seems to be the best way to utilize what PHP has to offer without forfeiting usability:

    /**
     * @param mixed $values Either an array of values to add, or multiple values
     * @example
     * 
     * $object->add('1');
     * $object->add('1','2');
     * $object->add(array('1','2'));
     * 
     * @return type 
     */
    public function add($values=null) {
        if (is_array($values)) {
            return $this->addAll($values);
        } else {
            return $this->addAll(func_get_args());
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was trying out the method of creating a background music for a java
I am creating a class that is used as an portal to read, insert
hey I'm creating an app with two switches on it that change the background
A little background: I'm creating a set of adapters to allow communication with mobile
I am creating a simple gradient background by drawing a quad as follows: glMatrixMode
I creating a program which send newsletter with a background image. It works fine
Background Right now, I'm creating a multiple-predictor linear model and generating diagnostic plots to
I'm creating a datagridview transparent //I got the parent background image Bitmap parentBackGround =
Background : I'm currently, for my University, creating some simple apps showcasing the possible
I am adding a custom background image to my navigation bar by creating an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.