Générer des interfaces PHP

Existe-t-il un outil pour générer l'interface php des classs existantes? Il serait bon d'avoir un outil comme la création automatique de getter / setbe Netbeans mais pour les interfaces.

Pour l'utilisation programmée, il existe InterfaceDistiller qui vous permet de dériver des interfaces à partir de classs existantes comme ceci:

 $distiller = new InterfaceDistiller; $distiller ->methodsWithModifiers(\ReflectionMethod::IS_PUBLIC) ->extendInterfaceFrom('Iterator, SeekableIterator') ->excludeImplementedMethods() ->excludeInheritedMethods() ->excludeMagicMethods() ->excludeOldStyleConstructors() ->filterMethodsByPattern('(^get)') ->saveAs(new SplFileObject('MyInterface.php')) ->distill('SomeFoo', 'MyInterface'); $ distiller = new InterfaceDistiller; $distiller = new InterfaceDistiller; $distiller ->methodsWithModifiers(\ReflectionMethod::IS_PUBLIC) ->extendInterfaceFrom('Iterator, SeekableIterator') ->excludeImplementedMethods() ->excludeInheritedMethods() ->excludeMagicMethods() ->excludeOldStyleConstructors() ->filterMethodsByPattern('(^get)') ->saveAs(new SplFileObject('MyInterface.php')) ->distill('SomeFoo', 'MyInterface'); $ distillateur $distiller = new InterfaceDistiller; $distiller ->methodsWithModifiers(\ReflectionMethod::IS_PUBLIC) ->extendInterfaceFrom('Iterator, SeekableIterator') ->excludeImplementedMethods() ->excludeInheritedMethods() ->excludeMagicMethods() ->excludeOldStyleConstructors() ->filterMethodsByPattern('(^get)') ->saveAs(new SplFileObject('MyInterface.php')) ->distill('SomeFoo', 'MyInterface'); -> methodsWithModifiers (\ ReflectionMethod :: IS_PUBLIC) $distiller = new InterfaceDistiller; $distiller ->methodsWithModifiers(\ReflectionMethod::IS_PUBLIC) ->extendInterfaceFrom('Iterator, SeekableIterator') ->excludeImplementedMethods() ->excludeInheritedMethods() ->excludeMagicMethods() ->excludeOldStyleConstructors() ->filterMethodsByPattern('(^get)') ->saveAs(new SplFileObject('MyInterface.php')) ->distill('SomeFoo', 'MyInterface'); -> extendInterfaceFrom ('Iterator, SeekableIterator') $distiller = new InterfaceDistiller; $distiller ->methodsWithModifiers(\ReflectionMethod::IS_PUBLIC) ->extendInterfaceFrom('Iterator, SeekableIterator') ->excludeImplementedMethods() ->excludeInheritedMethods() ->excludeMagicMethods() ->excludeOldStyleConstructors() ->filterMethodsByPattern('(^get)') ->saveAs(new SplFileObject('MyInterface.php')) ->distill('SomeFoo', 'MyInterface'); -> exclureImplementedMethods () $distiller = new InterfaceDistiller; $distiller ->methodsWithModifiers(\ReflectionMethod::IS_PUBLIC) ->extendInterfaceFrom('Iterator, SeekableIterator') ->excludeImplementedMethods() ->excludeInheritedMethods() ->excludeMagicMethods() ->excludeOldStyleConstructors() ->filterMethodsByPattern('(^get)') ->saveAs(new SplFileObject('MyInterface.php')) ->distill('SomeFoo', 'MyInterface'); -> exclureInheritedMethods () $distiller = new InterfaceDistiller; $distiller ->methodsWithModifiers(\ReflectionMethod::IS_PUBLIC) ->extendInterfaceFrom('Iterator, SeekableIterator') ->excludeImplementedMethods() ->excludeInheritedMethods() ->excludeMagicMethods() ->excludeOldStyleConstructors() ->filterMethodsByPattern('(^get)') ->saveAs(new SplFileObject('MyInterface.php')) ->distill('SomeFoo', 'MyInterface'); -> exclureMagicMethods () $distiller = new InterfaceDistiller; $distiller ->methodsWithModifiers(\ReflectionMethod::IS_PUBLIC) ->extendInterfaceFrom('Iterator, SeekableIterator') ->excludeImplementedMethods() ->excludeInheritedMethods() ->excludeMagicMethods() ->excludeOldStyleConstructors() ->filterMethodsByPattern('(^get)') ->saveAs(new SplFileObject('MyInterface.php')) ->distill('SomeFoo', 'MyInterface'); -> excludeOldStyleConstructors () $distiller = new InterfaceDistiller; $distiller ->methodsWithModifiers(\ReflectionMethod::IS_PUBLIC) ->extendInterfaceFrom('Iterator, SeekableIterator') ->excludeImplementedMethods() ->excludeInheritedMethods() ->excludeMagicMethods() ->excludeOldStyleConstructors() ->filterMethodsByPattern('(^get)') ->saveAs(new SplFileObject('MyInterface.php')) ->distill('SomeFoo', 'MyInterface'); -> filterMethodsByPattern ('(^ get)') $distiller = new InterfaceDistiller; $distiller ->methodsWithModifiers(\ReflectionMethod::IS_PUBLIC) ->extendInterfaceFrom('Iterator, SeekableIterator') ->excludeImplementedMethods() ->excludeInheritedMethods() ->excludeMagicMethods() ->excludeOldStyleConstructors() ->filterMethodsByPattern('(^get)') ->saveAs(new SplFileObject('MyInterface.php')) ->distill('SomeFoo', 'MyInterface'); -> saveAs (nouveau SplFileObject ('MyInterface.php')) $distiller = new InterfaceDistiller; $distiller ->methodsWithModifiers(\ReflectionMethod::IS_PUBLIC) ->extendInterfaceFrom('Iterator, SeekableIterator') ->excludeImplementedMethods() ->excludeInheritedMethods() ->excludeMagicMethods() ->excludeOldStyleConstructors() ->filterMethodsByPattern('(^get)') ->saveAs(new SplFileObject('MyInterface.php')) ->distill('SomeFoo', 'MyInterface'); 

Il a également une interface CLI:

 Usage: phpdistill [options] <classname> <interfacename> --bootstrap Path to File containing your bootstrap and autoloader --methodsWithModifiers <number> A ReflectionMethod Visibility BitMask. Defaults to Public. --extendInterfaceFrom <name,...> Comma-separated list of Interfaces to extend. --excludeImplementedMethods Will exclude all implemented methods. --excludeInheritedMethods Will exclude all inherited methods. --excludeMagicMethods Will exclude all magic methods. --excludeOldStyleConstructors Will exclude Legacy Constructors. --filterMethodsByPattern <pattern> Only include methods matching PCRE pattern. --saveAs Filename to save new Interface to. STDOUT if omitted. Utilisation: phpdistill [options] <classname> <interfacename> Usage: phpdistill [options] <classname> <interfacename> --bootstrap Path to File containing your bootstrap and autoloader --methodsWithModifiers <number> A ReflectionMethod Visibility BitMask. Defaults to Public. --extendInterfaceFrom <name,...> Comma-separated list of Interfaces to extend. --excludeImplementedMethods Will exclude all implemented methods. --excludeInheritedMethods Will exclude all inherited methods. --excludeMagicMethods Will exclude all magic methods. --excludeOldStyleConstructors Will exclude Legacy Constructors. --filterMethodsByPattern <pattern> Only include methods matching PCRE pattern. --saveAs Filename to save new Interface to. STDOUT if omitted. --bootstrap Path to File contenant votre démarrage et chargeur automatique Usage: phpdistill [options] <classname> <interfacename> --bootstrap Path to File containing your bootstrap and autoloader --methodsWithModifiers <number> A ReflectionMethod Visibility BitMask. Defaults to Public. --extendInterfaceFrom <name,...> Comma-separated list of Interfaces to extend. --excludeImplementedMethods Will exclude all implemented methods. --excludeInheritedMethods Will exclude all inherited methods. --excludeMagicMethods Will exclude all magic methods. --excludeOldStyleConstructors Will exclude Legacy Constructors. --filterMethodsByPattern <pattern> Only include methods matching PCRE pattern. --saveAs Filename to save new Interface to. STDOUT if omitted. - Méthodes avec Modificateurs <nombre> A ReflectionMethod Visibility BitMask. Usage: phpdistill [options] <classname> <interfacename> --bootstrap Path to File containing your bootstrap and autoloader --methodsWithModifiers <number> A ReflectionMethod Visibility BitMask. Defaults to Public. --extendInterfaceFrom <name,...> Comma-separated list of Interfaces to extend. --excludeImplementedMethods Will exclude all implemented methods. --excludeInheritedMethods Will exclude all inherited methods. --excludeMagicMethods Will exclude all magic methods. --excludeOldStyleConstructors Will exclude Legacy Constructors. --filterMethodsByPattern <pattern> Only include methods matching PCRE pattern. --saveAs Filename to save new Interface to. STDOUT if omitted. Par défaut, le public. Usage: phpdistill [options] <classname> <interfacename> --bootstrap Path to File containing your bootstrap and autoloader --methodsWithModifiers <number> A ReflectionMethod Visibility BitMask. Defaults to Public. --extendInterfaceFrom <name,...> Comma-separated list of Interfaces to extend. --excludeImplementedMethods Will exclude all implemented methods. --excludeInheritedMethods Will exclude all inherited methods. --excludeMagicMethods Will exclude all magic methods. --excludeOldStyleConstructors Will exclude Legacy Constructors. --filterMethodsByPattern <pattern> Only include methods matching PCRE pattern. --saveAs Filename to save new Interface to. STDOUT if omitted. --extendInterfaceDe <nom, ...> Liste séparée par des virgules d'interfaces pour étendre. Usage: phpdistill [options] <classname> <interfacename> --bootstrap Path to File containing your bootstrap and autoloader --methodsWithModifiers <number> A ReflectionMethod Visibility BitMask. Defaults to Public. --extendInterfaceFrom <name,...> Comma-separated list of Interfaces to extend. --excludeImplementedMethods Will exclude all implemented methods. --excludeInheritedMethods Will exclude all inherited methods. --excludeMagicMethods Will exclude all magic methods. --excludeOldStyleConstructors Will exclude Legacy Constructors. --filterMethodsByPattern <pattern> Only include methods matching PCRE pattern. --saveAs Filename to save new Interface to. STDOUT if omitted. --excludeImplementedMethods exclura toutes les methods mises en œuvre. Usage: phpdistill [options] <classname> <interfacename> --bootstrap Path to File containing your bootstrap and autoloader --methodsWithModifiers <number> A ReflectionMethod Visibility BitMask. Defaults to Public. --extendInterfaceFrom <name,...> Comma-separated list of Interfaces to extend. --excludeImplementedMethods Will exclude all implemented methods. --excludeInheritedMethods Will exclude all inherited methods. --excludeMagicMethods Will exclude all magic methods. --excludeOldStyleConstructors Will exclude Legacy Constructors. --filterMethodsByPattern <pattern> Only include methods matching PCRE pattern. --saveAs Filename to save new Interface to. STDOUT if omitted. --excludeInheritedMethods exclura toutes les methods héritées. Usage: phpdistill [options] <classname> <interfacename> --bootstrap Path to File containing your bootstrap and autoloader --methodsWithModifiers <number> A ReflectionMethod Visibility BitMask. Defaults to Public. --extendInterfaceFrom <name,...> Comma-separated list of Interfaces to extend. --excludeImplementedMethods Will exclude all implemented methods. --excludeInheritedMethods Will exclude all inherited methods. --excludeMagicMethods Will exclude all magic methods. --excludeOldStyleConstructors Will exclude Legacy Constructors. --filterMethodsByPattern <pattern> Only include methods matching PCRE pattern. --saveAs Filename to save new Interface to. STDOUT if omitted. --excludeMagicMethods exclura toutes les methods magiques. Usage: phpdistill [options] <classname> <interfacename> --bootstrap Path to File containing your bootstrap and autoloader --methodsWithModifiers <number> A ReflectionMethod Visibility BitMask. Defaults to Public. --extendInterfaceFrom <name,...> Comma-separated list of Interfaces to extend. --excludeImplementedMethods Will exclude all implemented methods. --excludeInheritedMethods Will exclude all inherited methods. --excludeMagicMethods Will exclude all magic methods. --excludeOldStyleConstructors Will exclude Legacy Constructors. --filterMethodsByPattern <pattern> Only include methods matching PCRE pattern. --saveAs Filename to save new Interface to. STDOUT if omitted. --excludeOldStyleConstructors exclura les éditeurs hérités. Usage: phpdistill [options] <classname> <interfacename> --bootstrap Path to File containing your bootstrap and autoloader --methodsWithModifiers <number> A ReflectionMethod Visibility BitMask. Defaults to Public. --extendInterfaceFrom <name,...> Comma-separated list of Interfaces to extend. --excludeImplementedMethods Will exclude all implemented methods. --excludeInheritedMethods Will exclude all inherited methods. --excludeMagicMethods Will exclude all magic methods. --excludeOldStyleConstructors Will exclude Legacy Constructors. --filterMethodsByPattern <pattern> Only include methods matching PCRE pattern. --saveAs Filename to save new Interface to. STDOUT if omitted. --filterMethodsByPattern <pattern> Comprend uniquement les methods correspondant au model PCRE. Usage: phpdistill [options] <classname> <interfacename> --bootstrap Path to File containing your bootstrap and autoloader --methodsWithModifiers <number> A ReflectionMethod Visibility BitMask. Defaults to Public. --extendInterfaceFrom <name,...> Comma-separated list of Interfaces to extend. --excludeImplementedMethods Will exclude all implemented methods. --excludeInheritedMethods Will exclude all inherited methods. --excludeMagicMethods Will exclude all magic methods. --excludeOldStyleConstructors Will exclude Legacy Constructors. --filterMethodsByPattern <pattern> Only include methods matching PCRE pattern. --saveAs Filename to save new Interface to. STDOUT if omitted. 

Je ne connais aucun IDE qui offre de telles fonctionnalités pour php.

Actuellement PHPStorm 8 peut le faire, peut-être des versions antérieures aussi.

Pas:

  1. Placez votre slider sur le nom de la class
  2. Choisissez: Refactor -> Extrait -> Interface
  3. Remplissez les options et faites.