Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Pôle IS
Bundles Symfony 2
ng-model-generator-bundle
Commits
067ca76c
Commit
067ca76c
authored
Apr 02, 2020
by
Guillaume Perréal
Browse files
Met à jour les outlis de dev et les linters.
parent
05484ced
Changes
87
Hide whitespace changes
Inline
Side-by-side
.gitlab-ci.yml
View file @
067ca76c
include
:
-
project
:
pole-is/tools/ci-config
ref
:
"
1.10.0
"
file
:
/
php-package-ci
.yml
ref
:
"
2.2.1
"
file
:
/
defaults
.yml
-
project
:
pole-is/tools/ci-config
ref
:
"
1.10.0"
file
:
/nodejs-ci.yml
ref
:
"
2.2.1"
file
:
/php/package.yml
-
project
:
pole-is/tools/ci-config
ref
:
"
2.2.1"
file
:
/php/packagist.yml
-
project
:
pole-is/tools/ci-config
ref
:
"
2.2.1"
file
:
/node/base.yml
stages
:
-
vendor
-
test
-
test-generated
-
deploy
variables
:
PHP_VERSION
:
"
7.1"
...
...
@@ -37,7 +44,7 @@ npm:test:
test:tsc:
stage
:
test-generated
extends
:
.nodejs
dependencie
s
:
need
s
:
-
node_modules
-
test:generate
script
:
...
...
.php_cs.dist
View file @
067ca76c
<?php
declare
(
strict_types
=
1
);
require
__DIR__
.
'/vendor/autoload.php'
;
$finder
=
PhpCsFixer\Finder
::
create
()
->
files
()
->
name
(
'*.php'
)
...
...
@@ -9,8 +7,13 @@ $finder = PhpCsFixer\Finder::create()
->
exclude
(
'tests/Fixtures/var'
)
->
in
(
'.'
);
return
Irstea\CS\Config
::
create
()
->
setIndent
(
' '
)
->
setLineEnding
(
"
\n
"
)
->
setFinder
(
$finder
);
$loader
=
require
__DIR__
.
'/vendor/autoload.php'
;
try
{
return
Irstea\CS\Config
::
create
()
->
setIndent
(
' '
)
->
setLineEnding
(
"
\n
"
)
->
setFinder
(
$finder
);
}
finally
{
$loader
->
unregister
();
}
composer.json
View file @
067ca76c
...
...
@@ -87,7 +87,7 @@
"test:lint"
:
"@php vendor/bin/parallel-lint src/php tests -j $(nproc)"
,
"test:php-cs-fixer"
:
"@php vendor/bin/php-cs-fixer fix --dry-run --verbose --using-cache=false --show-progress=none --no-interaction"
,
"test:phpmd"
:
"@php vendor/bin/phpmd src/php,tests text ./phpmd-ruleset.xml"
,
"test:phpcpd"
:
"@php vendor/bin/phpcpd src/php tests --no-interaction --exclude=Fixtures/var"
,
"test:phpcpd"
:
"@php vendor/bin/phpcpd src/php tests --no-interaction --exclude=Fixtures/var
--names-exclude=ClassInfoTest.php
"
,
"test:phpstan"
:
"@php vendor/bin/phpstan analyse --no-progress --no-interaction"
,
"test:composer-require-checker"
:
"@php -d xdebug.max_nesting_level=1000 vendor/bin/composer-require-checker --ignore-parse-errors"
,
"test:phpunit"
:
"@php vendor/bin/phpunit --colors=never --coverage-text"
,
...
...
composer.lock
View file @
067ca76c
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
src/php/Command/NgModelGenerateCommand.php
View file @
067ca76c
...
...
@@ -52,9 +52,6 @@ final class NgModelGenerateCommand extends Command
/**
* NgModelGenerateCommand constructor.
*
* @param ModelGenerator $generator
* @param Documentation $documentation
*/
public
function
__construct
(
ModelGenerator
$generator
,
...
...
@@ -113,12 +110,6 @@ final class NgModelGenerateCommand extends Command
}
}
/**
* @param InputInterface $input
* @param OutputInterface $output
*
* @return MultiFileWriter
*/
private
function
openWriter
(
InputInterface
$input
,
OutputInterface
$output
):
MultiFileWriter
{
$zipPath
=
$input
->
getOption
(
'zip'
);
...
...
@@ -142,12 +133,6 @@ final class NgModelGenerateCommand extends Command
return
new
ConsoleWriter
(
$output
);
}
/**
* @param string $path
* @param bool $force
*
* @return \ZipArchive
*/
private
function
openZipArchive
(
string
$path
,
bool
$force
):
\
ZipArchive
{
$archive
=
new
\
ZipArchive
();
...
...
src/php/Command/NgModelMetadataCommand.php
View file @
067ca76c
...
...
@@ -47,9 +47,6 @@ final class NgModelMetadataCommand extends Command
/**
* NgModelGenerateCommand constructor.
*
* @param MetadataFactoryInterface $metadataFactory
* @param Documentation $documentation
*/
public
function
__construct
(
MetadataFactoryInterface
$metadataFactory
,
...
...
src/php/Iterators/CallbackFilterRecursorIterator.php
View file @
067ca76c
...
...
@@ -54,8 +54,6 @@ class CallbackFilterRecursorIterator extends RecursorIterator
/**
* @param \Iterator $iter
*
* @return \RecursiveIterator
*/
protected
function
doGetChildren
(
\
Traversable
$iter
)
:
\
RecursiveIterator
{
...
...
src/php/Iterators/IteratorBuilder.php
View file @
067ca76c
...
...
@@ -63,8 +63,6 @@ final class IteratorBuilder implements \IteratorAggregate
}
/**
* @param int $mode
*
* @return IteratorBuilder
*/
public
function
recurse
(
int
$mode
):
self
...
...
@@ -79,9 +77,6 @@ final class IteratorBuilder implements \IteratorAggregate
}
/**
* @param int $mode
* @param callable $filter
*
* @return IteratorBuilder
*/
public
function
recurseWhere
(
int
$mode
,
callable
$filter
):
self
...
...
@@ -97,8 +92,6 @@ final class IteratorBuilder implements \IteratorAggregate
}
/**
* @param callable $where
*
* @return IteratorBuilder
*/
public
function
where
(
callable
$where
):
self
...
...
src/php/Iterators/RecursorIterator.php
View file @
067ca76c
...
...
@@ -55,11 +55,6 @@ class RecursorIterator extends \IteratorIterator implements \RecursiveIterator
return
$this
->
doGetChildren
(
$iter
);
}
/**
* @param \Traversable $iter
*
* @return \RecursiveIterator
*/
protected
function
doGetChildren
(
\
Traversable
$iter
)
:
\
RecursiveIterator
{
return
new
self
(
$iter
);
...
...
src/php/Iterators/UniqueFilter.php
View file @
067ca76c
...
...
@@ -33,8 +33,6 @@ final class UniqueFilter
/**
* @param mixed $value
*
* @return bool
*/
public
function
__invoke
(
$value
):
bool
{
...
...
@@ -47,8 +45,6 @@ final class UniqueFilter
/**
* @param mixed $value
*
* @return string
*/
private
function
getKey
(
$value
):
string
{
...
...
src/php/Metadata/CachingMetadataFactory.php
View file @
067ca76c
...
...
@@ -38,9 +38,6 @@ final class CachingMetadataFactory implements MetadataFactoryInterface
/**
* CachedMetadataFactory constructor.
*
* @param MetadataFactoryInterface $inner
* @param Cache|null $cache
*/
public
function
__construct
(
MetadataFactoryInterface
$inner
,
Cache
$cache
=
null
)
{
...
...
@@ -67,10 +64,6 @@ final class CachingMetadataFactory implements MetadataFactoryInterface
}
/**
* @param string $namespace
* @param string $key
* @param callable $compute
*
* @return mixed
*/
private
function
memoize
(
string
$namespace
,
string
$key
,
callable
$compute
)
...
...
src/php/Metadata/ClassHierarchy.php
View file @
067ca76c
...
...
@@ -28,16 +28,9 @@ use Irstea\NgModelGeneratorBundle\Models\ClassName;
*/
interface
ClassHierarchy
{
/**
* @param ClassName $class
*
* @return ClassName|null
*/
public
function
getParent
(
ClassName
$class
):
?ClassName
;
/**
* @param ClassName $class
*
* @return ClassName[]
*/
public
function
getChildren
(
ClassName
$class
):
array
;
...
...
src/php/Metadata/MetadataFactory.php
View file @
067ca76c
...
...
@@ -84,17 +84,6 @@ final class MetadataFactory implements MetadataFactoryInterface
/**
* MetadataFactory constructor.
*
* @param ResourceClassResolverInterface $resourceClassResolver
* @param ResourceMetadataFactoryInterface $resourceMetadataFactory
* @param PropertyNameCollectionFactoryInterface $propertyNameCollectionFactory
* @param PropertyMetadataFactoryInterface $propertyMetadataFactory
* @param PropertyInfoExtractorInterface $propertyInfoExtractor
* @param OperationMethodResolverInterface $operationMethodResolver
* @param ContainerInterface $filterLocator
* @param PaginationMetadata $paginationMetadata
* @param RouterInterface $router
* @param ClassHierarchy $classHierarchy
*/
public
function
__construct
(
ResourceClassResolverInterface
$resourceClassResolver
,
...
...
@@ -156,12 +145,6 @@ final class MetadataFactory implements MetadataFactoryInterface
);
}
/**
* @param bool $enabled
* @param bool $clientItemsPerPage
*
* @return PaginationMetadata
*/
private
function
buildPagination
(
bool
$enabled
,
bool
$clientItemsPerPage
):
PaginationMetadata
{
return
new
PaginationMetadata
(
...
...
@@ -174,8 +157,6 @@ final class MetadataFactory implements MetadataFactoryInterface
/**
* Get paginationMetadata.
*
* @return PaginationMetadata
*/
public
function
getPaginationMetadata
():
PaginationMetadata
{
...
...
@@ -183,8 +164,6 @@ final class MetadataFactory implements MetadataFactoryInterface
}
/**
* @param ClassName $class
*
* @throws PropertyNotFoundException
* @throws ResourceClassNotFoundException
* @throws \ReflectionException
...
...
@@ -213,17 +192,9 @@ final class MetadataFactory implements MetadataFactoryInterface
}
/**
* @param ClassName $class
* @param APIResourceMetadata $resourceMetadata
* @param string $name
* @param string $type
* @param array $operation
*
* @throws PropertyNotFoundException
* @throws ResourceClassNotFoundException
* @throws \ReflectionException
*
* @return OperationMetadata
*/
private
function
getOperation
(
ClassName
$class
,
...
...
@@ -311,14 +282,6 @@ final class MetadataFactory implements MetadataFactoryInterface
);
}
/**
* @param ClassName $class
* @param string $type
* @param string $name
* @param string $method
*
* @return string
*/
private
function
getOperationPath
(
ClassName
$class
,
string
$type
,
string
$name
,
string
$method
):
string
{
$className
=
$class
->
getFullName
();
...
...
@@ -344,9 +307,6 @@ final class MetadataFactory implements MetadataFactoryInterface
}
/**
* @param ClassName $class
* @param array $filterIds
*
* @return FilterInterface[]
*/
private
function
getFilters
(
ClassName
$class
,
array
$filterIds
):
array
...
...
@@ -367,16 +327,11 @@ final class MetadataFactory implements MetadataFactoryInterface
/**
* @parma string $operationName
*
* @param OperationDef|null $opDef
* @param ClassName $class
* @param bool $normalization
* @param string[] $groups
* @param string[] $groups
*
* @throws PropertyNotFoundException
* @throws ResourceClassNotFoundException
* @throws \ReflectionException
*
* @return SerializationMetadata
*/
private
function
getOperationSerialization
(
?OperationDef
$opDef
,
...
...
@@ -395,16 +350,12 @@ final class MetadataFactory implements MetadataFactoryInterface
}
/**
* @param ClassName $class
* @param bool $normalization
* @param OperationDef $opDef
* @param string[] $groups
*
* @throws PropertyNotFoundException
* @throws ResourceClassNotFoundException
* @throws \ReflectionException
*
* @return SerializationMetadata
*/
private
function
doGetSerialization
(
ClassName
$class
,
bool
$normalization
,
?OperationDef
$opDef
,
array
$groups
):
SerializationMetadata
{
...
...
@@ -474,15 +425,7 @@ final class MetadataFactory implements MetadataFactoryInterface
}
/**
* @param ClassName $root
* @param ClassName $class
* @param bool $normalization
* @param OperationDef|null $opDef
* @param array $groups
*
* @throws ResourceClassNotFoundException
*
* @return string
*/
private
function
getRepresentationName
(
ClassName
$root
,
...
...
@@ -515,11 +458,7 @@ final class MetadataFactory implements MetadataFactoryInterface
}
/**
* @param ClassName $class
*
* @throws ResourceClassNotFoundException
*
* @return array
*/
private
function
getDefaultGroups
(
ClassName
$class
):
array
{
...
...
src/php/Metadata/MetadataFactoryInterface.php
View file @
067ca76c
...
...
@@ -28,22 +28,9 @@ use Irstea\NgModelGeneratorBundle\Models\ClassName;
*/
interface
MetadataFactoryInterface
{
/**
* @param ClassName $class
*
* @return bool
*/
public
function
isResource
(
ClassName
$class
):
bool
;
/**
* @param ClassName $class
*
* @return ResourceMetadata
*/
public
function
getResourceMetadata
(
ClassName
$class
):
ResourceMetadata
;
/**
* @return PaginationMetadata
*/
public
function
getPaginationMetadata
():
PaginationMetadata
;
}
src/php/Metadata/OperationDef.php
View file @
067ca76c
...
...
@@ -46,10 +46,6 @@ final class OperationDef implements \JsonSerializable, HasName
/**
* OperationDef constructor.
*
* @param string $name
* @param string $method
* @param bool $isCollection
*/
public
function
__construct
(
string
$name
,
string
$method
,
bool
$isCollection
)
{
...
...
@@ -83,57 +79,36 @@ final class OperationDef implements \JsonSerializable, HasName
$this
->
name
=
$name
;
}
/**
* @return bool
*/
public
function
hasNormalization
():
bool
{
return
\
in_array
(
$this
->
method
,
[
'GET'
,
'PUT'
,
'POST'
]);
}
/**
* @return bool
*/
public
function
hasDenormalization
():
bool
{
return
\
in_array
(
$this
->
method
,
[
'PUT'
,
'POST'
]);
}
/**
* @return bool
*/
public
function
isGetItem
():
bool
{
return
$this
->
special
===
'GET'
&&
!
$this
->
isCollection
;
}
/**
* @return bool
*/
public
function
isCreateItem
():
bool
{
return
$this
->
special
===
'POST'
&&
!
$this
->
isCollection
;
}
/**
* @return bool
*/
public
function
isUpdateItem
():
bool
{
return
$this
->
special
===
'PUT'
&&
!
$this
->
isCollection
;
}
/**
* @return bool
*/
public
function
isDeleteItem
():
bool
{
return
$this
->
special
===
'DELETE'
&&
!
$this
->
isCollection
;
}
/**
* @return bool
*/
public
function
isGetCollection
():
bool
{
return
$this
->
method
===
'GET'
&&
$this
->
isCollection
;
...
...
@@ -141,8 +116,6 @@ final class OperationDef implements \JsonSerializable, HasName
/**
* Get name.
*
* @return string
*/
public
function
getName
():
string
{
...
...
@@ -151,8 +124,6 @@ final class OperationDef implements \JsonSerializable, HasName
/**
* Get originalName.
*
* @return string
*/
public
function
getOriginalName
():
string
{
...
...
@@ -161,8 +132,6 @@ final class OperationDef implements \JsonSerializable, HasName
/**
* Get method.
*
* @return string
*/
public
function
getMethod
():
string
{
...
...
@@ -171,8 +140,6 @@ final class OperationDef implements \JsonSerializable, HasName
/**
* Get isCollection.
*
* @return bool
*/
public
function
isCollection
():
bool
{
...
...
src/php/Metadata/OperationMetadata.php
View file @
067ca76c
...
...
@@ -58,15 +58,6 @@ class OperationMetadata implements \JsonSerializable, HasName
/**
* OperationMetadata constructor.
*
* @param OperationDef $opDef
* @param string $description
* @param string $path
* @param array $requirements
* @param array $filters
* @param PaginationMetadata|null $pagination
* @param SerializationMetadata|null $normalization
* @param SerializationMetadata|null $denormalization
*/
public
function
__construct
(
OperationDef
$opDef
,
...
...
@@ -89,8 +80,6 @@ class OperationMetadata implements \JsonSerializable, HasName
}
/**
* @param ResourceMetadata $resource
*
* @return OperationMetadata
*/
public
function
withResource
(
ResourceMetadata
$resource
):
self
...
...
@@ -103,8 +92,6 @@ class OperationMetadata implements \JsonSerializable, HasName
/**
* Get className.
*
* @return string
*/
public
function
getClassName
():
string
{
...
...
@@ -113,8 +100,6 @@ class OperationMetadata implements \JsonSerializable, HasName
/**
* Get opDef.
*
* @return OperationDef
*/
public
function
getOpDef
():
OperationDef
{
...
...
@@ -123,8 +108,6 @@ class OperationMetadata implements \JsonSerializable, HasName
/**
* Get name.
*
* @return string
*/
public
function
getName
():
string
{
...
...
@@ -133,8 +116,6 @@ class OperationMetadata implements \JsonSerializable, HasName
/**
* Get description.
*
* @return string
*/
public
function
getDescription
():
string
{
...
...
@@ -143,25 +124,17 @@ class OperationMetadata implements \JsonSerializable, HasName
/**
* Get type.
*
* @return string
*/
public
function
getType
():
string
{
return
$this
->
opDef
->
isCollection
()
?
'collection'
:
'item'
;
}
/**
* @return bool
*/
public
function
isItemOperation
():
bool
{
return
!
$this
->
opDef
->
isCollection
();
}
/**
* @return bool
*/
public
function
isCollectionOperation
():
bool
{
return
$this
->
opDef
->
isCollection
();
...
...
@@ -169,8 +142,6 @@ class OperationMetadata implements \JsonSerializable, HasName
/**
* Get method.
*
* @return string
*/
public
function
getMethod
():
string
{
...
...
@@ -179,8 +150,6 @@ class OperationMetadata implements \JsonSerializable, HasName
/**
* Get path.
*
* @return string
*/
public
function
getPath
():
string
{
...
...
@@ -199,8 +168,6 @@ class OperationMetadata implements \JsonSerializable, HasName
/**
* Get pagination.
*
* @return PaginationMetadata|null
*/
public
function
getPagination
():
?PaginationMetadata
{
...
...
@@ -219,8 +186,6 @@ class OperationMetadata implements \JsonSerializable, HasName
/**
* Get normalization.
*
* @return SerializationMetadata|null
*/
public
function
getNormalization
():
?SerializationMetadata
{
...
...
@@ -229,8 +194,6 @@ class OperationMetadata implements \JsonSerializable, HasName
/**
* Get denormalization.
*
* @return SerializationMetadata|null
*/
public
function
getDenormalization
():
?SerializationMetadata
{
...
...
@@ -239,8 +202,6 @@ class OperationMetadata implements \JsonSerializable, HasName
/**
* Get resource.
*
* @return ResourceMetadata
*/
public
function
getResource
():
ResourceMetadata
{
...
...
src/php/Metadata/PaginationMetadata.php
View file @
067ca76c