Skip to content

PHPORM-439 Initialize the make:document command - #3

Merged
GromNaN merged 14 commits into
doctrine:0.1.xfrom
GromNaN:PHPORM-439
Jan 30, 2026
Merged

PHPORM-439 Initialize the make:document command#3
GromNaN merged 14 commits into
doctrine:0.1.xfrom
GromNaN:PHPORM-439

Conversation

@GromNaN

@GromNaN GromNaN commented Jan 14, 2026

Copy link
Copy Markdown
Member

Comment thread tests/Maker/MakeDocumentTest.php Outdated
Comment thread tests/Maker/MakeDocumentTest.php Outdated
Comment thread src/MongoDB/MongoDBHelper.php
Comment thread composer.json Outdated
Comment thread composer.json
"keywords": ["mongodb", "maker", "odm", "dev"],
"type": "symfony-bundle",
"repositories": [
{ "type": "github", "url": "https://github.com/GromNaN/symfony-maker-bundle" }

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I created the branch 1.x on my fork to get all the required PR together. https://github.com/GromNaN/symfony-maker-bundle/tree/1.x

@paulinevos paulinevos left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Some comments but I don't think it should block merging for now if it all works 🤷‍♀️


services:
mongodb:
image: "mongodb/mongodb-atlas-local:latest"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we always want to use latest or lock this to a specific tag?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Using the latest if fine. New versions should always be backward compatible for what we do. And I don't want to have to constantly update. Unless Dependabot can do it for us.

Comment thread src/Maker/MakeDocument.php Outdated
DocumentClassGenerator|null $documentClassGenerator = null,
) {
if ($generator === null) {
$this->generator = new Generator($fileManager, 'App\\');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can't we like

$this->generator = $generator ?? new Generator($fileManager, 'App\\');

or is this a stylistic choice?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good catch, I'll use CPP also.

Comment thread src/Maker/MakeDocument.php Outdated
$documentClassName ??= $io->askQuestion($question);

while ($dangerous = $this->verifyDocumentName($documentClassName)) {
if ($io->confirm(sprintf('"%s" contains one or more non-ASCII characters, which are potentially problematic with some database. It is recommended to use only ASCII characters for document names. Continue anyway?', $documentClassName), false)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

some databases

Comment thread src/Maker/MakeDocument.php Outdated
if ($classExists) {
$documentPath = $this->getPathOfClass($documentClassDetails->getFullName());
$io->text('Your document already exists! So let\'s add some new fields!');
} else {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can't we put this after L155?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, I merged the 2 if

],
];

$printSection = static function (array $sectionTypes) use ($io, &$allTypes): void {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Feel like this one's a little hard to read. Maybe there's some way to improve it like limiting the nesting etc?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'll let this refactoring for a later PR.

private function getPropertyNames(string $class): array
{
if (! class_exists($class)) {
return [];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should this not be an error?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is for when a new document class is created.

@GromNaN
GromNaN merged commit e59afbe into doctrine:0.1.x Jan 30, 2026
7 checks passed
@GromNaN
GromNaN deleted the PHPORM-439 branch January 30, 2026 11:01
Comment thread composer.json
"description": "Symfony MakerBundle for MongoDB ODM",
"keywords": ["mongodb", "maker", "odm", "dev"],
"type": "symfony-bundle",
"repositories": [

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Noted that this and the "symfony/maker-bundle": "^1@dev" requirement below are required until your upstream PRs on symfony/maker-bundle are merged.

Comment thread tests/TestKernel.php
Comment thread tests/TestKernel.php

final class MakeDocument extends AbstractMaker implements InputAwareMakerInterface
{
use UidTrait;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do you want a todo here to note that this file is internal? Maybe an attribute to suppress the warning (not sure if it's something that comes up in CI checks or just PHPStorm).

Comment thread src/Maker/MakeDocument.php Outdated
Comment on lines +59 to +69
if ($generator === null) {
$this->generator = new Generator($fileManager, 'App\\');
} else {
$this->generator = $generator;
}

if ($documentClassGenerator === null) {
$this->documentClassGenerator = new DocumentClassGenerator($this->generator, $this->mongoDBHelper);
} else {
$this->documentClassGenerator = $documentClassGenerator;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Noted that ??= isn't possible here because the argument and properties are different variables. I assume using ?? in a one-liner would be too long, so this is more readable.

Comment thread src/Maker/MakeDocument.php Outdated
private FileManager $fileManager,
private MongoDBHelper $mongoDBHelper,
Generator|null $generator = null,
DocumentClassGenerator|null $documentClassGenerator = null,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Out of curiosity, is |null preferred instead of a ? prefix (just for nullable args)?

{
// TODO: Implement configureCommand() method.
$command
->addArgument('name', InputArgument::OPTIONAL, sprintf('Class name of the document to create or update (e.g. <fg=yellow>%s</>)', Str::asClassName(Str::getRandomTerm())))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I haven't worked with Symfony Console formatting before, but is </> shorthand for disabling all formatting switches? Is it still possible to just disable individual tags (e.g. <fg> in this case, if you wanted to leave a background color active)?

@GromNaN GromNaN added this to the 0.1.0 milestone Mar 20, 2026
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