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

$primary must not be accessed before initialization #37

Open
MKI-Miro opened this issue Feb 20, 2024 · 1 comment
Open

$primary must not be accessed before initialization #37

MKI-Miro opened this issue Feb 20, 2024 · 1 comment

Comments

@MKI-Miro
Copy link

Ahojte

Po update na 6.0.1 tu mame novu chybu:

Fatal error: Uncaught Error: Typed property Contributte\Nextras\Orm\Generator\Entity\PhpRelDoc::$primary must not be accessed before initialization in \vendor\contributte\nextras-orm-generator\src\Entity\PhpRelDoc.php:132 Stack trace: #0 \vendor\contributte\nextras-orm-generator\src\Entity\PhpDoc.php(150): Contributte\Nextras\Orm\Generator\Entity\PhpRelDoc->__toString() #1 \vendor\contributte\nextras-orm-generator\src\Generator\Entity\Decorator\ColumnDocumentor.php(73): Contributte\Nextras\Orm\Generator\Entity\PhpDoc->__toString() #2 \vendor\contributte\nextras-orm-generator\src\Generator\Entity\EntityGenerator.php(60): Contributte\Nextras\Orm\Generator\Generator\Entity\Decorator\ColumnDocumentor->doDecorate(Object(Contributte\Nextras\Orm\Generator\Entity\Column), Object(Nette\PhpGenerator\ClassType), Object(Nette\PhpGenerator\PhpNamespace)) #3 \vendor\contributte\nextras-orm-generator\src\Generator.php(90): Contributte\Nextras\Orm\Generator\Generator\Entity\EntityGenerator->generate(Object(Contributte\Nextras\Orm\Generator\Entity\Database)) #4 \www\nextras.php(20): Contributte\Nextras\Orm\Generator\Generator->generate() #5 {main} thrown in \vendor\contributte\nextras-orm-generator\src\Entity\PhpRelDoc.php on line 132

@phpfui
Copy link

phpfui commented Mar 2, 2024

Having the same problem in PHP 8.2

Fix is to set the following to null in PhpRelDoc

private ?bool $primary = null;
private ?string $orderProperty = null;
private ?int $orderDirection = null;

I would submit a PR, but I am just benchmarking this ORM and patching the vendor directory gets me around this issue.

Also I would add FQNs to your example or add use statements.

$factory = new \Contributte\Nextras\Orm\Generator\SimpleFactory(
	new \Contributte\Nextras\Orm\Generator\Config\Impl\TogetherConfig($config),
	new \Contributte\Nextras\Orm\Generator\Analyser\Database\DatabaseAnalyser('sqlite:sqlite.db', 'root'));

Thanks for providing this package so I don't have to write code by hand.

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

No branches or pull requests

2 participants