Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is
duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
The variable $path does not exist. Did you forget to declare it?
This check marks access to variables or properties that have not been declared yet. While PHP
has no explicit notion of declaring a variable, accessing it before a value is assigned
to it is most likely a bug.
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.
If you suppress an error, we recommend checking for the error condition explicitly:
// For example instead of@mkdir($dir);// Better useif(@mkdir($dir)===false){thrownew\RuntimeException('The directory '.$dir.' could not be created.');}
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate
the same code in three or more different places, we strongly encourage you to
look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
30
// Analyze database structure and get entities metadata
31
foreach ($analyzer->analyze() as $metadata) {
32
// Iterate all generators for analyzer
33
foreach ($this->generators[$analyzerClass] as $generator) {
34
/** @var Generic $generator Create class generator */
35
$generator = new $generator($this->codeGenerator->defNamespace($this->namespace), $metadata);
This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.