Skip to content

Commit

Permalink
Update Duster and fix
Browse files Browse the repository at this point in the history
  • Loading branch information
driftingly committed Jan 12, 2024
1 parent 0d6761d commit c91da08
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
6 changes: 5 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"require-dev": {
"orchestra/testbench": "^7.0||^8.0",
"phpunit/phpunit": "^9.5.10||^10.0",
"tightenco/duster": "^2.5"
"tightenco/duster": "^2.7"
},
"autoload": {
"psr-4": {
Expand All @@ -36,5 +36,9 @@
"Parental\\Tests\\": "tests/",
"Database\\Factories\\": "tests/factories/"
}
},
"scripts": {
"lint": "vendor/bin/duster lint",
"fix": "vendor/bin/duster fix"
}
}
27 changes: 13 additions & 14 deletions src/HasParent.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,19 +119,6 @@ public function getClassNameForSerialization(): string
return $this->getParentClass();
}

/**
* Get the class name for Parent Class.
*
* @throws ReflectionException
*/
protected function getParentClass(): string
{
static $parentClassName;

return $parentClassName ?: $parentClassName = (new ReflectionClass($this))->getParentClass()->getName();
}


/**
* Merge the fillable attributes for the model with those of its Parent Class
*
Expand All @@ -146,7 +133,19 @@ public function getFillable()
return $this->fillable;
}
$parentFillable = (new $parentClass)->getFillable();

return array_unique(array_merge($parentFillable, $this->fillable));
}

/**
* Get the class name for Parent Class.
*
* @throws ReflectionException
*/
protected function getParentClass(): string
{
static $parentClassName;

return $parentClassName ?: $parentClassName = (new ReflectionClass($this))->getParentClass()->getName();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class ChildModelFillablesMergeWithParentModelFillablesTest extends TestCase
{
/** @test */
function child_fillables_are_merged_with_parent_fillables()
public function child_fillables_are_merged_with_parent_fillables()
{
$workshop = Workshop::create([
'name' => 'Scaling Laravel',
Expand Down

0 comments on commit c91da08

Please sign in to comment.