Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
hhit
config-generator
Commits
faf53eeb
Commit
faf53eeb
authored
Mar 09, 2021
by
Hendrik Heneke
Browse files
Compatibility with PHP >= 7.2.
parent
3004eca0
Pipeline
#392
passed with stage
in 26 seconds
Changes
15
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
115 additions
and
39 deletions
+115
-39
src/Command/AbstractCommand.php
src/Command/AbstractCommand.php
+4
-1
src/Generator/Compiler/Compiler.php
src/Generator/Compiler/Compiler.php
+14
-8
src/Generator/Definition/Definition.php
src/Generator/Definition/Definition.php
+20
-5
src/Generator/Definition/DefinitionReader.php
src/Generator/Definition/DefinitionReader.php
+4
-1
src/Generator/Factory.php
src/Generator/Factory.php
+8
-2
src/Generator/Generator.php
src/Generator/Generator.php
+12
-3
src/Generator/IO/FileReader.php
src/Generator/IO/FileReader.php
+4
-1
src/Generator/IO/FileWriter.php
src/Generator/IO/FileWriter.php
+4
-1
src/Generator/IO/JsonReader.php
src/Generator/IO/JsonReader.php
+5
-4
src/Generator/IO/Path.php
src/Generator/IO/Path.php
+4
-1
src/Generator/Secrets/SecretProviderFactory.php
src/Generator/Secrets/SecretProviderFactory.php
+4
-1
src/Generator/Secrets/SymfonyVaultSecretProvider.php
src/Generator/Secrets/SymfonyVaultSecretProvider.php
+8
-2
src/Generator/Validator/JSONValidator.php
src/Generator/Validator/JSONValidator.php
+4
-4
src/Generator/Values/ValuesLoader.php
src/Generator/Values/ValuesLoader.php
+12
-3
src/Generator/Values/ValuesLoaderFactory.php
src/Generator/Values/ValuesLoaderFactory.php
+8
-2
No files found.
src/Command/AbstractCommand.php
View file @
faf53eeb
...
...
@@ -10,7 +10,10 @@ use Symfony\Component\Console\Input\InputOption;
abstract
class
AbstractCommand
extends
Command
{
protected
string
$projectDir
;
/**
* @var string
*/
protected
$projectDir
;
public
function
__construct
(
string
$projectDir
,
?string
$name
=
null
)
{
...
...
src/Generator/Compiler/Compiler.php
View file @
faf53eeb
...
...
@@ -10,9 +10,18 @@ use LightnCandy\LightnCandy;
class
Compiler
extends
FileReader
{
private
ValuesLoader
$loader
;
private
?
\
Closure
$fn
=
null
;
private
array
$helpers
=
[];
/**
* @var ValuesLoader
*/
private
$loader
;
/**
* @var \Closure|null
*/
private
$fn
=
null
;
/**
* @var \Closure[]
*/
private
$helpers
=
[];
public
function
__construct
(
File
$file
,
ValuesLoader
$loader
)
{
...
...
@@ -24,19 +33,16 @@ class Compiler extends FileReader
return
password_hash
(
$password
,
PASSWORD_DEFAULT
);
},
'password_hash_bcrypt'
=>
function
(
$password
)
{
if
(
!
in_array
(
'2y'
,
password_algos
()))
{
throw
new
\
Exception
(
'bcrypt algorithm not supported!'
);
}
return
password_hash
(
$password
,
PASSWORD_BCRYPT
);
},
'password_hash_argon2i'
=>
function
(
$password
)
{
if
(
!
in_array
(
'argon2i'
,
password_algos
()
))
{
if
(
!
defined
(
'PASSWORD_ARGON2I'
))
{
throw
new
\
Exception
(
'argon2i algorithm not supported!'
);
}
return
password_hash
(
$password
,
PASSWORD_ARGON2I
);
},
'password_hash_argon2id'
=>
function
(
$password
)
{
if
(
!
in_array
(
'argon2id'
,
password_algos
()
))
{
if
(
!
defined
(
'PASSWORD_ARGON2ID'
))
{
throw
new
\
Exception
(
'argon2id algorithm not supported!'
);
}
return
password_hash
(
$password
,
PASSWORD_ARGON2ID
);
...
...
src/Generator/Definition/Definition.php
View file @
faf53eeb
...
...
@@ -8,11 +8,26 @@ use HHIT\ConfigGenerator\Generator\IO\Path;
class
Definition
{
private
string
$id
;
private
File
$templateFile
;
private
string
$type
;
private
File
$valuesFile
;
private
File
$destinationFile
;
/**
* @var string
*/
private
$id
;
/**
* @var File
*/
private
$templateFile
;
/**
* @var string
*/
private
$type
;
/**
* @var File
*/
private
$valuesFile
;
/**
* @var File
*/
private
$destinationFile
;
public
function
__construct
(
string
$id
,
File
$templateFile
,
string
$type
,
File
$valuesFile
,
File
$destinationFile
)
{
...
...
src/Generator/Definition/DefinitionReader.php
View file @
faf53eeb
...
...
@@ -11,7 +11,10 @@ use HHIT\ConfigGenerator\Generator\StringUtils;
class
DefinitionReader
{
private
string
$projectDir
;
/**
* @var string
*/
private
$projectDir
;
public
function
__construct
(
string
$projectDir
)
{
...
...
src/Generator/Factory.php
View file @
faf53eeb
...
...
@@ -14,8 +14,14 @@ use Symfony\Component\Dotenv\Dotenv;
class
Factory
{
private
string
$projectDir
;
private
string
$env
;
/**
* @var string
*/
private
$projectDir
;
/**
* @var string
*/
private
$env
;
public
function
__construct
(
string
$projectDir
,
string
$env
=
'dev'
)
{
...
...
src/Generator/Generator.php
View file @
faf53eeb
...
...
@@ -14,9 +14,18 @@ use Symfony\Component\Console\Output\OutputInterface;
class
Generator
{
private
DefinitionReader
$definitionReader
;
private
ValuesLoaderFactory
$valuesLoaderFactory
;
private
ValidatorFactory
$validatorFactory
;
/**
* @var DefinitionReader
*/
private
$definitionReader
;
/**
* @var ValuesLoaderFactory
*/
private
$valuesLoaderFactory
;
/**
* @var ValidatorFactory
*/
private
$validatorFactory
;
public
function
__construct
(
DefinitionReader
$definitionReader
,
...
...
src/Generator/IO/FileReader.php
View file @
faf53eeb
...
...
@@ -5,7 +5,10 @@ namespace HHIT\ConfigGenerator\Generator\IO;
class
FileReader
{
private
File
$file
;
/**
* @var File
*/
private
$file
;
public
function
__construct
(
File
$file
)
{
...
...
src/Generator/IO/FileWriter.php
View file @
faf53eeb
...
...
@@ -5,7 +5,10 @@ namespace HHIT\ConfigGenerator\Generator\IO;
class
FileWriter
{
private
File
$file
;
/**
* @var File
*/
private
$file
;
public
function
__construct
(
File
$file
)
{
...
...
src/Generator/IO/JsonReader.php
View file @
faf53eeb
...
...
@@ -14,11 +14,12 @@ class JsonReader extends FileReader
{
$str
=
$this
->
read
();
if
(
$str
)
{
try
{
return
json_decode
(
$str
,
$assoc
,
$depth
,
JSON_THROW_ON_ERROR
);
}
catch
(
\
JsonException
$e
)
{
throw
new
\
RuntimeException
(
'Reading JSON failed
'
,
0
,
$e
);
$decoded
=
@
json_decode
(
$str
,
$assoc
,
$depth
);
$err
=
json_last_error
(
);
if
(
$err
!==
JSON_ERROR_NONE
)
{
throw
new
\
RuntimeException
(
'Reading JSON failed
: '
.
json_last_error_msg
()
,
$e
rr
);
}
return
$decoded
;
}
}
}
src/Generator/IO/Path.php
View file @
faf53eeb
...
...
@@ -7,7 +7,10 @@ use HHIT\ConfigGenerator\Generator\StringUtils;
abstract
class
Path
{
private
string
$path
;
/**
* @var string
*/
private
$path
;
protected
function
__construct
(
string
$path
,
?File
$relativeTo
=
null
)
{
...
...
src/Generator/Secrets/SecretProviderFactory.php
View file @
faf53eeb
...
...
@@ -5,7 +5,10 @@ namespace HHIT\ConfigGenerator\Generator\Secrets;
class
SecretProviderFactory
{
private
SymfonyVaultSecretProvider
$symfonyProvider
;
/**
* @var SymfonyVaultSecretProvider
*/
private
$symfonyProvider
;
public
function
__construct
(
SymfonyVaultSecretProvider
$symfonyProvider
)
{
...
...
src/Generator/Secrets/SymfonyVaultSecretProvider.php
View file @
faf53eeb
...
...
@@ -8,8 +8,14 @@ use Symfony\Bundle\FrameworkBundle\Secrets\SodiumVault;
class
SymfonyVaultSecretProvider
implements
SecretProviderInterface
{
private
SodiumVault
$sodiumVault
;
private
DotenvVault
$dotenvVault
;
/**
* @var SodiumVault
*/
private
$sodiumVault
;
/**
* @var DotenvVault
*/
private
$dotenvVault
;
public
function
__construct
(
SodiumVault
$sodiumVault
,
DotenvVault
$dotenvVault
)
{
...
...
src/Generator/Validator/JSONValidator.php
View file @
faf53eeb
...
...
@@ -7,10 +7,10 @@ class JSONValidator implements ValidatorInterface
{
public
function
validate
(
string
$content
)
{
try
{
json_decode
(
$content
,
false
,
512
,
JSON_THROW_ON_ERROR
);
}
catch
(
\
JsonException
$e
)
{
throw
new
ValidationException
(
"JSON is invalid:
{
$e
->
getMessage
()
}
"
,
$e
->
getCode
(),
$e
);
@
json_decode
(
$content
,
false
,
512
);
$err
=
json_last_error
(
);
if
(
$err
!==
JSON_ERROR_NONE
)
{
throw
new
ValidationException
(
"JSON is invalid:
"
.
json_last_error_msg
(),
$err
);
}
}
}
src/Generator/Values/ValuesLoader.php
View file @
faf53eeb
...
...
@@ -9,9 +9,18 @@ use HHIT\ConfigGenerator\Generator\Secrets\SecretProviderInterface;
class
ValuesLoader
extends
JsonReader
{
private
array
$context
=
[];
private
SecretProviderInterface
$provider
;
private
string
$env
;
/**
* @var array
*/
private
$context
=
[];
/**
* @var SecretProviderInterface
*/
private
$provider
;
/**
* @var string
*/
private
$env
;
public
function
__construct
(
File
$file
,
SecretProviderInterface
$provider
,
string
$env
)
{
...
...
src/Generator/Values/ValuesLoaderFactory.php
View file @
faf53eeb
...
...
@@ -8,8 +8,14 @@ use HHIT\ConfigGenerator\Generator\Secrets\SecretProviderFactory;
class
ValuesLoaderFactory
{
private
SecretProviderFactory
$secretProviderFactory
;
private
string
$env
;
/**
* @var SecretProviderFactory
*/
private
$secretProviderFactory
;
/**
* @var string
*/
private
$env
;
public
function
__construct
(
SecretProviderFactory
$secretProviderFactory
,
string
$env
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment