davedevelopment / phpmig

Simple migrations system for php
Other
569 stars 92 forks source link

Validate migration class name. #121

Closed imunew closed 7 years ago

imunew commented 7 years ago

problem

Even if generate command is executed with invalid 'name' argument, migration class is generated.

$ phpmig generate invalid-class
+f ./migrations/20170107182747_invalid-class.php

valid class name

http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.class

A valid class name starts with a letter or underscore, followed by any number of letters, numbers, or underscores. As a regular expression, it would be expressed thus: ^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$.

fix

If AbstractCommand:: migrationToClassName called with invalid class name, throw InvalidArgumentException.

davedevelopment commented 7 years ago

Thanks!