Skip to content

Update class constructor docblocks to support specifying an array or a string for $label #867

@nikkifurls

Description

@nikkifurls

Description of the bug

Each constructor has a $label parameter which can be a string or an array.

Currently, docblocks only specify that $label can be a string, making the docblock incorrect.

This causes issues with code quality tools like phpstan.

Steps To Reproduce

  1. Set up phpstan on a project with wordpress-fieldmanager
  2. Register a new Fieldmanager field, specifying an array for $label, e.g.
new \Fieldmanager_Group(
	[
		'name'     => 'settings',
		'children' => [
			'api_key' => new \Fieldmanager_TextField( __( 'API Key', 'wp-plugin' ) ),
		],
	]
);
  1. Run phpstan
  2. Notice errors like Parameter #1 $label of class Fieldmanager_Group constructor expects string, array<string, array<string, Fieldmanager_TextField>|string> given.

Additional Information

No response

Metadata

Metadata

Assignees

Labels

documentationImprovements or additions to documentationenhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions