44
55namespace Ock \Testing \Exporter ;
66
7- use Ock \Reflection \ClassReflection ;
8-
97/**
108 * Exports as array suitable for a yaml file.
119 */
@@ -484,10 +482,13 @@ protected function stabilizePath(string $path): string {
484482 * @return array<string, mixed>
485483 */
486484 protected function exportObjectProperties (object $ object , int $ depth , bool $ public = false ): array {
487- $ reflector = new ClassReflection ($ object );
488- $ properties = $ reflector ->getFilteredProperties (static: false , public: $ public ?: null );
485+ $ reflector = new \ ReflectionClass ($ object );
486+ $ properties = $ reflector ->getProperties ( $ public ? \ReflectionProperty:: IS_PUBLIC : null );
489487 $ export = [];
490488 foreach ($ properties as $ property ) {
489+ if ($ property ->isStatic ()) {
490+ continue ;
491+ }
491492 if ($ property ->isInitialized ($ object )) {
492493 $ propertyValue = $ property ->getValue ($ object );
493494 }
@@ -513,10 +514,17 @@ protected function exportObjectProperties(object $object, int $depth, bool $publ
513514 * @return array<string, mixed>
514515 */
515516 protected function exportObjectGetterValues (object $ object , int $ depth ): array {
516- $ reflector = new ClassReflection ($ object );
517+ $ reflector = new \ ReflectionClass ($ object );
517518 $ result = [];
518- foreach ($ reflector ->getFilteredMethods (static: false , public: true , constructor: false ) as $ method ) {
519- if ($ method ->hasRequiredParameters ()
519+ $ methods = $ reflector ->getMethods (\ReflectionMethod::IS_PUBLIC );
520+ foreach ($ methods as $ method ) {
521+ if ($ method ->isConstructor () || $ method ->isStatic ()) {
522+ continue ;
523+ }
524+ if ($ method ->isConstructor ()
525+ || $ method ->isStatic ()
526+ // Skip if the method has required parameters.
527+ || ($ method ->getParameters ()[0 ] ?? NULL )?->isOptional() === false
520528 || (string ) ($ method ->getReturnType () ?? '? ' ) === 'void '
521529 || (string ) ($ method ->getReturnType () ?? '? ' ) === 'never '
522530 || !\preg_match ('#^(get|is|has)[A-Z]# ' , $ method ->name )
0 commit comments