Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated and legacy code, migrate some syntax, cleanup #908

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
* text=auto
/.composer/ export-ignore
/.travis/ export-ignore
/.github/ export-ignore
/Tests/ export-ignore
/.coveralls.yml export-ignore
Expand Down
42 changes: 11 additions & 31 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,21 @@ sudo: false

language: php

php:
- 5.3
- 5.4
- 5.5
- 5.6
- 7.0
- 7.1
- hhvm

cache:
directories:
- $HOME/.composer/cache/files

env:
global:
- SYMFONY_VERSION=2.8.x
- SYMFONY_DEPRECATIONS_HELPER=weak

matrix:
include:
- php: 5.3
env: COMPOSER_FLAGS="--prefer-lowest"
- php: 5.6
env: SYMFONY_VERSION=2.3.x-dev
- php: 5.6
env: SYMFONY_VERSION=2.7.x-dev
- php: 7.1
- php: hhvm-stable
sudo: required
dist: trusty
env: SYMFONY_VERSION=3.0.x-dev
- php: 7.0
env: SYMFONY_VERSION=3.0.x-dev
- php: 7.1
env: SYMFONY_VERSION=3.1.x-dev
Expand All @@ -41,28 +29,20 @@ matrix:
- php: 7.1
env: SYMFONY_VERSION=dev-master
allow_failures:
- php: 7.1
env: SYMFONY_VERSION=3.3.x-dev
- php: 7.1
env: SYMFONY_VERSION=dev-master
- php: hhvm-stable
- env: SYMFONY_VERSION=dev-master
fast_finish: true

before_install:
- if [ "${TRAVIS_PHP_VERSION}" != "hhvm" ]; then echo "memory_limit = -1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini; fi;
- cp ./.composer/config.json ~/.composer; composer global require "hirak/prestissimo:^0.3"
- if [ "${TRAVIS_PHP_VERSION}" == "5.3" ]; then composer remove --no-update --dev satooshi/php-coveralls; fi;
- if [ "${SYMFONY_VERSION:0:3}" == "2.3" ]; then composer remove --no-update --dev friendsofphp/php-cs-fixer; fi;
- if [ "${SYMFONY_VERSION:-x}" != "x" ]; then composer require "symfony/symfony:${SYMFONY_VERSION}" --no-update; fi;
- if [ "${TRAVIS_PHP_VERSION}" != "hhvm" ] && [ "${TRAVIS_PHP_VERSION:0:3}" != "5.3" ]; then composer require --no-update --dev league/flysystem:~1.0; fi;
- if [ "${TRAVIS_PHP_VERSION}" != "hhvm" ] && [ "${TRAVIS_PHP_VERSION:0:1}" != "7" ]; then yes "" | pecl -q install -f mongo; composer require --no-update --dev doctrine/mongodb-odm:~1.0; fi;
- if [ "${TRAVIS_PHP_VERSION}" != "hhvm" ] && [ "${TRAVIS_PHP_VERSION:0:1}" == "7" ]; then yes "" | pecl -q install -f mongodb; travis_retry composer require --dev alcaeus/mongo-php-adapter:~1.0; composer require --no-update --dev doctrine/mongodb-odm:~1.0; fi
- bash ./.travis/exec-before.bash

install:
- travis_retry composer update $COMPOSER_FLAGS
- travis_retry composer require "symfony/symfony:${SYMFONY_VERSION}" $COMPOSER_FLAGS

script:
- bin/simple-phpunit -vvv || bin/phpunit -vvv

after_script:
- if [ "${TRAVIS_PHP_VERSION}" != "5.3" ]; then bin/coveralls -vvv; fi;
- bash ./.travis/exec-after.bash

...
File renamed without changes.
24 changes: 24 additions & 0 deletions .travis/exec-after.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

# exit if any statement returns a non-true value
set -e

# determine path to this script
readonly SELF_DIR_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/"

# source variables and functions files
source "${SELF_DIR_PATH}inc-variables.bash"
source "${SELF_DIR_PATH}inc-functions.bash"

#
# perform different operations depending on the environment
#
function main()
{
out_main "Running 'exec-after' operations"

send_coveralls_statistics
}

# go!
main
32 changes: 32 additions & 0 deletions .travis/exec-before.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash

# exit if any statement returns a non-true value
set -e

# determine path to this script
readonly SELF_DIR_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/"

# source variables and functions files
source "${SELF_DIR_PATH}inc-variables.bash"
source "${SELF_DIR_PATH}inc-functions.bash"

#
# perform different operations depending on the environment
#
function main()
{
out_main "Running 'exec-before' operations"

if [[ ! ${TRAVIS_PHP_VERSION} = hhvm* ]]; then
disable_php_memory_limit
fi

if [[ ${TRAVIS_PHP_VERSION} = hhvm* ]]; then
enable_hhvm_php7_mode
fi

initialize_prestissimo
}

# go!
main
89 changes: 89 additions & 0 deletions .travis/inc-functions.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#!/bin/bash

#
# output text to console
#
function out_line()
{
printf "[%d] %s...\n" $(date +%s) "${1}"
}

#
# output main text to console
#
function out_main()
{
out_line "${1^^}"
}

#
# disable the php memory limit by setting it to "-1"
#
function disable_php_memory_limit()
{
if [[ ! -d "$(dirname ${CONF_PATH_PHP7})" ]]; then
return
fi

out_line "Disabling PHP memory limit in '${CONF_PATH_PHP7}'"
echo "memory_limit = -1" >> "${CONF_PATH_PHP7}";
}

#
# enable the hhvm php7 mode by setting it to "1"
#
function enable_hhvm_php7_mode()
{
out_line "Enabling HHVM PHP7 mode in '${CONF_PATH_HHVM}'"
echo "hhvm.php7.all = 1" >> "${CONF_PATH_HHVM}"
echo "hhvm.php7.scalar_types = 0" >> "${CONF_PATH_HHVM}"
}

#
# configure the prestissimo package
#
function configure_prestissimo()
{
local composer_reqs="${1}"
local composer_orig="${TRAVIS_BUILD_DIR}/.travis/composer/config.json"
local composer_dest="${HOME}/.composer/config.json"

out_line "Configuring '${composer_reqs}' in '${composer_dest}'"
if [[ ! -d "$(dirname ${composer_dest})" ]]; then
mkdir "$(dirname ${composer_dest})"
fi
cp "${composer_orig}" "${composer_dest}"
}

#
# require the prestissimo package using composer
#
function require_prestissimo()
{
local composer_reqs="${1}"

out_line "Requiring '${composer_reqs}'"
composer global require "${composer_reqs}"
}

#
# initialize the prestissimo package
#
function initialize_prestissimo()
{
local composer_reqs="hirak/prestissimo:^0.3"

configure_prestissimo "${composer_reqs}"
require_prestissimo "${composer_reqs}"
}

#
# send coveralls statistics using the required binary
#
function send_coveralls_statistics()
{
local coveralls_bin="${TRAVIS_BUILD_DIR}/bin/coveralls"

out_line "Sending Coveralls coverage using '${coveralls_bin}'"
${coveralls_bin} -vvv
}
5 changes: 5 additions & 0 deletions .travis/inc-variables.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

# path to travis php configuration file
CONF_PATH_PHP7="${HOME}/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini"
CONF_PATH_HHVM="/etc/hhvm/php.ini"
21 changes: 5 additions & 16 deletions Binary/Loader/FileSystemLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,30 +38,19 @@ class FileSystemLoader implements LoaderInterface
/**
* @param MimeTypeGuesserInterface $mimeGuesser
* @param ExtensionGuesserInterface $extensionGuesser
* @param string[] $dataRoots
* @param LocatorInterface $locator
* @param string[] $rootPaths
*/
public function __construct(
MimeTypeGuesserInterface $mimeGuesser,
ExtensionGuesserInterface $extensionGuesser,
$dataRoots
/* LocatorInterface $locator */
LocatorInterface $locator,
array $rootPaths = []
) {
$this->mimeTypeGuesser = $mimeGuesser;
$this->extensionGuesser = $extensionGuesser;

if (count($dataRoots) === 0) {
throw new InvalidArgumentException('One or more data root paths must be specified.');
}

if (func_num_args() >= 4 && false === ($this->locator = func_get_arg(3)) instanceof LocatorInterface) {
throw new \InvalidArgumentException(sprintf('Method %s() expects a LocatorInterface for the forth argument.', __METHOD__));
} elseif (func_num_args() < 4) {
@trigger_error(sprintf('Method %s() will have a forth `LocatorInterface $locator` argument in version 2.0. Not defining it is deprecated since version 1.7.2', __METHOD__), E_USER_DEPRECATED);
Copy link
Collaborator Author

@robfrawley robfrawley May 2, 2017

Choose a reason for hiding this comment

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

Note to self: This deprecation notice needs to be amended to properly articulate the changes.

$this->locator = new FileSystemLocator();
}

$this->locator->setOptions(array('roots' => (array) $dataRoots));
$this->locator = $locator;
$this->locator->setOptions(['roots' => $rootPaths]);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why pass the $rootPaths to this class anyway since it's only handing them off to the passed in LocatorInterface? Why not set the option on the LocatorInterface before passing it to this class?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That is a valid question and something I've considered changing, but the current configuration handling of these items is tied to the *Loader implementations and not the *Locator classes; the FileLocator and InsecureFileSystem "locator" variants are really implementation details ATM.

I'm not really positive how we should handle this moving forward and am very open to its discussion, but I do think that it is more appropriate to handle that in a PR of its own, no?

Copy link
Collaborator Author

@robfrawley robfrawley May 3, 2017

Choose a reason for hiding this comment

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

IDK: now you got me thinking maybe it should be fully handled in this PR; what do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

Since you're making a signature change here I would solve the problem fully in this PR, instead of in another PR which breaks the signature a second time. People aren't supposed to be using 2.x yet I guess, but you never know 😃

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have not found a straightforward solution to this, and based on my testing the solution will likely be quite large (only making this pull request even larger), so I don't forsee this issue being resolved by this pull request. See #908 (comment) for additional details.

As for breaking changes (multiple times), I'm not too concerned about that; the whole point of having a development branch is to be able to actively develop on it. Those running the 1.x branch should expect no backward incompatible changes, but that doesn't apply here. I run the 2.0 branch on a few personal projects, and while it's annoying to update it when breaking changes occur, that is a contract I agreed to when I decided to run an unreleased version. We're going to need to introduce a plethora of additional breaking changes to complete many of the TODO items for 2.0, so let's focus on making the release amazing and not on making it easier for those running unreleased software. Right?

}

/**
Expand Down
54 changes: 0 additions & 54 deletions Binary/Loader/GridFSLoader.php

This file was deleted.

8 changes: 4 additions & 4 deletions Binary/Locator/FileSystemLocator.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,23 @@ class FileSystemLocator implements LocatorInterface
/**
* @var string[]
*/
private $roots = array();
private $roots = [];

/**
* @param array[] $options
*/
public function setOptions(array $options = array())
public function setOptions(array $options = [])
{
$resolver = new OptionsResolver();
$resolver->setDefaults(array('roots' => array()));
$resolver->setDefaults(['roots' => []]);

try {
$options = $resolver->resolve($options);
} catch (ExceptionInterface $e) {
throw new InvalidArgumentException(sprintf('Invalid options provided to %s()', __METHOD__), null, $e);
}

$this->roots = array_map(array($this, 'sanitizeRootPath'), (array) $options['roots']);
$this->roots = array_map([$this, 'sanitizeRootPath'], (array) $options['roots']);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion Binary/Locator/LocatorInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ interface LocatorInterface
/**
* @param array $options[]
*/
public function setOptions(array $options = array());
public function setOptions(array $options = []);

/**
* @param string $path
Expand Down
6 changes: 3 additions & 3 deletions Controller/ImagineController.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public function filterRuntimeAction(Request $request, $hash, $path, $filter)
$resolver = $request->get('resolver');

try {
$filters = $request->query->get('filters', array());
$filters = $request->query->get('filters', []);

if (!is_array($filters)) {
throw new NotFoundHttpException(sprintf('Filters must be an array. Value was "%s"', $filters));
Expand Down Expand Up @@ -169,9 +169,9 @@ public function filterRuntimeAction(Request $request, $hash, $path, $filter)
$rcPath = $this->cacheManager->getRuntimePath($path, $filters);

$this->cacheManager->store(
$this->filterManager->applyFilter($binary, $filter, array(
$this->filterManager->applyFilter($binary, $filter, [
'filters' => $filters,
)),
]),
$rcPath,
$filter,
$resolver
Expand Down
Loading