@@ -369,9 +369,9 @@ private function askForNextField(ConsoleStyle $io, array $fields, string $entity
369369 $ defaultType = 'datetime_immutable ' ;
370370 } elseif ('_id ' === $ suffix ) {
371371 $ defaultType = 'integer ' ;
372- } elseif (0 === strpos ($ snakeCasedField , 'is_ ' )) {
372+ } elseif (str_starts_with ($ snakeCasedField , 'is_ ' )) {
373373 $ defaultType = 'boolean ' ;
374- } elseif (0 === strpos ($ snakeCasedField , 'has_ ' )) {
374+ } elseif (str_starts_with ($ snakeCasedField , 'has_ ' )) {
375375 $ defaultType = 'boolean ' ;
376376 } elseif ('uuid ' === $ snakeCasedField ) {
377377 $ defaultType = 'uuid ' ;
@@ -479,9 +479,9 @@ private function printAvailableTypes(ConsoleStyle $io): void
479479 if (\is_string ($ subTypes ) && $ subTypes ) {
480480 $ line .= sprintf (' (%s) ' , $ subTypes );
481481 } elseif (\is_array ($ subTypes ) && !empty ($ subTypes )) {
482- $ line .= sprintf (' (or %s) ' , implode (', ' , array_map (function ( $ subType ) {
483- return sprintf ('<comment>%s</comment> ' , $ subType );
484- }, $ subTypes )) );
482+ $ line .= sprintf (' (or %s) ' , implode (', ' , array_map (
483+ static fn ( $ subType ) => sprintf ('<comment>%s</comment> ' , $ subType ), $ subTypes ))
484+ );
485485
486486 foreach ($ subTypes as $ subType ) {
487487 unset($ allTypes [$ subType ]);
@@ -508,9 +508,7 @@ private function printAvailableTypes(ConsoleStyle $io): void
508508
509509 $ io ->writeln ('<info>Other Types</info> ' );
510510 // empty the values
511- $ allTypes = array_map (function () {
512- return [];
513- }, $ allTypes );
511+ $ allTypes = array_map (static fn () => [], $ allTypes );
514512 $ printSection ($ allTypes );
515513 }
516514
@@ -551,31 +549,27 @@ private function askRelationDetails(ConsoleStyle $io, string $generatedEntityCla
551549 $ type = $ this ->askRelationType ($ io , $ generatedEntityClass , $ targetEntityClass );
552550 }
553551
554- $ askFieldName = function (string $ targetClass , string $ defaultValue ) use ($ io ) {
555- return $ io ->ask (
556- sprintf ('New field name inside %s ' , Str::getShortClassName ($ targetClass )),
557- $ defaultValue ,
558- function ($ name ) use ($ targetClass ) {
559- // it's still *possible* to create duplicate properties - by
560- // trying to generate the same property 2 times during the
561- // same make:entity run. property_exists() only knows about
562- // properties that *originally* existed on this class.
563- if (property_exists ($ targetClass , $ name )) {
564- throw new \InvalidArgumentException (sprintf ('The "%s" class already has a "%s" property. ' , $ targetClass , $ name ));
565- }
566-
567- return Validator::validateDoctrineFieldName ($ name , $ this ->doctrineHelper ->getRegistry ());
552+ $ askFieldName = fn (string $ targetClass , string $ defaultValue ) => $ io ->ask (
553+ sprintf ('New field name inside %s ' , Str::getShortClassName ($ targetClass )),
554+ $ defaultValue ,
555+ function ($ name ) use ($ targetClass ) {
556+ // it's still *possible* to create duplicate properties - by
557+ // trying to generate the same property 2 times during the
558+ // same make:entity run. property_exists() only knows about
559+ // properties that *originally* existed on this class.
560+ if (property_exists ($ targetClass , $ name )) {
561+ throw new \InvalidArgumentException (sprintf ('The "%s" class already has a "%s" property. ' , $ targetClass , $ name ));
568562 }
569- );
570- };
571563
572- $ askIsNullable = static function (string $ propertyName , string $ targetClass ) use ($ io ) {
573- return $ io ->confirm (sprintf (
574- 'Is the <comment>%s</comment>.<comment>%s</comment> property allowed to be null (nullable)? ' ,
575- Str::getShortClassName ($ targetClass ),
576- $ propertyName
577- ));
578- };
564+ return Validator::validateDoctrineFieldName ($ name , $ this ->doctrineHelper ->getRegistry ());
565+ }
566+ );
567+
568+ $ askIsNullable = static fn (string $ propertyName , string $ targetClass ) => $ io ->confirm (sprintf (
569+ 'Is the <comment>%s</comment>.<comment>%s</comment> property allowed to be null (nullable)? ' ,
570+ Str::getShortClassName ($ targetClass ),
571+ $ propertyName
572+ ));
579573
580574 $ askOrphanRemoval = static function (string $ owningClass , string $ inverseClass ) use ($ io ) {
581575 $ io ->text ([
@@ -841,9 +835,7 @@ private function getPropertyNames(string $class): array
841835
842836 $ reflClass = new \ReflectionClass ($ class );
843837
844- return array_map (static function (\ReflectionProperty $ prop ) {
845- return $ prop ->getName ();
846- }, $ reflClass ->getProperties ());
838+ return array_map (static fn (\ReflectionProperty $ prop ) => $ prop ->getName (), $ reflClass ->getProperties ());
847839 }
848840
849841 /** @legacy Drop when Annotations are no longer supported */
0 commit comments