Skip to content

Commit

Permalink
Merge pull request #166 from jackalope/upgrade-to-2
Browse files Browse the repository at this point in the history
upgrade to jackalope 2
  • Loading branch information
dbu authored Feb 20, 2023
2 parents f8013c9 + b04194d commit f183b66
Show file tree
Hide file tree
Showing 19 changed files with 583 additions and 1,024 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
coverage: none

- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3

# have to install phpstan ourselves here, the phpstan-ga fails at composer install with weird errors
- name: Install phpstan
Expand All @@ -48,7 +48,7 @@ jobs:
coverage: none

- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Install phpstan
run: |
Expand All @@ -64,7 +64,7 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: PHP-CS-Fixer
uses: docker://oskarstark/php-cs-fixer-ga
Expand Down
23 changes: 14 additions & 9 deletions .github/workflows/test-application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,15 @@ jobs:

matrix:
include:
- php-version: '7.2'
- php-version: '7.4'
dependencies: 'lowest'
- php-version: '7.2'
- php-version: '7.3'
- php-version: '7.4'
- php-version: '8.0'
- php-version: '8.1'

steps:
- name: Checkout project
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Install and configure PHP
uses: shivammathur/setup-php@v2
Expand All @@ -37,15 +35,22 @@ jobs:
tools: 'composer:v2'

- name: Install dependencies with Composer
uses: ramsey/composer-install@v1
uses: ramsey/composer-install@v2
with:
dependency-versions: ${{ matrix.dependencies }}
composer-options: --prefer-dist

- name: Start jackrabbit
- name: Get source version of phpcr-utils
run: |
./bin/jackrabbit.sh
rm -rf vendor/phpcr/phpcr-utils
composer update phpcr/phpcr-utils --prefer-source
- name: Start jackrabbit
run: bin/jackrabbit.sh

- name: Execute test cases
run: |
vendor/bin/phpunit
run: vendor/bin/phpunit

- name: Print Jackrabbit logs on error
if: ${{ failure() }}
run: cat bin/jackrabbit/log/*
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
Changelog
=========

Version 1
Version 2
=========

2.0.0 (unreleased)
------------------

* Added static typing whereever possible. This should not change anything, but the added strictness
might trigger errors where it was more tolerant for incorrect types before.
* Renamed cli-config.php.dist to cli-config.dist.php and cleaned up to be better documented.

Version 1
=========

1.4.4
-----

Expand Down
7 changes: 7 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Upgrade
=======

Version 1 to Version 2
----------------------

`Client::forceHttpVersion10` has been removed in favor of `Client::addCurlOptions([CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_0])`.
13 changes: 7 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,24 @@
}
],
"require": {
"php": "^7.2 || ^8.0",
"php": "^7.4 || ^8.0",
"ext-xml":"*",
"ext-dom": "*",
"ext-curl":"*",
"ext-json":"*",
"phpcr/phpcr": "~2.1.5",
"phpcr/phpcr-utils": "^1.3.0",
"jackalope/jackalope": "^1.3.5"
"phpcr/phpcr-utils": "^1.8.0",
"jackalope/jackalope": "^2.0.0-beta1"
},
"provide": {
"jackalope/jackalope-transport": "1.3.0"
"jackalope/jackalope-transport": "2.0.0"
},
"require-dev": {
"psr/log": "~1.0",
"phpcr/phpcr-api-tests": "2.1.22",
"phpcr/phpcr-api-tests": "2.1.24",
"symfony/console": "^2.3 || ^3.4 || ^4.3 || ^5.0 || ^6.0",
"phpunit/phpunit": "^7.5 || ^8.0 || ^9.0"
"phpunit/phpunit": "^9.5",
"phpstan/phpstan": "^1.9"
},
"autoload": {
"psr-0": { "Jackalope\\": "src/" }
Expand Down
3 changes: 0 additions & 3 deletions src/Jackalope/Jackrabbit/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
*/
class Factory extends \Jackalope\Factory
{
/**
* {@inheritDoc}
*/
public function get($name, array $params = [])
{
switch ($name) {
Expand Down
15 changes: 5 additions & 10 deletions src/Jackalope/Jackrabbit/Query/QOM/QueryObjectModelFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,39 +15,33 @@
use PHPCR\Query\QOM\OrInterface;
use PHPCR\Query\QOM\PropertyExistenceInterface;
use PHPCR\Query\QOM\PropertyValueInterface;
use PHPCR\Query\QOM\QueryObjectModelInterface;
use PHPCR\Query\QOM\SelectorInterface;
use PHPCR\Query\QOM\SourceInterface;
use PHPCR\Query\QOM\UpperCaseInterface;

/**
* {@inheritDoc}
*
* @license http://www.apache.org/licenses Apache License Version 2.0, January 2004
* @license http://opensource.org/licenses/MIT MIT License
*
* @api
*/
class QueryObjectModelFactory extends BaseQueryObjectModelFactory
{
/**
* {@inheritDoc}
*
* @api
*/
public function createQuery(
SourceInterface $source,
ConstraintInterface $constraint = null,
array $orderings = [],
array $columns = [],
$simpleQuery = false
) {
): QueryObjectModelInterface {
$className = $this->isSimple($source, $constraint)
? 'Query\QOM\QueryObjectModelSql1' : 'Query\QOM\QueryObjectModel';

return $this->factory->get($className, [$this->objectManager, $source, $constraint, $orderings, $columns]);
}

protected function isSimple($source, $constraint)
private function isSimple(SourceInterface $source, ?ConstraintInterface $constraint): bool
{
if ($source instanceof JoinInterface) {
return false;
Expand All @@ -71,7 +65,8 @@ protected function isSimple($source, $constraint)
|| $c instanceof PropertyExistenceInterface
) {
continue;
} elseif ($c instanceof ComparisonInterface) {
}
if ($c instanceof ComparisonInterface) {
$o = $c->getOperand1();
if ($o instanceof LowerCaseInterface
|| $o instanceof UpperCaseInterface
Expand Down
7 changes: 1 addition & 6 deletions src/Jackalope/RepositoryFactoryJackrabbit.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,7 @@ public function getRepository(array $parameters = null)
return new Repository($factory, $transport, $options);
}

/**
* {@inheritDoc}
*
* @api
*/
public function getConfigurationKeys()
public function getConfigurationKeys(): array
{
return array_merge(self::$required, self::$optional);
}
Expand Down
12 changes: 3 additions & 9 deletions src/Jackalope/Tools/Console/Command/JackrabbitCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,18 @@ class JackrabbitCommand extends Command
{
/**
* Path to Jackrabbit jar file.
*
* @var string
*/
protected $jackrabbit_jar;
private string $jackrabbit_jar;

/**
* Path to the Jackrabbit workspace dir.
*
* @var string
*/
protected $workspace_dir;
private string $workspace_dir;

/**
* TCP port of the Jackrabbit HTTP server.
*
* @var int
*/
protected $port;
private int $port;

protected function configure(): void
{
Expand Down
26 changes: 12 additions & 14 deletions src/Jackalope/Tools/Console/Helper/JackrabbitHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,28 @@
*/
class JackrabbitHelper
{
protected $jackrabbit_jar;
protected $workspace_dir;
protected $port;
private string $jackrabbit_jar;
private string $workspace_dir;
private ?int $port;

/**
* construct an instance of the helper.
*
* @param string $jackrabbit_jar the path to the jackrabbit server jar file
* @param string $workspace_dir if provided this will be used as workspace directory, otherwise the directory of the jar file is used
* @param int $port if provided this will be used as port for HTTP server, otherwise the default is used
* @param string $jackrabbit_jar the path to the jackrabbit server jar file
* @param string|null $workspace_dir if provided this will be used as workspace directory, otherwise the directory of the jar file is used
* @param int|null $port if provided this will be used as port for HTTP server, otherwise the default is used
*/
public function __construct($jackrabbit_jar, $workspace_dir = null, $port = null)
public function __construct(string $jackrabbit_jar, string $workspace_dir = null, int $port = null)
{
$this->jackrabbit_jar = $jackrabbit_jar;
$this->workspace_dir = $workspace_dir ? $workspace_dir : dirname($jackrabbit_jar);
$this->workspace_dir = $workspace_dir ?: dirname($jackrabbit_jar);
$this->port = $port;
}

/**
* Start the jackrabbit server. If it is already running, silently return.
*/
public function startServer()
public function startServer(): void
{
$pid = $this->getServerPid();
if (!$pid) {
Expand All @@ -46,7 +46,7 @@ public function startServer()
/**
* Stop the jackrabbit server. If it is not running, silently return.
*/
public function stopServer()
public function stopServer(): void
{
$pid = $this->getServerPid();
if ($pid) {
Expand All @@ -56,15 +56,13 @@ public function stopServer()

/**
* Return true if the jackrabbit server is running, false otherwise.
*
* @return bool
*/
public function isServerRunning()
public function isServerRunning(): bool
{
return '' !== $this->getServerPid();
}

public function getServerPid()
public function getServerPid(): string
{
$pid = trim(shell_exec("pgrep -f -n 'java \-jar {$this->jackrabbit_jar}'"));
// TODO: check it's a valid pid
Expand Down
Loading

0 comments on commit f183b66

Please sign in to comment.