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

ZF3 #213

Merged
merged 28 commits into from
Jun 27, 2016
Merged

ZF3 #213

Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
2089b51
Update ZDT for use with modern ZF components
Apr 27, 2016
07fc76c
use PSR4 autoloader
Apr 27, 2016
69cc60c
Merge branch 'master' of github.com:alex-oleshkevich/ZendDeveloperTools
Apr 27, 2016
dd79364
Merge branch 'master' of github.com:alex-oleshkevich/ZendDeveloperTools
Apr 27, 2016
a41ee4c
Merge branch 'master' of github.com:alex-oleshkevich/ZendDeveloperTools
Apr 27, 2016
183d6e8
Remove phpunit.xml
Apr 27, 2016
f2dc619
remove 5.3 and 5.4 versions of php from travis
Apr 27, 2016
bf4d652
Update composer.json
alex-oleshkevich May 4, 2016
e063b7d
remove Module::getAutoloaderConfig() as https://github.com/zendframew…
samsonasik Jun 24, 2016
9aaca7d
update zend-mvc dependency
samsonasik Jun 24, 2016
3125403
short array syntax
samsonasik Jun 25, 2016
cb1b467
another short array syntax
samsonasik Jun 25, 2016
6f272e5
remove php 7 from allow_failures
samsonasik Jun 25, 2016
616ba68
uses "test" instead of "tests" folder for consistency
samsonasik Jun 25, 2016
50cf2f2
psr-4 autoloader
samsonasik Jun 25, 2016
c47b1db
use phpunit: ~4 || ~5
samsonasik Jun 25, 2016
a2554cf
update include module.config.php path
samsonasik Jun 25, 2016
75f6fb7
use ZendDeveloperToolsTest for test
samsonasik Jun 25, 2016
498cb0d
one empty line at the end of .travis.yml
samsonasik Jun 25, 2016
891d3e8
remove whitespace in ToolbarListener
samsonasik Jun 25, 2016
6981ee0
another white character
samsonasik Jun 25, 2016
8d0c9be
remove duplicated autoload-dev
samsonasik Jun 25, 2016
219eb58
added php-cs check and checks for lowest, locked, latest in .travis.yml
samsonasik Jun 25, 2016
ca71be4
cs fix
samsonasik Jun 25, 2016
0419000
whitespace fix
samsonasik Jun 25, 2016
f554d92
commit composer.lock
samsonasik Jun 25, 2016
3232f51
remove DEPS=locked from php 5.5
samsonasik Jun 25, 2016
fdaaf23
re-update composer.lock
samsonasik Jun 25, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
language: php

php:
- 5.3.3
- 5.4
- 5.5
- 5.6
- 7
Expand All @@ -12,8 +10,4 @@ before_install:
- composer install --prefer-source

script:
- ./vendor/bin/phpunit

matrix:
allow_failures:
- php: 7.0
- ./vendor/bin/phpunit
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one empty line at the and of the file plz

25 changes: 13 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@
}
],
"require": {
"php": ">=5.3.3",
"zendframework/zend-mvc": "2.*",
"zendframework/zend-eventmanager": "2.*",
"zendframework/zend-stdlib": "2.*",
"zendframework/zend-servicemanager": "2.*",
"zendframework/zend-modulemanager": "2.*",
"zendframework/zend-version": "2.*",
"zendframework/zend-debug": "2.*",
"zendframework/zend-view": "2.*"
"php": "^5.5 || ^7.0",
"zendframework/zend-mvc": "^2.7 || ^3.0.1",
"zendframework/zend-eventmanager": "^2.6.2 || ^3.0",
"zendframework/zend-stdlib": "^2.7 || ^3.0",
"zendframework/zend-servicemanager": "^2.7.5 || ^3.0.3",
"zendframework/zend-modulemanager": "^2.7",
"zendframework/zend-version": "^2.5",
"zendframework/zend-debug": "^2.5 || ^3.0",
"zendframework/zend-view": "^2.6"
},
"require-dev": {
"phpunit/phpunit": "~4"
"phpunit/phpunit": "~4 || ~5"
},
"suggest": {
"bjyoungblood/bjy-profiler": "Version: dev-master, allows the usage of the (Zend) Db collector.",
Expand All @@ -45,8 +45,9 @@
"aist/aist-git-tools": "Show you informations about current GIT repository"
},
"autoload": {
"psr-0": {
"ZendDeveloperTools": "src/"
"psr-4": {
"ZendDeveloperTools\\": "src/",
"ZendDeveloperToolsTest\\": "test/"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

autoloading tests should be in autoload-dev section (please update below)

}
},
"autoload-dev": {
Expand Down
12 changes: 6 additions & 6 deletions config/module.config.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
return array(
'view_manager' => array(
'template_path_stack' => array(
return [
'view_manager' => [
'template_path_stack' => [
'zenddevelopertools' => __DIR__ . '/../view',
),
),
);
],
],
];
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
syntaxCheck="true"
>
<testsuite name="ZendDeveloperTools tests suite">
<directory>./tests</directory>
<directory>./test</directory>
</testsuite>
<filter>
<whitelist addUncoveredFilesFromWhitelist="true">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public function getApplicationConfig()
*/
public function serialize()
{
return serialize(array('config' => $this->config, 'applicationConfig' => $this->applicationConfig));
return serialize(['config' => $this->config, 'applicationConfig' => $this->applicationConfig]);
}

/**
Expand All @@ -113,7 +113,7 @@ public function unserialize($serialized)
*/
private function makeArraySerializable($data)
{
$serializable = array();
$serializable = [];

foreach (ArrayUtils::iteratorToArray($data) as $key => $value) {
if ($value instanceof Traversable || is_array($value)) {
Expand Down Expand Up @@ -143,7 +143,7 @@ private function makeArraySerializable($data)
*/
private function unserializeArray(array $data)
{
$unserialized = array();
$unserialized = [];

foreach (ArrayUtils::iteratorToArray($data) as $key => $value) {
if ($value instanceof Traversable || is_array($value)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ public function getPriority()
public function collect(MvcEvent $mvcEvent)
{
if ($mvcEvent->getError() === Application::ERROR_EXCEPTION) {
$this->data = array(
$this->data = [
'exception' => new SerializableException($mvcEvent->getParam('exception'))
);
];
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function getPriority()
public function collect(MvcEvent $mvcEvent)
{
if (!isset($this->data)) {
$this->data = array();
$this->data = [];
}

$this->data['memory'] = memory_get_peak_usage(true);
Expand All @@ -62,7 +62,7 @@ public function collectEvent($id, Event $event)
$context['memory'] = memory_get_usage(true);

if (!isset($this->data['event'][$id])) {
$this->data['event'][$id] = array();
$this->data['event'][$id] = [];
}

$this->data['event'][$id][] = $context;
Expand Down Expand Up @@ -95,7 +95,7 @@ public function hasEventMemory()
*/
public function getApplicationEventMemory()
{
$result = array();
$result = [];

if (!isset($this->data['event']['application'])) {
return $result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function getPriority()
*/
public function collect(MvcEvent $mvcEvent)
{
$views = array();
$views = [];
$match = $mvcEvent->getRouteMatch();
$viewModel = $mvcEvent->getViewModel();

Expand All @@ -55,23 +55,23 @@ public function collect(MvcEvent $mvcEvent)
$var = $key . ': ' . (is_object($var) ? get_class($var) : gettype($var));
}
sort($vars);
$views[] = array(
$views[] = [
'template' => $child->getTemplate(),
'vars' => $vars,
);
];
};

$addToViewFromModel($viewModel);
$this->addChildrenToView($viewModel, $addToViewFromModel);

$this->data = array(
$this->data = [
'views' => $views,
'method' => $mvcEvent->getRequest()->getMethod(),
'status' => $mvcEvent->getResponse()->getStatusCode(),
'route' => ($match === null) ? 'N/A' : $match->getMatchedRouteName(),
'action' => ($match === null) ? 'N/A' : $match->getParam('action', 'N/A'),
'controller' => ($match === null) ? 'N/A' : $match->getParam('controller', 'N/A')
);
];
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function collect(MvcEvent $mvcEvent)
}

if (!isset($this->data)) {
$this->data = array();
$this->data = [];
}

$this->data['start'] = $start;
Expand All @@ -70,7 +70,7 @@ public function collectEvent($id, Event $event)
$context['line'] = $contextProvider->getEventTriggerLine();

if (!isset($this->data['event'][$id])) {
$this->data['event'][$id] = array();
$this->data['event'][$id] = [];
}

$this->data['event'][$id][] = $context;
Expand Down Expand Up @@ -113,7 +113,7 @@ public function hasEventTimes()
*/
public function getApplicationEventTimes()
{
$result = array();
$result = [];

if (!isset($this->data['event']['application'])) {
return $result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class EventContextProvider implements EventContextInterface
*
* @var array
*/
private $debugBacktrace = array();
private $debugBacktrace = [];

/**
* @param EventInterface $event (Optional) The event to provide context to. The event must be set either here or
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class SerializableException implements \Serializable
*/
public function __construct(\Exception $exception)
{
$this->data = array(
$this->data = [
'code' => $exception->getCode(),
'file' => $exception->getFile(),
'line' => $exception->getLine(),
Expand All @@ -37,7 +37,7 @@ public function __construct(\Exception $exception)
$exception->getFile(),
$exception->getLine()
),
);
];
}

/**
Expand Down Expand Up @@ -109,18 +109,18 @@ public function getPrevious()
*/
protected function filterTrace($trace, $file, $line)
{
$filteredTrace = array();
$filteredTrace = [];

$filteredTrace[] = array(
$filteredTrace[] = [
'namespace' => '',
'short_class' => '',
'class' => '',
'type' => '',
'function' => '',
'file' => $file,
'line' => $line,
'args' => array(),
);
'args' => [],
];

foreach ($trace as $entry) {
$class = '';
Expand All @@ -132,16 +132,16 @@ protected function filterTrace($trace, $file, $line)
$namespace = implode('\\', $parts);
}

$filteredTrace[] = array(
$filteredTrace[] = [
'namespace' => $namespace,
'short_class' => $class,
'class' => isset($entry['class']) ? $entry['class'] : '',
'type' => isset($entry['type']) ? $entry['type'] : '',
'function' => $entry['function'],
'file' => isset($entry['file']) ? $entry['file'] : null,
'line' => isset($entry['line']) ? $entry['line'] : null,
'args' => isset($entry['args']) ? $this->filterArgs($entry['args']) : array(),
);
'args' => isset($entry['args']) ? $this->filterArgs($entry['args']) : [],
];
}

return $filteredTrace;
Expand All @@ -159,25 +159,25 @@ protected function filterTrace($trace, $file, $line)
*/
protected function filterArgs($args, $level = 0)
{
$result = array();
$result = [];

foreach ($args as $key => $value) {
if (is_object($value)) {
$result[$key] = array('object', get_class($value));
$result[$key] = ['object', get_class($value)];
} elseif (is_array($value)) {
if ($level > 10) {
$result[$key] = array('array', '*DEEP NESTED ARRAY*');
$result[$key] = ['array', '*DEEP NESTED ARRAY*'];
} else {
$result[$key] = array('array', $this->filterArgs($value, ++$level));
$result[$key] = ['array', $this->filterArgs($value, ++$level)];
}
} elseif (null === $value) {
$result[$key] = array('null', null);
$result[$key] = ['null', null];
} elseif (is_bool($value)) {
$result[$key] = array('boolean', $value);
$result[$key] = ['boolean', $value];
} elseif (is_resource($value)) {
$result[$key] = array('resource', get_resource_type($value));
$result[$key] = ['resource', get_resource_type($value)];
} else {
$result[$key] = array('string', (string) $value);
$result[$key] = ['string', (string) $value];
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@

use Zend\EventManager\Event;
use Zend\EventManager\SharedEventManagerInterface;
use Zend\EventManager\SharedListenerAggregateInterface;
use Zend\ServiceManager\Exception\ServiceNotFoundException;
use ZendDeveloperTools\Collector\CollectorInterface;
use ZendDeveloperTools\Collector\EventCollectorInterface;
use ZendDeveloperTools\Profiler;

/**
Expand All @@ -22,10 +21,10 @@
* @author Mark Garrett <[email protected]>
* @since 0.0.3
*/
class EventLoggingListenerAggregate implements SharedListenerAggregateInterface
class EventLoggingListenerAggregate
{
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

possible BC break?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it tested with EventManager v2 and v3

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@svycka Essentially, that interface goes away with v3, so to make code forwards compatible, you cannot directly implement the interface. Since this particular class implements a method for attaching listeners to the shared manager, and that method is what is called inside the Module class, it continues to work perfectly.

/**
* @var \ZendDeveloperTools\Collector\EventCollectorInterface[]
* @var EventCollectorInterface[]
*/
protected $collectors;

Expand All @@ -37,7 +36,7 @@ class EventLoggingListenerAggregate implements SharedListenerAggregateInterface
/**
* Constructor.
*
* @param \ZendDeveloperTools\Collector\EventCollectorInterface[] $collectors
* @param EventCollectorInterface[] $collectors
* @param string[] $identifiers
*/
public function __construct(array $collectors, array $identifiers)
Expand All @@ -61,7 +60,9 @@ function ($identifier) {
*/
public function attachShared(SharedEventManagerInterface $events)
{
$events->attach($this->identifiers, '*', array($this,'onCollectEvent'), Profiler::PRIORITY_EVENT_COLLECTOR);
foreach ($this->identifiers as $id) {
$events->attach($id, '*', [$this,'onCollectEvent'], Profiler::PRIORITY_EVENT_COLLECTOR);
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class FirePhpListener implements ListenerAggregateInterface
/**
* @var array
*/
protected $listeners = array();
protected $listeners = [];

/**
* Constructor.
Expand All @@ -44,11 +44,11 @@ public function __construct(ServiceLocatorInterface $serviceLocator)
/**
* {@inheritdoc}
*/
public function attach(EventManagerInterface $events)
public function attach(EventManagerInterface $events, $priority = 1)
{
$this->listeners[] = $events->attach(
ProfilerEvent::EVENT_COLLECTED,
array($this, 'onCollected'),
[$this, 'onCollected'],
Profiler::PRIORITY_FIREPHP
);
}
Expand Down
Loading