From b8b50379c3afa5bfc8eff62c943c66f55e9bf2f1 Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Wed, 10 Jul 2024 23:38:53 +0200 Subject: [PATCH] Get rid of more arrays. --- lib/class-argument-datalist.php | 9 +++++++++ lib/class-hook-datalist.php | 9 +++++++++ lib/class-method-data.php | 2 +- lib/class-method-datalist.php | 9 +++++++++ lib/class-property-datalist.php | 9 +++++++++ lib/runner.php | 25 ++++++++----------------- 6 files changed, 45 insertions(+), 18 deletions(-) create mode 100644 lib/class-argument-datalist.php create mode 100644 lib/class-hook-datalist.php create mode 100644 lib/class-method-datalist.php create mode 100644 lib/class-property-datalist.php diff --git a/lib/class-argument-datalist.php b/lib/class-argument-datalist.php new file mode 100644 index 0000000..30f7001 --- /dev/null +++ b/lib/class-argument-datalist.php @@ -0,0 +1,9 @@ + */ -function export_arguments( array $arguments ) : array { +function export_arguments( array $arguments ) : ArgumentDataList { $output = array(); foreach ( $arguments as $argument ) { @@ -158,15 +156,13 @@ function export_arguments( array $arguments ) : array { ); } - return $output; + return new ArgumentDataList( ...$output ); } /** * @param \phpDocumentor\Reflection\Php\Property[] $properties - * - * @return array */ -function export_properties( array $properties ) : array { +function export_properties( array $properties ) : PropertyDataList { $out = array(); foreach ( $properties as $property ) { @@ -181,19 +177,16 @@ function export_properties( array $properties ) : array { ); } - return $out; + return new PropertyDataList( ...$out ); } /** * @param \phpDocumentor\Reflection\Php\Method[] $methods - * - * @return array */ -function export_methods( array $methods ) : array { +function export_methods( array $methods ) : MethodDataList { $output = array(); foreach ( $methods as $method ) { - $namespace = get_namespace( $method->getFqsen() ); $output[] = new MethodData( @@ -210,15 +203,13 @@ function export_methods( array $methods ) : array { ); } - return $output; + return new MethodDataList( ...$output ); } /** * @param HooksMetadata $hooks_metadata - * - * @return array */ -function export_hooks( HooksMetadata $hooks_metadata ) : array { +function export_hooks( HooksMetadata $hooks_metadata ) : HookDataList { $out = array(); /** @var Hook $hook */ @@ -233,7 +224,7 @@ function export_hooks( HooksMetadata $hooks_metadata ) : array { ); } - return $out; + return new HookDataList( ...$out ); } /**