Skip to content
This repository has been archived by the owner on Dec 7, 2023. It is now read-only.

Commit

Permalink
travis and code style updates (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinpapst authored Jun 6, 2019
1 parent d915832 commit 7fdb6b4
Show file tree
Hide file tree
Showing 35 changed files with 181 additions and 116 deletions.
2 changes: 2 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
github: [kevinpapst]
custom: https://paypal.me/kevinpapst
12 changes: 11 additions & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
<!-- All my contributions adhere implicitly to the MIT license -->
## Description
A clear and concise description of what this pull request adds or changes.

## Types of changes
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)

## Checklist
- [ ] I updated the documentation (see [here](https://github.com/kevinpapst/AdminLTEBundle/tree/master/Resources/docs))
- [ ] I agree that this code is used in AdminLTEBundle and will be published under the [MIT license](https://github.com/kevinpapst/AdminLTEBundle/blob/master/LICENSE)
8 changes: 4 additions & 4 deletions .php_cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,10 @@ return PhpCsFixer\Config::create()
])
->name('*.php')
->exclude([
__DIR__ . '/.github',
__DIR__ . '/node_modules',
__DIR__ . '/Resources',
__DIR__ . '/vendor',
'.github/',
'node_modules/',
'Resources/',
'vendor/',
])
)
->setFormat('checkstyle')
Expand Down
11 changes: 6 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,17 @@ matrix:
include:
- php: 7.1
- php: 7.2
- php: 7.3

before_install:
- phpenv config-rm xdebug.ini
- composer self-update
- php -i

install:
- composer install

# This triggers builds to run on the new TravisCI infrastructure.
# See: http://docs.travis-ci.com/user/workers/container-based-infrastructure/

notifications:
webhooks: ~
script:
- composer codestyle
- composer phpstan
- composer tests
23 changes: 23 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Contributing

The AdminLTEBundle is an open source project and contributions made by the community are welcome.
Send your ideas, code reviews, pull requests and feature requests to help me improve this project.

To make my and your live easier, here are the simple rules for PRs.

## Pull request rules

- Fix your codestyles before pushing with `composer codestyle-fix`
- Fix static code analysis errors, use `composer phpstan`
- Add PHPUnit tests for your changes and execute all tests with `composer tests`
- Travis fails if you do not verify the above points: fix the errors :-)
- Verify everything still works, e.g. using a branch inside the [demo apps](https://github.com/kevinpapst/AdminLTEBundle-Demo) with composer.json pointing to your AdminLTEBundle branch
- the app is not well tested (old codebase) so you have to do this manually
- With sending in a PR, you accept that your contributions/code will be published under MIT license (see [LICENSE](LICENSE))

## Code styles

As this project is a fork, the code is written in different flavours and the code base
is not yet upgraded to be fully consistent. But for all new changes I'd like to stick to the following rules:
- use strict typing wherever possible (function params, returns types ...)
- camelCase variables and function names
4 changes: 2 additions & 2 deletions Controller/BreadcrumbController.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ public function breadcrumbAction(Request $request)

/** @var SidebarMenuEvent $event */
$event = $this->getDispatcher()->dispatch(ThemeEvents::THEME_BREADCRUMB, new SidebarMenuEvent($request));
/** @var MenuItemInterface $active */
$active = $event->getActive();
/** @var $active MenuItemInterface */
$list = [];
if ($active) {
if (null !== $active) {
$list[] = $active;
while (null !== ($item = $active->getActiveChild())) {
$list[] = $item;
Expand Down
2 changes: 1 addition & 1 deletion Controller/EmitterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ protected function hasListener($eventName)
*
* Then it will dispatch the event as normal via the event dispatcher.
*
* @param $eventName
* @param string $eventName
* @param Event $event
*
* @return Event
Expand Down
16 changes: 8 additions & 8 deletions Controller/NavbarController.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ public function notificationsAction($max = null)

return $this->render(
'@AdminLTE/Navbar/notifications.html.twig',
[
'notifications' => $listEvent->getNotifications(),
'total' => $listEvent->getTotal(),
]
[
'notifications' => $listEvent->getNotifications(),
'total' => $listEvent->getTotal(),
]
);
}

Expand All @@ -78,10 +78,10 @@ public function messagesAction($max = null)

return $this->render(
'@AdminLTE/Navbar/messages.html.twig',
[
[
'messages' => $listEvent->getMessages(),
'total' => $listEvent->getTotal(),
]
]
);
}

Expand All @@ -105,10 +105,10 @@ public function tasksAction($max = null)

return $this->render(
'@AdminLTE/Navbar/tasks.html.twig',
[
[
'tasks' => $listEvent->getTasks(),
'total' => $listEvent->getTotal(),
]
]
);
}

Expand Down
8 changes: 4 additions & 4 deletions Controller/SidebarController.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ public function userPanelAction()

return $this->render(
'@AdminLTE/Sidebar/user-panel.html.twig',
[
[
'user' => $userEvent->getUser(),
]
]
);
}

Expand All @@ -60,9 +60,9 @@ public function menuAction(Request $request)

return $this->render(
'@AdminLTE/Sidebar/menu.html.twig',
[
[
'menu' => $event->getItems(),
]
]
);
}
}
17 changes: 17 additions & 0 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

namespace KevinPapst\AdminLTEBundle\DependencyInjection;

use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;

Expand All @@ -27,9 +28,11 @@ public function getConfigTreeBuilder()
$treeBuilder = new TreeBuilder('admin_lte');

if (method_exists($treeBuilder, 'getRootNode')) {
/** @var ArrayNodeDefinition $rootNode */
$rootNode = $treeBuilder->getRootNode();
} else {
// BC layer for symfony/config 4.1 and older
/** @var ArrayNodeDefinition $rootNode */
$rootNode = $treeBuilder->root('admin_lte');
}

Expand All @@ -51,8 +54,10 @@ private function getRouteAliasesConfig()
$treeBuilder = new TreeBuilder('routes');

if (method_exists($treeBuilder, 'getRootNode')) {
/** @var ArrayNodeDefinition $rootNode */
$rootNode = $treeBuilder->getRootNode();
} else {
/** @var ArrayNodeDefinition $rootNode */
$rootNode = $treeBuilder->root('routes');
}

Expand Down Expand Up @@ -118,8 +123,10 @@ private function getKnpMenuConfig()
$treeBuilder = new TreeBuilder('knp_menu');

if (method_exists($treeBuilder, 'getRootNode')) {
/** @var ArrayNodeDefinition $rootNode */
$rootNode = $treeBuilder->getRootNode();
} else {
/** @var ArrayNodeDefinition $rootNode */
$rootNode = $treeBuilder->root('knp_menu');
}

Expand Down Expand Up @@ -149,8 +156,10 @@ private function getWidgetConfig()
$treeBuilder = new TreeBuilder('widget');

if (method_exists($treeBuilder, 'getRootNode')) {
/** @var ArrayNodeDefinition $rootNode */
$rootNode = $treeBuilder->getRootNode();
} else {
/** @var ArrayNodeDefinition $rootNode */
$rootNode = $treeBuilder->root('widget');
}

Expand Down Expand Up @@ -200,8 +209,10 @@ private function getButtonConfig()
$treeBuilder = new TreeBuilder('button');

if (method_exists($treeBuilder, 'getRootNode')) {
/** @var ArrayNodeDefinition $rootNode */
$rootNode = $treeBuilder->getRootNode();
} else {
/** @var ArrayNodeDefinition $rootNode */
$rootNode = $treeBuilder->root('button');
}

Expand All @@ -227,8 +238,10 @@ private function getThemeConfig()
$treeBuilder = new TreeBuilder('theme');

if (method_exists($treeBuilder, 'getRootNode')) {
/** @var ArrayNodeDefinition $rootNode */
$rootNode = $treeBuilder->getRootNode();
} else {
/** @var ArrayNodeDefinition $rootNode */
$rootNode = $treeBuilder->root('theme');
}

Expand All @@ -248,8 +261,10 @@ private function getOptionsConfig()
$treeBuilder = new TreeBuilder('options');

if (method_exists($treeBuilder, 'getRootNode')) {
/** @var ArrayNodeDefinition $rootNode */
$rootNode = $treeBuilder->getRootNode();
} else {
/** @var ArrayNodeDefinition $rootNode */
$rootNode = $treeBuilder->root('options');
}

Expand Down Expand Up @@ -303,8 +318,10 @@ private function getControlSidebarConfig()
$treeBuilder = new TreeBuilder('control_sidebar');

if (method_exists($treeBuilder, 'getRootNode')) {
/** @var ArrayNodeDefinition $rootNode */
$rootNode = $treeBuilder->getRootNode();
} else {
/** @var ArrayNodeDefinition $rootNode */
$rootNode = $treeBuilder->root('control_sidebar');
}

Expand Down
8 changes: 2 additions & 6 deletions Event/KnpMenuEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

use Knp\Menu\FactoryInterface;
use Knp\Menu\ItemInterface;
use Knp\Menu\MenuFactory;
use Knp\Menu\MenuItem;

/**
* The KnpMenuEvent should be used with the ThemeEvents::THEME_SIDEBAR_SETUP_KNP_MENU
Expand All @@ -38,8 +36,6 @@ class KnpMenuEvent extends ThemeEvent
private $childOptions;

/**
* KnpMneuEvent constructor.
*
* @param ItemInterface $menu
* @param FactoryInterface $factory
* @param array $options
Expand All @@ -54,15 +50,15 @@ public function __construct($menu, $factory, $options = [], $childOptions = [])
}

/**
* @return MenuItem
* @return ItemInterface
*/
public function getMenu()
{
return $this->menu;
}

/**
* @return MenuFactory
* @return FactoryInterface
*/
public function getFactory()
{
Expand Down
1 change: 1 addition & 0 deletions Event/MessageListEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public function getMessages()
if (null !== $this->max) {
return array_slice($this->messages, 0, $this->max);
}

return $this->messages;
}

Expand Down
1 change: 1 addition & 0 deletions Event/NotificationListEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public function getNotifications()
if (null !== $this->max) {
return array_slice($this->notifications, 0, $this->max);
}

return $this->notifications;
}

Expand Down
2 changes: 1 addition & 1 deletion Event/ShowUserEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function setUser($user)
}

/**
* @return UserInterface
* @return UserInterface|null
*/
public function getUser()
{
Expand Down
2 changes: 1 addition & 1 deletion Event/SidebarMenuEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function addItem($item)

/**
* @param string $id
* @return MenuItemInterface||MenuItem|null
* @return MenuItemInterface|MenuItem|null
*/
public function getRootItem($id)
{
Expand Down
1 change: 1 addition & 0 deletions Event/TaskListEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public function getTasks()
if (null !== $this->max) {
return array_slice($this->tasks, 0, $this->max);
}

return $this->tasks;
}

Expand Down
10 changes: 5 additions & 5 deletions Helper/ContextHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ContextHelper extends \ArrayObject
/**
* @return array
*/
public function getOptions()
public function getOptions(): array
{
return $this->getArrayCopy();
}
Expand All @@ -24,18 +24,18 @@ public function getOptions()
* @param mixed $value
* @return $this
*/
public function setOption($name, $value)
public function setOption(string $name, $value): ContextHelper
{
$this->offsetSet($name, $value);

return $this;
}

/**
* @param $name
* @param string $name
* @return bool
*/
public function hasOption($name)
public function hasOption(string $name): bool
{
return $this->offsetExists($name);
}
Expand All @@ -45,7 +45,7 @@ public function hasOption($name)
* @param mixed $default
* @return mixed|null
*/
public function getOption($name, $default = null)
public function getOption(string $name, $default = null)
{
return $this->offsetExists($name) ? $this->offsetGet($name) : $default;
}
Expand Down
11 changes: 7 additions & 4 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
Copyright (c) 2014-2018 Marc Bach, Ángel Guzmán Maeso, Kevin Papst and others
MIT License

See the full list of contributors at:
https://github.com/avanzu/AdminThemeBundle/graphs/contributors
https://github.com/kevinpapst/AdminLTEBundle/graphs/contributors
Copyright (c) 2014-2018 Marc Bach, Ángel Guzmán Maeso, Kevin Papst and others

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -21,3 +19,8 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

---
You can find the full list of contributors at:
https://github.com/avanzu/AdminThemeBundle/graphs/contributors
https://github.com/kevinpapst/AdminLTEBundle/graphs/contributors
Loading

0 comments on commit 7fdb6b4

Please sign in to comment.