Skip to content

Commit 12abb88

Browse files
committed
Removing of code compatibility with php5.4, changes for readme.
1 parent d368a47 commit 12abb88

File tree

8 files changed

+27
-24
lines changed

8 files changed

+27
-24
lines changed

README.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Require this package in your composer.json and run composer update:
1616
```json
1717
{
1818
"require": {
19-
"nqxcode/laravel-lucene-search": "2.1.*-dev"
19+
"nqxcode/laravel-lucene-search": "2.1.*"
2020
}
2121
}
2222
```
@@ -25,15 +25,15 @@ After updating composer, add the ServiceProvider to the providers array in `app/
2525

2626
```php
2727
'providers' => [
28-
'Nqxcode\LuceneSearch\ServiceProvider',
28+
Nqxcode\LuceneSearch\ServiceProvider::class,
2929
],
3030
```
3131

3232
If you want to use the facade to search, add this to your facades in `app/config/app.php`:
3333

3434
```php
3535
'aliases' => [
36-
'Search' => 'Nqxcode\LuceneSearch\Facade',
36+
'Search' => Nqxcode\LuceneSearch\Facade::class,
3737
],
3838
```
3939
## Configuration
@@ -50,13 +50,13 @@ In published config file add descriptions for models which need to be indexed, f
5050

5151
// ...
5252

53-
'namespace\FirstModel' => [
53+
namespace\FirstModel::class => [
5454
'fields' => [
5555
'name', 'full_description', // Fields for indexing.
5656
]
5757
],
5858

59-
'namespace\SecondModel' => [
59+
namespace\SecondModel::class => [
6060
'fields' => [
6161
'name', 'short_description', // Fields for indexing.
6262
]
@@ -88,7 +88,7 @@ Example:
8888
In config file:
8989

9090
```php
91-
'namespace\FirstModel' => [
91+
namespace\FirstModel::class => [
9292
'fields' => [
9393
'name', 'full_description', // Fixed fields for indexing.
9494
],
@@ -100,7 +100,7 @@ In config file:
100100
In model add following accessor:
101101

102102
```php
103-
publc function getOptionalAttributesAttribute()
103+
public function getOptionalAttributesAttribute()
104104
{
105105
return [
106106
'optional_attribute1' => "value1",
@@ -119,7 +119,7 @@ This filters can be deleted or replaced with others.
119119
'analyzer' => [
120120
'filters' => [
121121
// Default stemming filter.
122-
'Nqxcode\Stemming\TokenFilterEnRu',
122+
Nqxcode\Stemming\TokenFilterEnRu::class,
123123
],
124124

125125
// List of paths to files with stopwords.
@@ -262,8 +262,9 @@ Highlighting of matches is available for any html fragment encoded in **utf-8**
262262
Search::find('nearly all words must be highlighted')->get();
263263
$highlighted = Search::highlight('all words');
264264

265-
// highlighted html:
266-
// '<span class="highlight">all</span> <span class="highlight">words</span>'
265+
echo $highlighted;
266+
267+
// Echo: <span class="highlight">all</span> <span class="highlight">words</span>
267268
```
268269
##
269270
## License

src/Nqxcode/LuceneSearch/Analyzer/Config.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function __construct(array $filterClasses, array $stopWordFiles, FilterFa
3535
public function setDefaultAnalyzer()
3636
{
3737
/** @var AbstractCommon $analyzer */
38-
$analyzer = App::make('ZendSearch\Lucene\Analysis\Analyzer\Common\AbstractCommon');
38+
$analyzer = App::make(AbstractCommon::class);
3939

4040
foreach ($this->stopWordFiles as $file) {
4141
$analyzer->addFilter($this->stopwordsFilterFactory->newInstance($file));
@@ -54,7 +54,7 @@ public function setDefaultAnalyzer()
5454
public function setHighlighterAnalyzer()
5555
{
5656
/** @var AbstractCommon $analyzer */
57-
$analyzer = App::make('ZendSearch\Lucene\Analysis\Analyzer\Common\AbstractCommon');
57+
$analyzer = App::make(AbstractCommon::class);
5858

5959
foreach ($this->filterClasses as $filterClass) {
6060
$analyzer->addFilter(App::make($filterClass));

src/Nqxcode/LuceneSearch/Console/RebuildCommand.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,13 @@ public function fire()
4545
$progress->advance();
4646
}
4747
$progress->finish();
48-
4948
} else {
5049
$this->comment(' No available models found. ');
5150
}
5251
}
53-
$this->info('Operation is fully complete!');
52+
$this->info(PHP_EOL . 'Operation is fully complete!');
5453
} else {
55-
$this->error('No models found in config.php file..');
54+
$this->error('No models found in config file..');
5655
}
5756
}
5857
}

src/Nqxcode/LuceneSearch/Model/Config.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,8 @@ function ($i) use ($field) {
192192
*/
193193
public function model(QueryHit $hit)
194194
{
195-
$repo = $this->createModelByClassUid(object_get($hit, 'class_uid'));
196-
$model = $repo->find(object_get($hit, 'private_key'));
195+
$repository = $this->createModelByClassUid(object_get($hit, 'class_uid'));
196+
$model = $repository->find(object_get($hit, 'private_key'));
197197

198198
return $model;
199199
}

src/Nqxcode/LuceneSearch/Model/Factory.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php namespace Nqxcode\LuceneSearch\Model;
22

33
use App;
4+
use Illuminate\Database\Eloquent\Model;
45

56
class Factory
67
{
@@ -11,7 +12,7 @@ class Factory
1112
*/
1213
public function newInstance($className)
1314
{
14-
$baseClass = 'Illuminate\Database\Eloquent\Model';
15+
$baseClass = Model::class;
1516

1617
if (!is_subclass_of($className, $baseClass)) {
1718
throw new \InvalidArgumentException(

src/Nqxcode/LuceneSearch/Query/Builder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,8 @@ public function rawQuery($query)
233233
$this->query = $query;
234234
} else {
235235
throw new \InvalidArgumentException(
236-
"Argument 'query' must be a string or ZendSearch\\Lucene\\Search\\Query\\AbstractQuery instance " .
237-
"or callable returning a string or ZendSearch\\Lucene\\Search\\Query\\AbstractQuery instance."
236+
"Argument 'query' must be a string or " . AbstractQuery::class . " instance " .
237+
"or callable returning a string or " . AbstractQuery::class . " instance."
238238
);
239239
}
240240

src/Nqxcode/LuceneSearch/Search.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
use Illuminate\Database\Eloquent\Model;
44
use Nqxcode\LuceneSearch\Highlighting\Html;
55
use Nqxcode\LuceneSearch\Model\Config;
6+
use Nqxcode\LuceneSearch\Query\Builder as QueryBuilder;
7+
use Nqxcode\LuceneSearch\Highlighting\Html as Highlighter;
68
use ZendSearch\Lucene\Document;
79
use ZendSearch\Lucene\Index\Term;
810
use ZendSearch\Lucene\Search\Query\MultiTerm;
@@ -156,7 +158,7 @@ public function delete(Model $model)
156158
*/
157159
public function __call($name, $arguments)
158160
{
159-
$queryBuilder = App::make('Nqxcode\LuceneSearch\Query\Builder');
161+
$queryBuilder = App::make(QueryBuilder::class);
160162
return call_user_func_array([$queryBuilder, $name], $arguments);
161163
}
162164

@@ -169,7 +171,7 @@ public function __call($name, $arguments)
169171
public function highlight($html)
170172
{
171173
/** @var Html $highlighter */
172-
$highlighter = App::make('Nqxcode\LuceneSearch\Highlighting\Html');
174+
$highlighter = App::make(Highlighter::class);
173175
return $highlighter->highlight($html);
174176
}
175177
}

src/config/config.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
|
1414
| For example, model's description can be like this:
1515
|
16-
| 'namespace\ModelClass' => [
16+
| namespace\ModelClass::class => [
1717
| 'fields' => [
1818
| 'name', 'description', // Fields for indexing.
1919
| ]
@@ -46,7 +46,7 @@
4646
'analyzer' => [
4747

4848
'filters' => [
49-
'Nqxcode\Stemming\TokenFilterEnRu',
49+
Nqxcode\Stemming\TokenFilterEnRu::class,
5050
],
5151

5252
'stopwords' => Nqxcode\LuceneSearch\Analyzer\Stopwords\Files::get(),

0 commit comments

Comments
 (0)