{"id":16252419,"url":"https://github.com/remarkablemark/rector-laravel-database-expressions","last_synced_at":"2026-04-29T21:33:08.554Z","repository":{"id":213391339,"uuid":"734021593","full_name":"remarkablemark/rector-laravel-database-expressions","owner":"remarkablemark","description":"🐘 Rector Laravel database expressions","archived":false,"fork":false,"pushed_at":"2025-11-24T05:43:56.000Z","size":148,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-11-27T23:46:51.052Z","etag":null,"topics":["codemod","composer","database","expressions","laravel","php","rector","refactoring"],"latest_commit_sha":null,"homepage":"https://packagist.org/packages/remarkablemark/rector-laravel-database-expressions","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/remarkablemark.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":["remarkablemark"],"patreon":"remarkablemark","open_collective":null,"ko_fi":"remarkablemark","tidelift":null,"community_bridge":null,"liberapay":"remarkablemark","issuehunt":null,"otechie":null,"buy_me_a_coffee":"remarkablemark","thanks_dev":"u/gh/remarkablemark","custom":["https://b.remarkabl.org/teespring"]}},"created_at":"2023-12-20T17:10:26.000Z","updated_at":"2025-11-24T05:43:59.000Z","dependencies_parsed_at":"2024-05-06T03:30:23.653Z","dependency_job_id":"6b8e2f0e-e8f3-44fa-a2d9-c476be4b3ee9","html_url":"https://github.com/remarkablemark/rector-laravel-database-expressions","commit_stats":null,"previous_names":["remarkablemark/rector-laravel-database-expressions"],"tags_count":8,"template":false,"template_full_name":"remarkablemark/rector-template","purl":"pkg:github/remarkablemark/rector-laravel-database-expressions","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remarkablemark%2Frector-laravel-database-expressions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remarkablemark%2Frector-laravel-database-expressions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remarkablemark%2Frector-laravel-database-expressions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remarkablemark%2Frector-laravel-database-expressions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/remarkablemark","download_url":"https://codeload.github.com/remarkablemark/rector-laravel-database-expressions/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remarkablemark%2Frector-laravel-database-expressions/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32445165,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-29T20:22:27.477Z","status":"ssl_error","status_checked_at":"2026-04-29T20:22:26.507Z","response_time":110,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["codemod","composer","database","expressions","laravel","php","rector","refactoring"],"created_at":"2024-10-10T15:13:38.330Z","updated_at":"2026-04-29T21:33:08.539Z","avatar_url":"https://github.com/remarkablemark.png","language":"PHP","funding_links":["https://github.com/sponsors/remarkablemark","https://patreon.com/remarkablemark","https://ko-fi.com/remarkablemark","https://liberapay.com/remarkablemark","https://buymeacoffee.com/remarkablemark","https://thanks.dev/u/gh/remarkablemark","https://b.remarkabl.org/teespring"],"categories":[],"sub_categories":[],"readme":"# rector-laravel-database-expressions\n\n[![packagist](https://img.shields.io/packagist/v/remarkablemark/rector-laravel-database-expressions)](https://packagist.org/packages/remarkablemark/rector-laravel-database-expressions)\n[![test](https://github.com/remarkablemark/rector-laravel-database-expressions/actions/workflows/test.yml/badge.svg)](https://github.com/remarkablemark/rector-laravel-database-expressions/actions/workflows/test.yml)\n\n[Rector](https://github.com/rectorphp/rector) to refactor Laravel 10 database expressions.\n\nFrom [Laravel 10](https://laravel.com/docs/10.x/upgrade#database-expressions):\n\n\u003e Database \"expressions\" (typically generated via `DB::raw`) have been rewritten in Laravel 10.x to offer additional functionality in the future. Notably, the grammar's raw string value must now be retrieved via the expression's `getValue(Grammar $grammar)` method. Casting an expression to a string using `(string)` is no longer supported.\n\u003e\n\u003e If your application is manually casting database expressions to strings using `(string)` or invoking the `__toString` method on the expression directly, you should update your code to invoke the `getValue` method instead:\n\u003e\n\u003e ```php\n\u003e use Illuminate\\Support\\Facades\\DB;\n\u003e\n\u003e $expression = DB::raw('select 1');\n\u003e\n\u003e $string = $expression-\u003egetValue(DB::connection()-\u003egetQueryGrammar());\n\u003e ```\n\n## Requirements\n\nPHP \u003e=8.0\n\n## Install\n\nInstall with [Composer](http://getcomposer.org/):\n\n```sh\ncomposer require --dev rector/rector remarkablemark/rector-laravel-database-expressions\n```\n\n## Usage\n\nRegister rule in `rector.php`:\n\n```php\n\u003c?php\n\ndeclare(strict_types=1);\n\nuse Rector\\Config\\RectorConfig;\nuse Remarkablemark\\RectorLaravelDatabaseExpressions\\LaravelDatabaseExpressionsRector;\n\nreturn static function (RectorConfig $rectorConfig): void {\n    $rectorConfig-\u003epaths([\n        __DIR__ . '/app',\n        __DIR__ . '/bootstrap',\n        __DIR__ . '/config',\n        __DIR__ . '/database',\n        __DIR__ . '/public',\n        __DIR__ . '/resources',\n        __DIR__ . '/routes',\n        __DIR__ . '/storage',\n        __DIR__ . '/tests',\n    ]);\n    $rectorConfig-\u003erule(LaravelDatabaseExpressionsRector::class);\n};\n```\n\nSee the diff:\n\n```php\nvendor/bin/rector process --dry-run\n```\n\nApply the rule:\n\n```php\nvendor/bin/rector process\n```\n\nClear the cache and apply the rule:\n\n```php\nvendor/bin/rector process --clear-cache\n```\n\n## Rule\n\n### Before\n\n```php\nDB::select(DB::raw('select 1'));\n```\n\n### After\n\n```php\nDB::select('select 1');\n```\n\n## License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fremarkablemark%2Frector-laravel-database-expressions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fremarkablemark%2Frector-laravel-database-expressions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fremarkablemark%2Frector-laravel-database-expressions/lists"}