Skip to content

Method which returns list<T> #12

@nikophil

Description

@nikophil

Hello,

We're typing a lot our arrays as list<T>

usually we're using array_values() to ensure we have a list. But it feels really cumbersome to do something like array_values(listOf($foo)->toArray())

Would you be OK to add something like this?

// \Noctud\Collection\Collection

	/**
	 * Convert to a primitive PHP array list preserving iteration order.
	 *
	 * @return list<E>
	 */
	#[NoDiscard]
	public function toArrayList(): array;

not sure about the method's name. In doctrine/collection it is called getValues()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions