-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Basic generator #1
base: master
Are you sure you want to change the base?
Conversation
PR read, waiting returns |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
apply a phpcs pass pls
Util/ClassExtractor.php
Outdated
|
||
$classes = static::findClasses($path); | ||
|
||
if (\PHP_VERSION_ID >= 70000) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in a constant pls
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this bundle requires PHP 7.1 I can even delete this check 👍 (Once again, it's just a copy from Symfony's repository)
for ($i = 0; isset($tokens[$i]); ++$i) { | ||
$token = $tokens[$i]; | ||
|
||
if (!isset($token[1])) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a comment to explain what $token[1] is pls
namespace A5sys\TypeScriptGeneratorBundle\Util; | ||
|
||
/** | ||
* Copied from by Symfony's ClassMapGenerator which is now deprecated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does it means this class is deprecated ? does the comment still apply ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Symfony's ClassLoader component (from which the class is copied) is deprecated. Since the class will be deleted in the next version of Symfony I have copy/pasted its code in our bundle to be able to use its functionality even when Symfony 4 will be released.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok !
Voici ma première version pour le générateur de code TypeScript à partir de classes PHP.
L'analyse des classes se base sur le composant Property Info de Symfony qui lui utilise la PHPdoc, les métadonnées Doctrine et le typage PHP pour déduire les informations sur les propriétés d'une classe.
Cette première version gère normalement les cas d'usages "basique" (je l'ai testé sur un petit projet) et il va falloir le tester sur un nombre plus conséquent d'entité pour trouver les cas limites et les corriger.
Il y a deux générateurs disponibles, un générateur d'interface ou de classes (les deux options semblent être utilisées dans le monde TypeScript, à confirmer). Les deux formats sont gérés par la même classe (et la même commande), la distinction se fait au niveau des services déclarés (je déclare plusieurs services à partir de la même classe).