You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the AnonymousMigrations task the closing ; will appear in the wrong location if } appears after the class (in a comment section for example).
We sometimes document migrations with a data sample that could be imported into the table. We put it in a comment after the migration class because it will contain multiple records, sometimes expressed as json.
AnonymousMigrations currently replaces the last } in the file with }; to close the anonymous migration class return statement, but ends up changing the comment and the migration statement remains in error.
This modified fixture makes the test fail
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class SimpleMigration extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('videos', function (Blueprint $table) {
$table->integer('runtime')->nullable();
});
}
}
/* a closing bracket in a comment here can confuse the parsing
{ id: 1, name: "Doug" }
*/
It can be argued that comments belong before the code, not after, and that shift is not expected to cover such a case.
However, I made a fixture and failing test, then a change that parses the class and puts the ; right after it in the file. If wanted, I will gladly submit a PR (be warned it would be my first PR )
The text was updated successfully, but these errors were encountered:
Yes, feel free to issue PR. I think this is pretty light on a parsing. It just uses string manipulation. However, the better thing to do would probably be to parse the class and look at the closing offset. Or use the PhpFile class to find the closing brace.
Issue:
In the AnonymousMigrations task the closing
;
will appear in the wrong location if}
appears after the class (in a comment section for example).We sometimes document migrations with a data sample that could be imported into the table. We put it in a comment after the migration class because it will contain multiple records, sometimes expressed as json.
AnonymousMigrations currently replaces the last } in the file with }; to close the anonymous migration class return statement, but ends up changing the comment and the migration statement remains in error.
This modified fixture makes the test fail
It can be argued that comments belong before the code, not after, and that shift is not expected to cover such a case.
However, I made a fixture and failing test, then a change that parses the class and puts the ; right after it in the file. If wanted, I will gladly submit a PR (be warned it would be my first PR )
The text was updated successfully, but these errors were encountered: