Closed ManojKiranA closed 5 years ago
It might be possible to add a method addUses
, but I am dealing with these cases in PHP in a general way array_map([$namespace, 'addUse'], $array)
.
(btw in version < 2.6, this also worked array_map($namespace->addUse, $array)
, but it was deprecated. Perhaps it would not be bad ideat to come it back...)
The current signature is more type-safe. You can always use foreach
if you want to add multiple use statements from array.
Ok Thanks for the reply
And in the recent times as of php 7
namespace App\Models;
--
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
/**
* Class Post
*
* @package App\Models
*/
class Post extends Model
{
use SoftDeletes;
Can also be written as
namespace App\Models;
--
use Illuminate\Database\Eloquent\{ Model, SoftDeletes};
/**
* Class Post
*
* @package App\Models
*/
class Post extends Model
{
use SoftDeletes;
use Illuminate\Database\Eloquent{ Model, SoftDeletes};
@ManojKiranA ad grouped use statements, there is a testing branch https://github.com/nette/php-generator/tree/grouped-uses
can you be more specific or share some code
There is commit that implements grouped uses https://github.com/nette/php-generator/commit/7d49e177def6dd61b7e1d87c47123719ec8743d8
I have been looking for this type of library which helps me lot to generate the code
I am Working with laravel so i have created the base example model for post
And the generated Code is here
And its working fine but i was planning to add multiple
addUse
statment so the code becomed bigger so IT WILL BE FINE IF THEaddUse
method accepts thearray