ajthinking/archetype
Laravel package for defining and instantiating “archetypes” to generate consistent model data and fixtures. Helps standardize defaults, variations, and seeding/test setup by composing reusable templates for your app’s entities.
Thanks to @jasonvarga ✨
Please see #77 for details.
This feature provides a BuilderFactory instance when passing a closure to insertStmt.
PHPFile::make()->class(\App\Dummy::class)
->astQuery()
->class()
->insertStmt(function(BuilderFactory $builder) {
return $builder->property('someProperty')->getNode();
})
->commit()
->end()
->preview();
When astQuery()->insertStmt(.....) had no matches to operate on, it added the node to the end of the file. This was fixed by adding a guard clause.
withEach methodPHPFile::make() now return a Maker instance. Makers allows creating files from a template, for instance:
PHPFile::make()->file('scripts.php')
PHPFile::make()->class(\App\Car::class)
We can implement a custom maker and attaching it to the property "maker" on the File instance.
File methods no longer rely on obscure __call magic, instead minimal stubs are implemented to explicitly forward calls to the corresponding endpoint class.
Avoid Str macros which may cause segmentation fault in statamic/cms
Fixes bug when creating classes.
Now we can create classes like so:
namespace App;
PHPFile::make()->class(Models\Car::class);
PHPFile::make()->class(\App\Models\Car::class);
PHPFile::make()->class('App\Models\Car');
PHPFile::make()->class('\App\Models\Car');
PHPFile::make()->class('app/Models/Car.php');
all of these will write two app/Models/Car.php.
$astQuery->classMethod('name->name')
$this->file->astQuery()
->class()
->property()
->where->propertyProperty('name->name')->is($key)->get()
->replace(function() {
...
};
get(). Results are evaluated to see if they have results (considered thruty) or empty (falsy).Dumpable proxies on astQueryBuilder for ->dd->something() and ->dump->anotherfromString can allow pseudo phpPHPFile::addMissingTags()->fromString('$hey = 1337')
In order to tighten this package up and consolidate around primary features, we will drop the following incomplete/broken functionality:
Furthermore,
TestablePHPFile facade.TestableAstQueryBuilder facade.remove() ability for class constants.In order to tighten this package up and consolidate around primary features, we will drop the following:
Most of these feature were incomplete or otherwise broken. A side effect of this is we will no longer be depending on doctrine/dbal.
All tests are moved to pest and many uses an internal TestablePHPFile facade.
Better array formatting 🎉 🎉 🎉 Works for newly created, loaded or modified code.
class Finally
{
protected $empty = [];
protected $one = [
'one',
];
protected $moreThanOne = [
'one',
'two',
];
}
Thanks for spotting this @jackmcdade
Fixes an issue with doctrine/dbal
:bug: Fix bug in notInOperator by @ordago
🔒 Allow doctrine/dbal ^2.10 by @WorldSeso7
:white_check_mark: Bump dependecies, typos and test updates
Include nikic/php-parser as a dependency, don't assume it is included elsewhere.
Rename mismatching class name/file name. Fixes #15
Don't use facade aliases which might be unavailable.
Fix class resolving when using archetype schema in remote context
Archetype v0.1.0 :rocket:In the astQuery(), you can now access general classes/objects/structures with ->methodCall() or similar. To enter a property, simply use ->stmts without ()
How can I help you explore Laravel packages today?