Skip to content
This repository has been archived by the owner on Jan 16, 2018. It is now read-only.

Commit

Permalink
Add php strict typehint and return-type
Browse files Browse the repository at this point in the history
  • Loading branch information
sstok committed Sep 21, 2016
1 parent 509250a commit a2d75f1
Show file tree
Hide file tree
Showing 98 changed files with 370 additions and 368 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/phpunit.xml
/composer.lock
.php_cs.cache
*.phar
/vendor/
/bin/
Expand Down
33 changes: 13 additions & 20 deletions .php_cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

require_once __DIR__.'/vendor/sllh/php-cs-fixer-styleci-bridge/autoload.php';

$header = <<<EOF
This file is part of the RollerworksDatagrid package.
Expand All @@ -9,25 +11,16 @@ This source file is subject to the MIT license that is bundled
with this source code in the file LICENSE.
EOF;

Symfony\CS\Fixer\Contrib\HeaderCommentFixer::setHeader($header);
$config = SLLH\StyleCIBridge\ConfigBridge::create()
->setUsingCache(true)
->setRiskyAllowed(true)
;

return Symfony\CS\Config\Config::create()
->setUsingLinter(false)
// use SYMFONY_LEVEL:
->level(Symfony\CS\FixerInterface::SYMFONY_LEVEL)
// and extra fixers:
->fixers(array(
'ordered_use',
//'strict',
'strict_param',
'short_array_syntax',
'phpdoc_order',
'header_comment',
'-psr0',
))
->finder(
Symfony\CS\Finder\DefaultFinder::create()
->exclude(array('bin', 'doc'))
->in(__DIR__)
$config->setRules(
array_merge(
$config->getRules(),
['header_comment' => ['header' => $header]]
)
;
);

return $config;
20 changes: 20 additions & 0 deletions .styleci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
preset: symfony

risky: true

linting: false

enabled:
#- ordered_class_elements
- ordered_imports
- phpdoc_order
- short_array_syntax
- strict_param
#- declare_strict_types

finder:
path:
- 'src/'
- 'tests/'
not-path:
- 'Fixtures'
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"symfony/intl": "^3.0"
},
"require-dev": {
"phpunit/phpunit": "^5.5"
"phpunit/phpunit": "^5.5",
"sllh/php-cs-fixer-styleci-bridge": "^2.1"
},
"autoload": {
"psr-4": {
Expand Down
14 changes: 7 additions & 7 deletions src/AbstractDatagridExtension.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);

/*
* This file is part of the RollerworksDatagrid package.
Expand Down Expand Up @@ -38,7 +38,7 @@ abstract class AbstractDatagridExtension implements DatagridExtensionInterface
/**
* {@inheritdoc}
*/
public function getType($type)
public function getType($type): ColumnTypeInterface
{
if (null === $this->types) {
$this->initColumnTypes();
Expand All @@ -54,7 +54,7 @@ public function getType($type)
/**
* {@inheritdoc}
*/
public function hasType($type)
public function hasType($type): bool
{
if (null === $this->types) {
$this->initColumnTypes();
Expand All @@ -66,7 +66,7 @@ public function hasType($type)
/**
* {@inheritdoc}
*/
public function hasTypeExtensions($type)
public function hasTypeExtensions($type): bool
{
if (null === $this->typesExtensions) {
$this->initTypesExtensions();
Expand All @@ -78,7 +78,7 @@ public function hasTypeExtensions($type)
/**
* {@inheritdoc}
*/
public function getTypeExtensions($type)
public function getTypeExtensions($type): array
{
if (null === $this->typesExtensions) {
$this->initTypesExtensions();
Expand All @@ -96,7 +96,7 @@ public function getTypeExtensions($type)
*
* @codeCoverageIgnore
*/
protected function loadTypes()
protected function loadTypes(): array
{
return [];
}
Expand All @@ -110,7 +110,7 @@ protected function loadTypes()
*
* @codeCoverageIgnore
*/
protected function loadTypesExtensions()
protected function loadTypesExtensions(): array
{
return [];
}
Expand Down
4 changes: 2 additions & 2 deletions src/Column/AbstractType.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);

/*
* This file is part of the RollerworksDatagrid package.
Expand Down Expand Up @@ -56,7 +56,7 @@ public function buildHeaderView(HeaderView $view, ColumnInterface $column, array
*
* @return string The prefix of the template block name
*/
public function getBlockPrefix()
public function getBlockPrefix(): string
{
return StringUtil::fqcnToBlockPrefix(get_class($this));
}
Expand Down
2 changes: 1 addition & 1 deletion src/Column/AbstractTypeExtension.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);

/*
* This file is part of the RollerworksDatagrid package.
Expand Down
2 changes: 1 addition & 1 deletion src/Column/CellView.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);

/*
* This file is part of the RollerworksDatagrid package.
Expand Down
18 changes: 9 additions & 9 deletions src/Column/Column.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);

/*
* This file is part of the RollerworksDatagrid package.
Expand Down Expand Up @@ -83,15 +83,15 @@ public function __construct(
/**
* {@inheritdoc}
*/
public function getName()
public function getName(): string
{
return $this->name;
}

/**
* {@inheritdoc}
*/
public function getType()
public function getType(): ResolvedColumnTypeInterface
{
return $this->type;
}
Expand Down Expand Up @@ -131,15 +131,15 @@ public function resetViewTransformers()
/**
* {@inheritdoc}
*/
public function getViewTransformers()
public function getViewTransformers(): array
{
return $this->viewTransformers;
}

/**
* {@inheritdoc}
*/
public function getOptions()
public function getOptions(): array
{
return $this->options;
}
Expand All @@ -159,15 +159,15 @@ public function getOption($name, $default = null)
/**
* {@inheritdoc}
*/
public function hasOption($name)
public function hasOption($name): bool
{
return array_key_exists($name, $this->options);
}

/**
* {@inheritdoc}
*/
public function createHeaderView(DatagridView $datagrid)
public function createHeaderView(DatagridView $datagrid): HeaderView
{
// The methods createHeaderView(), buildHeaderView() are called
// explicitly here in order to be able to override either of them
Expand All @@ -182,7 +182,7 @@ public function createHeaderView(DatagridView $datagrid)
/**
* {@inheritdoc}
*/
public function createCellView(DatagridView $datagrid, $object, $index)
public function createCellView(DatagridView $datagrid, $object, $index): CellView
{
// The methods createCellView(), buildCellView() are called
// explicitly here in order to be able to override either of them
Expand Down Expand Up @@ -214,7 +214,7 @@ public function setDataProvider(callable $dataProvider)
*
* @return callable
*/
public function getDataProvider()
public function getDataProvider(): callable
{
return $this->dataProvider;
}
Expand Down
18 changes: 9 additions & 9 deletions src/Column/ColumnInterface.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);

/*
* This file is part of the RollerworksDatagrid package.
Expand All @@ -24,14 +24,14 @@ interface ColumnInterface
*
* @return string
*/
public function getName();
public function getName(): string;

/**
* Returns the column-type name.
*
* @return ResolvedColumnTypeInterface
*/
public function getType();
public function getType(): ResolvedColumnTypeInterface;

/**
* Appends / prepends a transformer to the view transformer chain.
Expand All @@ -58,14 +58,14 @@ public function resetViewTransformers();
*
* @return DataTransformerInterface[] An array of {@link DataTransformerInterface} instances
*/
public function getViewTransformers();
public function getViewTransformers(): array;

/**
* Returns all options passed during the construction of the column.
*
* @return array The passed options
*/
public function getOptions();
public function getOptions(): array;

/**
* Returns the value of a specific option.
Expand All @@ -84,14 +84,14 @@ public function getOption($name, $default = null);
*
* @return bool
*/
public function hasOption($name);
public function hasOption($name): bool;

/**
* @param DatagridView $datagrid
*
* @return HeaderView
*/
public function createHeaderView(DatagridView $datagrid);
public function createHeaderView(DatagridView $datagrid): HeaderView;

/**
* @param DatagridView $datagrid
Expand All @@ -100,7 +100,7 @@ public function createHeaderView(DatagridView $datagrid);
*
* @return CellView
*/
public function createCellView(DatagridView $datagrid, $object, $index);
public function createCellView(DatagridView $datagrid, $object, $index): CellView;

/**
* Set the data-provider for the column.
Expand All @@ -114,5 +114,5 @@ public function setDataProvider(callable $dataProvider);
*
* @return callable
*/
public function getDataProvider();
public function getDataProvider(): callable;
}
4 changes: 2 additions & 2 deletions src/Column/ColumnTypeExtensionInterface.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);

/*
* This file is part of the RollerworksDatagrid package.
Expand Down Expand Up @@ -50,5 +50,5 @@ public function configureOptions(OptionsResolver $optionsResolver);
*
* @return string The name of the type being extended
*/
public function getExtendedType();
public function getExtendedType(): string;
}
4 changes: 2 additions & 2 deletions src/Column/ColumnTypeInterface.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);

/*
* This file is part of the RollerworksDatagrid package.
Expand Down Expand Up @@ -56,7 +56,7 @@ public function buildHeaderView(HeaderView $view, ColumnInterface $column, array
*
* @return string The prefix of the template block name
*/
public function getBlockPrefix();
public function getBlockPrefix(): string;

/**
* Returns the fully-qualified class name of the parent type.
Expand Down
Loading

0 comments on commit a2d75f1

Please sign in to comment.