wrk-flow / larastrict Goto Github PK
View Code? Open in Web Editor NEWOpinionated extension of a Laravel framework to help you build type safe, testable and reusable code.
Home Page: https://larastrict.com
License: MIT License
Opinionated extension of a Laravel framework to help you build type safe, testable and reusable code.
Home Page: https://larastrict.com
License: MIT License
From larastran rule:
If we are using closures, we can generate from closure typehints expected result and input parameters:
expectation would not create Closure $createData
but
public readonly NotebookPageEntity $createDataPage,
public readonly NotebookFinancePageEntity $createDataResultResult,
Assert::assertEquals($createData($expectation->createDataResultPage), $expectation->createDataResult, $message);
For easy copy of hook params to implementation
/**
* @template TModel of \Illuminate\Database\Eloquent\Model
* @template TEntry
*/
Assert class is missing \
in namespace for objects in default new
statement
Assert class - documentation does not use full namespace for object return class
When using commands we have actions / services that logs different states. It would be great to prevent logging this to a log file (when using docker all logs are visible to user using stderr) when using command (called by user, not in schedule) and output it directly to user
Problem is detecting if the command was called via artisan.
At this moment there is partially working solution.
When using get/set methods, it would be great to wrap cacheMeService in entity/class that would pass $key
and strategy
.
This would prevent bugs when using set
with incorrect strategy
Proposals:
/** @var CacheEntity<string> $cache */
$cache = new CacheEntity(key: $key, strategy: CacheMeStrategy::Memory);
$value = $cache->get($this->cacheMeService);
$cache->set($this->cacheMeService, $value);
/** @var CacheEntity<string> $cache */
$cache = new CacheEntity(service: $this->cacheMeService, key: $key, strategy: CacheMeStrategy::Memory);
// construct with service
$cache = $this->cacheMeService->cache($key, strategy: CacheMeStrategy::Memory)
$value = $cache->get();
$cache->set($value);
@h4kuna what do you prefer?
For quality improvements would be great to patch Laravel framework using cweagans/composer-patches
The patches would be in separate composer package to make it reusable without using larastrict (and maybe optional?).
If $message
is used in method, incorrect value will be used.
Add custom attribute and use one for automatically to (re)generate Assert classes and Expectation classes.
for latest PHPUnit data provider
Example of a mock:
/**
* @extends ExpectationCallMap<GetTourIdForObjectTypeBoardQueryContractExpectation>
*/
class GetTourIdForObjectTypeBoardTestQuery extends ExpectationCallMap implements GetTourIdForObjectTypeBoardQueryContract
{
public function execute(int $objectId, int $objectTypeId, int $boardId): ?int
{
$expectation = $this->getExpectation();
Assert::assertEquals($expectation->objectId, $objectId);
Assert::assertEquals($expectation->objectTypeId, $objectTypeId);
Assert::assertEquals($expectation->boardId, $boardId);
}
}
To allow accessing data from "implementation" objects and passing it to expectation object.
221 Parameter $first of method
Illuminate\Database\Eloquent\Builder<App\Models\Notebook\Notebook>::leftJoinSub()
expects Closure|string, Illuminate\Database\Query\Expression given.
223 Parameter $second of method
Illuminate\Database\Eloquent\Builder<App\Models\Notebook\Notebook>::leftJoinSub()
expects string|null, Illuminate\Database\Query\Expression given.
make:migration-job RemoveCommissionFromLastPaymentJob
command that would make:
final class RemoveCommissionFromLastPaymentJob extends AbstractUniqueJob
{
public function uniqueId(): string
{
return 'remove-commission-from-last-payment';
}
public function handle(): void {
}
}
make:migration remove_commissiom_from_last_payment_job
return new class extends Migration
{
public function up(): void
{
dispatch(new RemoveCommissionFromLastPaymentJob());
}
public function down(): void
{
}
};
If you are using any interface
for "setting" service provider.
When using where between with a datetime column there can be a bug. We should try to detect it.
string|RoutePrefixEntity
Delete older than 60 days
php artisan queue:prune-failed --hours=1440
@template
will be used for setTransformOnEntry@template
will be used for onEntry/onChunkThis will be breaking change in PHPStan reports.
Syntax will be:
ChunkedModelQueryResult<MyModel,MyEntity>
ChunkedModelQueryResult<MyModel,MyModel >
Now we have to manually:
$bindings
and adding Contract => implementation bindingphp artisan make:expectation {path}
Use combination of rector + Laravel command?
based on discussion with @h4kuna
To ensure that calls are asserted.
Check if AssertExpectationTestCase or AssertExpectationManagerTrait is used.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.