Skip to content
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

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

Basic generator #1

wants to merge 9 commits into from

Conversation

jonag
Copy link

@jonag jonag commented Oct 2, 2017

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).

@arnaudgoulpeau
Copy link
Contributor

PR read, waiting returns

Copy link
Contributor

@arnaudgoulpeau arnaudgoulpeau left a 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


$classes = static::findClasses($path);

if (\PHP_VERSION_ID >= 70000) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in a constant pls

Copy link
Author

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])) {
Copy link
Contributor

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
Copy link
Contributor

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 ?

Copy link
Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants