diff --git a/src/DataObject.php b/src/DataObject.php index 9a824c5..9807b35 100644 --- a/src/DataObject.php +++ b/src/DataObject.php @@ -102,8 +102,8 @@ trait DataObject } /** - * @param array $data - * @param array $rules + * @param array $data + * @param array> $rules */ public static function withValidator(array $data, array $rules): Validator { diff --git a/src/DataObjectServiceProvider.php b/src/DataObjectServiceProvider.php index db0daf9..b92cd00 100644 --- a/src/DataObjectServiceProvider.php +++ b/src/DataObjectServiceProvider.php @@ -15,19 +15,6 @@ class DataObjectServiceProvider extends ServiceProvider public function register(): void { $this->mergeConfigFrom(__DIR__ . '/config/dto.php', 'dto'); - - $registrar = new DataObjectRegistrar($this->app); - - // Register from configured namespaces or manual class list - $config = $this->getConfig(); - - if (!empty($config['classes'])) { - // Manual registration (zero overhead) - $registrar->registerMany($config['classes']); - } elseif (!empty($config['namespaces'])) { - // Automatic namespace scanning - $registrar->registerFromNamespaces($config['namespaces']); - } } /** @@ -35,21 +22,6 @@ class DataObjectServiceProvider extends ServiceProvider */ public function boot(): void { - // Commands will be registered here - } - - /** - * Get DataObject configuration. - * - * @return array{namespaces: string[], classes: class-string[]} - */ - protected function getConfig(): array - { - return config('dataobject', [ - 'namespaces' => [ - 'App\DataObjects', - ], - 'classes' => [], - ]); + // } } diff --git a/tests/DataObjectTest.php b/tests/DataObjectTest.php index 77eed63..9514994 100644 --- a/tests/DataObjectTest.php +++ b/tests/DataObjectTest.php @@ -38,7 +38,7 @@ describe('primitive data test', function () { expect($object->float)->toEqualWithDelta(3.14, 0.0001); expect($object->bool)->toBeTrue(); }); -})->group('primitives'); +}); describe('optional data', function () { it('creates optional rules', function () { @@ -59,7 +59,7 @@ describe('optional data', function () { expect($object->float)->toEqualWithDelta(0.777, 0.0001); expect($object->bool)->toBeFalse(); }); -})->group('optional'); +}); describe('nullable data', function () { it('creates nullable rules', function () { @@ -88,7 +88,7 @@ describe('nullable data', function () { expect($object->string)->toBe('dfg'); expect($object->int)->toBeNull(); }); -})->group('nullable'); +}); describe('reference other DataObject', function () { @@ -105,7 +105,7 @@ describe('reference other DataObject', function () { 'extra.bool' => ['required', 'boolean'], ]); }); -})->group('reference'); +}); describe('primitive array', function () { it('creates array rules', function () { @@ -115,7 +115,7 @@ describe('primitive array', function () { 'values.*' => ['required', 'numeric'], ]); }); -})->group('primitive-array'); +}); describe('object array', function () { @@ -133,7 +133,7 @@ describe('object array', function () { 'values.*.bool' => ['sometimes', 'boolean'], ]); }); -})->group('object-array'); +}); describe('can map input names', function () { @@ -164,7 +164,7 @@ describe('can map input names', function () { expect($object->text)->toBe('xyz'); expect($object->standard)->toBe(1); }); -})->group('input-map'); +}); describe('with mapper object', function () { it('uses mapper', function () { @@ -187,7 +187,7 @@ describe('with mapper object', function () { 'standard' => 1, ]); })->throws(ValidationException::class); -})->group('mapper-object'); +}); test('failed validation throws ValidationException', function () { $object = PrimitiveData::fromArray([ @@ -195,8 +195,7 @@ test('failed validation throws ValidationException', function () { 'float' => 3.14, 'bool' => true, ]); -})->throws(ValidationException::class) -->group('error'); +})->throws(ValidationException::class); test('tries to resolve without mapper', function () { @@ -221,4 +220,4 @@ test('creates collection', function () { expect($object->values->count())->toBe(2); expect($object->values[0]->string)->toBe('x'); expect($object->values[1]->int)->toBeNull(); -})->group('collection'); +});